Question: 15. Write a recursive void function called rotateLeft() with two parameters, an array and an integer count n, that rotates the first n integers in

15. Write a recursive void function called rotateLeft() with two parameters, an array and an integer count n, that rotates the first n integers in the array to the left. To rotate n items left, rotate the first n – 1 items left recursively, and then exchange the last two items. For example, to rotate the five items 50 60 70 80 90 to the left, recursively rotate the first four items to the left:

60 70 80 50 90 and then exchange the last two items:

60 70 80 90 50 Test it with a main program that takes as input an integer count followed by the values to rotate. Output the original values and the rotated values. Do not use a loop in rotateLeft().

Output the value in the main program, not in the procedure.

Sample Input 5 50 60 70 80 90 Sample Output Original list: 50 60 70 80 90 Rotated list: 60 70 80 90 50

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Principles Algorithms And Systems Questions!