We have an array. we like to use stack library that Sami wrote to reverse the order
Fantastic news! We've Found the answer you've been seeking!
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[] 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
Related Book For
Introduction to Algorithms
ISBN: 978-0262033848
3rd edition
Authors: Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest
Posted Date: