Exam Flashcards

1
Q

State three advantages of using subroutines.
For each advantage, you must explain how the advantage is achieved.

A

-Easier to test/debug as each subroutine can be tested separately
-Allows the use of recursive techniques because subroutines can call themselves
-Code can be easily reused as each subroutine is independent of rest of program

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

Explain why, when implemented using a fixed-length array, a circular queue is usually considered to be a better choice of data structure than a linear queue.

A

When an item is removed from a linear queue, all items need to be moved up.()()

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

Describe the steps that must be completed to remove (dequeue) an item from a circular queue that has been implemented using a fixed-length array

A

Check to see if stack is not empty, if it is return an error. Otherwise, remove the item at the rear pointer. Decrement the rear pointer by 1. Check if the front is in the last position of the array and if it is set it to the first position in the array. Else, increment the front pointer by 1.

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

Describe the Halting problem

A

Using a program to determine whether a program will halt.

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

Explain the importance of the Halting problem

A

It proves that there are some problems for which there is no algorithm to solve them

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

State the other two properties of this graph that make it a tree.

A

Connected;
Undirected;

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

Binary Tree

A

each node has, at most, one child node
One root node

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

Stack

A

LIFO

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

Queue

A

FIFO

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

Explain what is meant by concatenation.

A

Joining two strings into one string

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