Topic Two Assessment Past paper Questions Flashcards

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

Explain how a single stack can be used to reverse the order of the items in a queue.

A

(Until the queue is empty) repeatedly remove/delete (the front item) from the queue and push it onto the stack;
(Until the stack is empty) repeatedly pop items from the stack and add them to the (rear of the) queue;

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

Define the term binary tree.

A

Rooted (tree);
Where each node has at most two child nodes;

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

State two components of a stack frame.

A

local variables;
return address;
parameters;
register values;

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

Describe the steps involved in adding a record to a hash table.

A

Hash algorithm applied;
to key value; NE. to data/item
result is location in table where the record should be stored;
if location is not empty;
then use next free location;

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

Discuss the advantages and disadvantages of dynamic data structures compared to
static data structures

A

Max 2 for advantages of dynamic data structures
No wasted memory;
Can grow as more data is added to the data structure // no limit on number of
items that can be added (except due to hardware limitations);
Resources only allocated as they are needed (with static data structures they are
allocated at creation even if not needed until later);
Max 2 for disadvantages of dynamic data structures
Additional memory needed for pointers;
Can result in memory leak (if memory that is no longer needed is not returned to
the heap);

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

Describe the steps involved in adding an item to a linear queue that has been implemented as a static data structure using an array.

A

Check that the queue is not already full;
(if it isn’t) then add 1 to the value of the rear pointer;
then add the new item to the position indicated by the rear pointer

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q
A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q
A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q
A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q
A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q
A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q
A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q
A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q
A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q
A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q
A
10
Q
A
10
Q
A
11
Q
A
12
Q
A