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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
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

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

What is the time complexities of each operation?

A

O(n)

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

What is infix?

A

Operators are placed between operands

Ex: 2 + 6 x 3

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

What is postfix?

A

Operators are placed after operands

Ex: 2 6 3 x +

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

What is the code to convert infix to postfix?

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

What is the code to convert postfix to infix?

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

What is the code to evaluate postfix?

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

Stack practice: valid brackets

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