I want to addtiming execution in java code but I don't know how? Here is the code of Bucket sort
import java.util.*;
public class BucketSort{
public static void sort(int[] a, int maxVal) {
int [] bucket=new int[maxVal+1];
for (int i=0; i<bucket.length; i++) {
bucket[i]=0;
}
for (int i=0; i<a.length; i++) {
bucket[a[i]]++;
}
int outPos=0;
for (int i=0; i<bucket.length; i++) {
for (int j=0; j<bucket[i]; j++) {
a[outPos++]=i;
}
}
}
public static void main(String[] args) {
int maxVal=100000;
int [] data= {1000, 10000, 15000, 25000, 30000, 45000, 50000, 60000, 75000, 90000, 100000};
System.out.println("Array: " + Arrays.toString(data));
sort(data,maxVal);
System.out.println("Sorted array Bucket Sort: " + Arrays.toString(data));
}
}