Question: We have an array. we like to use stack library that Sami wrote to reverse the order of it. Propose a method called myRevArray (int[]
We have an array. we like to use stack library that Sami wrote to reverse the order of it. Propose a method called myRevArray(int[] arr) that would inverse the order of the array with the use of stack
- you may use the stack library exits and use push and pop from it
- No a new array as it would be memory wasting
- Better to have your code in O(n) where n is the size of array [HINT: O(2n) is till O(n)]
- The method has no return but we use pass by reference to change arrĀ value (no need for anything but by changing the order of arrĀ it automatically will be reverse
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
