In java programming language use the operations push, pop, peek, and empty to write operations that do
Question:
In java programming language use the operations push, pop, peek, and empty to write operations that do each of the following:
1. set i to the second element from the top of the stack; leaving the stack without its top two elements.
2. set i to the second element from the top of the stack; leaving the stack unchanged.
3. Given an integer n, set i to the nth element from the top of the stack; leaving stack without its top n elements.
4. Given an integer n, set i to the nth element from the top of the stack; leaving stack unchanged.
5. Set i to the bottom element of the stack; leaving the stack empty.
6. Set i to the bottom element of the stack; leaving the stack unchanged (Hint: use another, auxiliary stack)
7. Set i to third element from the bottom of the stack.
Cost management a strategic approach
ISBN: 978-0073526942
5th edition
Authors: Edward J. Blocher, David E. Stout, Gary Cokins