Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class ShellSortTest {
- public static void main(String[] args) {
- Results r;
- int [] numbers = new int [16]; //create array of size n
- Random rand = new Random(1); //random seed
- for (int i = 0; i < 16; i++){
- numbers[i] = (10 + rand.nextInt(11)); // distribute random numbers into array
- }
- //System.out.println(Arrays.toString(numbers));//print array
- int [] test = {3,4,16,7,8,9,10,11,1,0,20,13,12,5,2,6,15};
- System.out.println(Arrays.toString(test));//print sorted array
- r = ShellSort.shellSort(test, 0); //sort array, pass array and integer to determine gap sequence formula
- //System.out.println(Arrays.toString(test));//print sorted array
- //print CopyCount and CompareCount values
- System.out.println("Number of times elements are copied: " + r.copies);
- System.out.println("Number of times elements are compared: " + r.comparisons);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement