Exam Flashcards
State three advantages of using subroutines.
For each advantage, you must explain how the advantage is achieved.
-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
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.
When an item is removed from a linear queue, all items need to be moved up.()()
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
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.
Describe the Halting problem
Using a program to determine whether a program will halt.
Explain the importance of the Halting problem
It proves that there are some problems for which there is no algorithm to solve them
State the other two properties of this graph that make it a tree.
Connected;
Undirected;
Binary Tree
each node has, at most, one child node
One root node
Stack
LIFO
Queue
FIFO
Explain what is meant by concatenation.
Joining two strings into one string