Exemple #1
0
        public void RotateArrayUsingJugglingAlgorithm()
        {
            int[] arr    = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 };
            int[] result = ArrayRotations.RotateUsingJugglingAlgorithm(arr, arr.Length, 3);
            var   output = PrintArray(result);

            Assert.AreEqual("4 5 6 7 8 9 10 11 12 1 2 3", output);
        }
Exemple #2
0
        public void RotateArrayUsingReversalAlgorithm()
        {
            int[] arr    = { 1, 2, 3, 4, 5, 6, 7 };
            var   result = ArrayRotations.RotateUsingReversalAlgorithm(arr, arr.Length, 2);
            var   output = PrintArray(result);

            Assert.AreEqual("3 4 5 6 7 1 2", output);
        }
Exemple #3
0
        public void RotateArrayOneByOne()
        {
            int[] arr    = { 1, 2, 3, 4, 5, 6, 7 };
            int[] result = ArrayRotations.RotateOneByOne(arr, arr.Length, 2);
            var   output = PrintArray(result);

            Assert.AreEqual("3 4 5 6 7 1 2", output);
        }