Data Structures: Stacks Flashcards

1
Q

What are stacks?

A

A stack consists of a sequence of items, which should be thought of as piled one on top of the other like a physical stack of boxes or cafeteria trays.

The rule: Insertion and deletion only occurs at the top. Only the top item on the stack is accessible at any given time.

Stacks are L.I.F.O structures

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

What does L.I.F.O stand for?

A

L.I.F.O

Last in first out.

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

Stack opperations

A

Push -adding an element to the stack

Pop -removing an element from the stack

peek -looking at the element at the top of a stack (pointer)

IsEmpty -Checks if stack is empty

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

Run time analysis

A

O(1)

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

Common uses of stacks

A

Function calls/Recursion
Undo opperations
Balanced parantheses checks
To reverse an order.

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

Two ways to implement a stack?

A

Array or linked list

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

What is the pointer in a stack called?

A

Top

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