public void TestShuffle_InArrayOf_7x2() { var a = BuildArray(7); RearrangeArray.ShuffleHalves(a); ValidateArray(a); }
public void TestSwap_1_InArrayOf_12() { var a = new int[] { 0, 1, 2, 3, 4, 5, 100, 101, 102, 103, 104, 105 }; RearrangeArray.Swap(1, a); Assert.AreEqual(1, a[2]); // all is sorted }
public void TestSwap_1_InArrayOf_10() { var a = new int[] { 0, 1, 2, 3, 4, 100, 101, 102, 103, 104 }; RearrangeArray.Swap(1, a); Assert.AreEqual(1, a[2]); // next unarranged index - 3 }
public void TestShuffle() { for (var i = 4; i < 100; i++) { var a = BuildArray(i); RearrangeArray.ShuffleHalves(a); ValidateArray(a); } }
public void TestSwap_1_InArrayOf_18() { var a = new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 100, 101, 102, 103, 104, 105, 106, 107, 108 }; RearrangeArray.Swap(1, a); RearrangeArray.Swap(3, a); Assert.AreEqual(1, a[2]); }
static void Main(string[] args) { //Rotation int[] input = { 16, 17, 4, 3, 5, 2 }; int[] index = { 3, 0, 1, 4, 6, 7, 8, 2, 5 }; Console.WriteLine("Input Array is - "); for (int i = 0; i < input.Length; i++) { Console.Write(input[i] + " "); } //Console.WriteLine("Input Index is - "); //for (int i = 0; i < index.Length; i++) //{ // Console.Write(index[i] + " "); //} Console.WriteLine(); //BasicRotation BR = new BasicRotation(); ////int[] Res = BR.RotateArray(input, 2); //int[] Res = BR.RotateArrayOneByOne(input, 2); // int[] Res = BR.RotateGCDArray(input, 7); // int[] Res = BR.RotateByReverse(input, 7); //BR.PrintRotations(input, 3); //Console.WriteLine(); //BR.PrintRotations(input, 5); //Console.WriteLine(); //BR.PrintRotations(input, 7); //int rotations = BR.RotationWithMaxHammingDist(input); //Console.WriteLine("Max Hamming distance Rotations : " + rotations); // BR.PrintSum(input); //Console.WriteLine(BR.ReturnPosition(input, 6)); // SortedRotatedArray SR = new SortedRotatedArray(); //int pos = SR.SearchSortedRotated(input, 12); // int pos = SR.FindSumPairSortedRotated(input, 15); // int pos = SR.maxSum(input); //Console.WriteLine(pos); //TestRotation TR = new TestRotation(); //int pos = TR.ReturnRotation(input); //Console.WriteLine("Rotation Count " + pos); RearrangeArray Obj = new RearrangeArray(); //int[] Res = Obj.ReArrangeArray(input); //int[] Res = Obj.ArrangedArray(input); //int[] Res = Obj.ReArrangeArrayPositiveNegative(input); //int[] Res = Obj.ArrangeNumbersWithoutSorting(input); //int[] Res = Obj.PrintZeroEnd(input); //int[] Res = Obj.PrintZeroRotationEnd(input); //int[] Res = Obj.ShiftAndDoubleArray(input); //int[] Res = Obj.ReturnInputArray(input, index); //Console.WriteLine( Obj.PrintLargeNumber(input)); //int[] Res = Obj.ReArrangeIndex(input); //int[] Res = Obj.RearrangePosNegArray(input); //int[] Res = Obj.ArrangeMultiples(input); //int[] Res = Obj.ShuffleArray(input); int[] Res = Obj.ReturnReplaceArray(input); Console.WriteLine("Output Array is - "); for (int i = 0; i < Res.Length; i++) { Console.Write(Res[i] + " "); } //int k = 5; //Console.WriteLine($"For k = {k} , Number Of Swaps required is : {Obj.ReturnSwapsForGroup(input, k)}"); //Obj.SequenceSortedArrayThree(input); //Console.WriteLine(Obj.SubArrayLength(input)); //Obj.MaxProdSubArray(input); Console.ReadLine(); }