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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What methods are available on a Stack data structure?

A
  1. The “push(value)” method - adds a value to the “top” of the stack
  2. The “pop()” method - removes the top value from the stack and returns it
  3. The “peek()” method - returns the “top” value of the stack without removing it
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly