📜  桶排序java代码示例

📅  最后修改于: 2022-03-11 14:52:16.613000             🧑  作者: Mango

代码示例1
public class Main 
{
   public static int[] bucket_sort(int[] arr, int max_value) 
    {
        int[] bucket = new int[max_value + 1];
        int[] sorted_arr = new int[arr.length];
 
        for (int i= 0; i  max_value)
                max_value = arr[i];
        return max_value;
    }
 
    public static void main(String args[]) 
    {
        int[] arr ={80, 50, 30, 10, 90, 60, 0, 70, 40, 20, 50};
        int max_value = maxValue(arr);
 
        System.out.print("\nOriginal : ");
        System.out.println(Arrays.toString(arr));
 
        System.out.print("\nSorted : ");
        System.out.println(Arrays.toString(bucket_sort(arr,max_value)));

    }
}