Stacks Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q

What is a stack?

A

an abstract data type which uses a concept of first in last out

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

What is it often used for ?

A

To undo actions in browsers and word editors

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

What types of stacks can there be?

A

Static and dynamic

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

What is necessary to get a stack to work?

A

pointer to the top of a stack and variable related to the size (amount of elements stored)

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

What does the push() do ?

A

Adds an item

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

What does a pop() do?

A

removes and returns the first item

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

peek()?

A

returns the top item but doesn’t remove it

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

isEmpty?

A

tests to see whether the stack is empty

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

isFull?

A

checks to see whether stack is full

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

What is the value of the pointer if a stack is empty?

A

-1

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

How can a stack cause overflow and underflow errors?

A

for example trying to pop() on an empty stack

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

What is a call stack?

A

A stack used to store information about active programs/subroutines (must be running)

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

What does a call stack store?

A

return addresses of subroutines (if nested then several return addresses are stored)
parameters
local variables

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

Why can memory run out with recursion?

A

As many addresses will need to be stored, consequently running out of memory

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

What is a call stack composed of?

A

A stack frame, this frame contains related information about a subroutine that is active

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