Advertisement
Guest User

Untitled

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