public override void Run() { int[] a = new int[] { 2, 3, 4, 5, 6, 8, 10, 100, 0, 0, 0, 0, 0, 0 }; int[] b = new int[] { 1, 4, 7, 6, 7, 7 }; Merge(a, b, 8, 6); Console.WriteLine(AssortedMethods.ArrayToString(a)); }
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 Run() { Push(0, 10); Push(1, 20); Push(2, 30); Push(1, 21); Push(0, 11); Push(0, 12); Pop(0); Push(2, 31); Push(0, 13); Push(1, 22); Push(2, 31); Push(2, 32); Push(2, 33); Push(2, 34); Console.WriteLine("Final Stack: " + AssortedMethods.ArrayToString(_buffer)); Pop(1); Push(2, 35); Console.WriteLine("Final Stack: " + AssortedMethods.ArrayToString(_buffer)); }
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 = { 48, 40, 31, 62, 28, 21, 64, 40, 23, 17 }; Console.WriteLine(AssortedMethods.ArrayToString(array)); SortValleyPeak(array); Console.WriteLine(AssortedMethods.ArrayToString(array)); int[] array2 = { 48, 40, 31, 62, 28, 21, 64, 40, 23, 17 }; Console.WriteLine(AssortedMethods.ArrayToString(array2)); SortValleyPeak2(array2); Console.WriteLine(AssortedMethods.ArrayToString(array2)); int[] array3 = { 48, 40, 31, 62, 28, 21, 64, 40, 23, 17 }; Console.WriteLine(AssortedMethods.ArrayToString(array3)); SortValleyPeak3(array3); Console.WriteLine(AssortedMethods.ArrayToString(array3)); }
public void Run() { Console.WriteLine("IsEmpty stack 0? {0}", IsEmpty(0)); Push(0, 10); Push(1, 20); Push(2, 30); Push(1, 21); Push(0, 11); Push(0, 12); var popped = Pop(0); Console.WriteLine("popped: {0}", popped); Console.WriteLine(); Push(2, 31); Push(0, 13); Push(1, 22); Push(2, 31); Push(2, 32); Push(2, 33); Push(2, 34); Console.WriteLine("Final Stack: " + AssortedMethods.ArrayToString(_buffer)); popped = Pop(1); Console.WriteLine("popped: {0}", popped); Console.WriteLine(); Push(2, 35); Console.WriteLine("IsEmpty stack 0? {0}", IsEmpty(0)); Console.WriteLine("What's on top of stack 0? {0}", Peek(0)); Console.WriteLine("Final Stack: " + AssortedMethods.ArrayToString(_buffer)); }
public void Run() { int[] array = AssortedMethods.RandomArray(30, 1, 30); Console.WriteLine(AssortedMethods.ArrayToString(array)); checkDuplicates(array); }