adding code for array rotation and reversal