Stacks, queues and recursion Flashcards

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

What is a recursively defined procedure?

A

A procedure that defined in terms of itself

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

What is the role of the stack when a recursively defined procedure is executed?

A

To store local variables, parameters and and return addresses

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

What is an advantage of storing a tree in an array rather than linked nodes?

A

faster access// no memory wasted for pointers

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

Give one disadvantage of storing a tree in an array

A

Fixed size// cannot allocate memory dynamically// memory wasted if the array isn’t full

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

What is meant by a recursive subroutine?

A

A subroutine that calls itself

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

Why is the stack necessary to execute procedure X recursively?

A

The current state of the machine is pushed onto the stack when the procedure is called. This can be restored when the procedure is finished by popping the stack

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

Why is a queue a suitable date structure in some cases?

A

It is a first in first out

It is a last in last out

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

Advantages of dynamic data structures

A

No wasted memory, No limit on number of items that can be added, resources allocated when needed

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

Disadvantages of dynamic data structures

A

Additional memory needed for pointers, Memory leak, longer to access items directly

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