So I have done a Bucket Sort algorithm that works just fine, but now I'm being asked to do it recursively. The Bucket Sort itself is something along the lines of:
public static void bucketSort(int[] arr, int max) {
int[] bucket = new int[max + 1];
for (int i = 0; i < arr.length; i++) {
bucket[arr[i]]++;
}
int x = 0;
for (int i = 0; i < bucket.length; i++) {
for (int j = 0; j < bucket[i]; j++) {
arr[x++] = i;
}
}
}
So my question would be, how to make this same algorithm but recursively? Note: I'm coding in Java using IntelliJ, but feel free to explain in other languages if you prefer it. Thanks in advance!