announcements‎ > ‎

2015-11-13 HW16

posted Nov 14, 2015, 5:50 PM by Samuel Konstantinovich   [ updated Nov 14, 2015, 5:51 PM ]

HW 16.

~/apcs/hw16/Sorts.java

 

public class Sorts{
   public static void printArray(int[]data){
      //print the array like:  [ 1, 2, 3, 4]
   }
   public static void insertionSort(int[]data){
      //your code here to make data re-order its elements
      //from least to greatest just like we did in class
      //same algorithm as the way you created your OrderedSuperArray
   }
}

A separate driver can just say:

 

int[] arrayName = { 8, 6, 7, 5, 3, 0, 9};
Sorts.printArray( arrayName);
Sorts.insertionSort( arrayName);
Sorts.printArray( arrayName);

You should test it on MANY other test cases.

Comments