Stack Flashcards

1
Q

What is a stack?

A

A linear data structure that operates on the principle of Last-In, First-Out (LIFO), meaning the most recently added element is the first one to be removed

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

What are the four key operations that you can perform on a stack?

A

Push (add), Pop (remove), Peek (see the top element), IsEmpty

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

What are some use cases of stacks?

A
  1. Web Browser History
  2. Undo Function
  3. Function Call Management
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is the time complexity of the push operation on a stack?

A

O(1)

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

What is the time complexity of the pop operation on a stack?

A

O(1)

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

What is the time complexity of the peek operation on a stack?

A

O(1)

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

What is the time complexity of the IsEmpty operation on a stack?

A

O(1)

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

What is the term for popping an element from an empty stack?

A

Stack Underflow

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

What is the term for pushing an element onto a stack that’s already full?

A

Stack Overflow

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