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

  1. you may use the stack library exits and use push and pop from it
  2. No a new array as it would be memory wasting
  3. Better to have your code in O(n) where n is the size of array [HINT: O(2n) is till O(n)]
  4. 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

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 Programming Questions!