data-structures-stacks Flashcards
1
Q
What does the acronym LIFO mean?
A
LIFO stands for “last-in-first-out”. It means the last thing “push”ed onto the stack is the first thing that can be “pop”ped out.
2
Q
What methods are available on a Stack data structure?
A
- The “push(value)” method - adds a value to the “top” of the stack
- The “pop()” method - removes the top value from the stack and returns it
- The “peek()” method - returns the “top” value of the stack without removing it
3
Q
What must you do to access the value at an arbitrary point in a stack (not just the “top”)?
A
Use the “pop” method and store the popped value in a variable. Keep popping to get to the arbitrary point in the stack.