Sunday, December 15, 2019

Bucket Sorting in Java

I wrote this program ten years ago while I am learning Java programming I called this program Bucket Sorting in Java.

I am currently accepting programming work, IT projects, school and application development, programming projects, thesis and capstone projects, IT consulting work, computer tutorials, and web development work kindly contact me in the following email address for further details.  If you want to advertise on my website kindly contact me also in my email address also. Thank you.

My email address is the following jakerpomperada@gmail.com, jakerpomperada@aol.com, and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.

My telephone number at home here in Bacolod City, Negros Occidental Philippines is  +63 (034) 4335675.

Here in Bacolod City, Negros Occidental I also accepting computer repair, networking and Arduino Project development at a very affordable price.

My personal website is http://www.jakerpomperada.com

My programming website is http://www.jakerpomperada.blogspot.com

I am also a book author you can purchase my books on computer programming and information technology in the following links below.

https://www.mindshaperspublishing.com/
https://www.unlimitedbooksph.com/

If you like my video tutorials kindly click the like button and subscribe for more video tutorials on my channel.


Thank you very much for your help and support.
 
 
 
 
Sample Program Output
 

Program Listing

buck.java

// buck.java
// Author  : Mr. Jake Rodriguez Pomperada,MAED - Instructional Techonology
// Tool    : Java
// Date    : March 18, 2009 Tuesday 1:45 PM
// Email   : jakerpomperada@yahoo.com
// Tel. No.: +63 034 4335081
// Program Description:
// Bucket Sort Program in Java Implementation


import java.io.*;

class buck    {

    static void printArray(int[] b)
        {
        for (int i = 1; i < b.length; i++) System.out.print(" " + b[i]);
        System.out.print("\n");
      }


// Bucket Sort Sorting Code

       public static void bucketSort(int entry[],int m){
                int[] buckets = new int[m];

                for(int j=0;j<m;j++)
            buckets[j]=0;
                for(int i=0;i<entry.length;i++)
                        ++buckets[entry[i]];
                for(int i=0,j=0;j<m;++j)
            for(int k=buckets[j];k>0;k--)
                                entry[i++]=j;
    }

  // End of Method

  public static void main (String args []) throws IOException    
       {
       String get_value;
        int n_value=0;
  
    String strEntry;
        int i=0;

        int entry[] = new int[6];
        BufferedReader dataIn= new BufferedReader(new InputStreamReader(System.in));
        System.out.println();
        System.out.print("\t============================================\n");
        System.out.print("\t========   Bucket Sort Version 1.0  ========\n");
        System.out.print("\t===== By: Mr. Jake Rodriguez Pomperada =====\n");
        System.out.print("\t============================================\n");
       

        System.out.println();

   
        for( i =1 ; i < entry.length; i++)
            {
            System.out.print("Enter number No. " + i +" : ");
            strEntry = dataIn.readLine();
            entry[i] = Integer.parseInt(strEntry);
        }
        System.out.println();
        System.out.println("== Original numbers ==>");
        printArray(entry);
     
          bucketSort(entry,50000);
        System.out.println("\n");
        System.out.println("== Sorted numbers ==>");
        printArray(entry);
        System.out.println("\n");
        System.out.print("\t====================================================\n");
        System.out.print("\t=== Created By: Jake Rodriguez Pomperada,MAED-IT ===\n");
        System.out.print("\t====================================================\n");
    }

} // End of Code


No comments:

Post a Comment