Write a recursive void function called rotate left that rotates the first n integers in an array
Question:
Write a recursive void function called rotate left that rotates the first n integers in an 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
The Architecture of Computer Hardware, Systems Software and Networking An Information Technology App
ISBN: 978-1118322635
5th edition
Authors: Irv Englander