data-structures-stacks Flashcards

1
Q

What does the acronym LIFO mean?

A

last in first 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

push, pop, print, peek

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

continuously pop until you reach that point in the stack

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

Are braces balanced (interview question: algo challenge)
- take a string containing brackets, braces, parentheses,
- return boolean to say if the string’s braces are balanced

  • balanced example: {[[()]]}
  • unbalanced example: [{)]
A

solution
- for each char, check if opening brace
- if yes, push it on to stack
- if closing brace,
- if the stack’s top is matching opening brace, pop it
- if the stack’s top is not matching return false

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