public static void demoSortingInput() { StringArray myArray = new StringArray(); string name; Console.Write("Enter a name ('quit' to stop': "); name = Console.ReadLine(); while (name != "quit") { myArray.add(name); Console.Write("Enter a name ('quit' to stop': "); name = Console.ReadLine(); } myArray.BubbleSort(); myArray.PrintArray(); }
public static void demoStringSort() { string cat; int ndx; StringArray myArray = new StringArray(); myArray.add("Tegan"); myArray.add("Alystra"); myArray.add("Brandon"); myArray.add("Oliver"); myArray.add("Casey"); myArray.add("Midnight"); myArray.add("Jeremiah"); myArray.add("Maya"); myArray.BubbleSort(); myArray.PrintArray(); cat = "Midnight"; ndx = myArray.findString(cat); Console.WriteLine("{0} found at index: {1}", cat, ndx); }
public static void demoStringSort() { string cat; int ndx; StringArray myArray = new StringArray(); myArray.add("Tegan"); myArray.add("Alystra"); myArray.add("Brandon"); myArray.add("Oliver"); myArray.add("Casey"); myArray.add("Midnight"); myArray.add("Jeremiah"); myArray.add("Maya"); myArray.BubbleSort(); myArray.PrintArray(); cat = "Midnight"; ndx = myArray.binarySearch(cat); string name = "Branford"; int insertionPoint = myArray.binarySearch(name); Console.WriteLine("Should insert {0} at {1}", name, insertionPoint); Console.WriteLine("{0} found at index: {1}", cat, ndx); }