Data Structures & Algorithms Flashcards
1
Q
How would you examine items below the top of a stack?
A
use stack.pop( ) to remove the top element from a stack
2
Q
How would you find out how many items are in a stack?
A
Use a counter, add one to the counter while stack.peek( ) !== undefined
3
Q
What happens to the order of values that are moved from one stack to another?
A
The order of the values is reversed.
4
Q
How can a stack be returned to it’s original state after examining its internal values?
A
By pushing the values of the inverted stack back onto the original stack