Stacks Flashcards

(7 cards)

1
Q

What is data abstraction?

A

Isolates how a compound data object is used from the details of how it’s constructed.

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

What is a stack?

A

They are defined as last in first out data structures.

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

What does push do?

A

Adds elements to the top of the stack.

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

What does peek do?

A

Returns the top item in a stack.

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

What does pop do?

A

Deletes the top item in a stack.

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

What are the steps involved in pushing an item onto a stack?

A

First check if the stack is full. If so, report a stack overflow. If not, increase the stack pointer by one. Insert the item at the memory location indicated by the front pointer.

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

What are the steps involved in popping an item off a stack?

A

First check if the stack is empty. If so, then report a stack underflow. If not, then delete the top item of the stack and decrease the stack pointer by one.

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