public override void Run() { int[] array = AssortedMethods.RandomArray(10, -10, 10); Console.WriteLine(AssortedMethods.ArrayToString(array)); SwapMinMaxBetter(array); Console.WriteLine(AssortedMethods.ArrayToString(array)); }
public override void Run() { int size = 100; int[] list = AssortedMethods.RandomArray(size, -100, 100); for (int i = 0; i < list.Length; i++) { Track(list[i]); } int[] tracker = new int[size]; for (int i = 0; i < list.Length; i++) { int v = list[i]; int rank1 = root.GetRank(list[i]); tracker[rank1] = v; } for (int i = 0; i < tracker.Length - 1; i++) { if (tracker[i] != 0 && tracker[i + 1] != 0) { if (tracker[i] > tracker[i + 1]) { Console.WriteLine("ERROR at " + i); } } } Console.WriteLine("Array: " + AssortedMethods.ArrayToString(list)); Console.WriteLine("Ranks: " + AssortedMethods.ArrayToString(tracker)); }
public void Test() { const int size = 5; int[] list = AssortedMethods.RandomArray(size, -5, 5); foreach (int t in list) { Track(t); } var tracker = new int[size]; foreach (int t in list) { int v = t; int rank1 = _root.GetRank(t); tracker[rank1] = v; } for (int i = 1; i < tracker.Length; i++) { if (tracker[i] == 0 || tracker[i - 1] == 0) { continue; } if (tracker[i] > tracker[i - 1]) { Console.WriteLine("ERROR at " + i); } } Console.WriteLine("Array: " + AssortedMethods.ArrayToString(list)); Console.WriteLine("Ranks: " + AssortedMethods.ArrayToString(tracker)); }
public void Run() { int[] array = AssortedMethods.RandomArray(30, 1, 30); Console.WriteLine(AssortedMethods.ArrayToString(array)); checkDuplicates(array); }