Stacks Flashcards
1
Q
What is a stack?
A
A linear data structure were elements are inserted and removed in a last-in-first-out (LIFO) order.
2
Q
What one the stack operations?
A
> push - insert element at the top of stack
pop - remove element at top of stack
top - return the element at top of stack
empty - returns true if stack is empty, false otherwise
3
Q
What is the time complexities of each operation?
A
O(n)
4
Q
What is infix?
A
Operators are placed between operands
Ex: 2 + 6 x 3
5
Q
What is postfix?
A
Operators are placed after operands
Ex: 2 6 3 x +
6
Q
What is the code to convert infix to postfix?
A
7
Q
What is the code to convert postfix to infix?
A
8
Q
What is the code to evaluate postfix?
A
9
Q
Stack practice: valid brackets
A