public void TestArrayRotation() { int[] arr = { 1, 2, 3, 4, 5, 6, 7 }; ArraysProblems ap = new ArraysProblems(); ap.Rotate(arr, 3); }
public void TestArrayReverseSubarray() { ArraysProblems ap = new ArraysProblems(); int[] arr = { 1, 2, 3, 4, 5, 6, 7 }; ap.ReverseSubArray(arr, 0, 4); Assert.IsTrue(arr[0] == 5); }
public void TestArrayReverse() { ArraysProblems ap = new ArraysProblems(); int[] arr = { 1, 2, 3, 4, 5, 6, 7 }; ap.Reverse(arr); Assert.IsTrue(arr[0] == 7); }
public void TestQuickSelect() { ArraysProblems ap = new ArraysProblems(); int[] arr = { 7, 3, 1, 4, 2, 9 }; var j = ap.QuickSelect(arr, 3); Assert.IsTrue(j == 3, "Third smallest is 3"); Assert.IsTrue(ap.QuickSelect(arr, 5) == 7, "5th smallest is 7"); }
public void TestArrayRotateOptimal() { ArraysProblems ap = new ArraysProblems(); int[] arr = { 1, 2, 3, 4, 5, 6, 7 }; ap.Rotate_Optimal(arr, 3); Assert.IsTrue(arr[0] == 5); arr = new int[] { 1, 2, 3, 4, 5, 6, 7 }; ap.Rotate_Optimal(arr, 4); Assert.IsTrue(arr[0] == 4); arr = new int[] { 1, 2, 3, 4, 5, 6, 7 }; ap.Rotate_Optimal(arr, 7); Assert.IsTrue(arr[0] == 1); arr = new int[] { 1, 2, 3, 4, 5, 6, 7 }; ap.Rotate_Optimal(arr, 8); Assert.IsTrue(arr[0] == 7); }