Now test yourself Flashcards
Explain what data structure should be used in a breadth first search: (2)
A queue as each newly discovered node is added to the rear of the queue and queues are discovered in the order they are found.
State one potential use for a breadth first search: (1)
shorted path through an unweighted graph
Explain what data structure should be used in a depth first search: (2)
A stack as each newly discovered node is inspected immediately and the route can be stepped through in reverse (popped) to find a new path.
State one potentially use for a Depth first search (1)
Navigating a maze
Which tree traversal algorithm will print the value of the root node as the last line? (1)
Post order traversal
which tree traversal algorithm would be most suitable for copying a tree? (1)
Pre order traversal
Describe two possible uses for post order traversal: (2)
Emptying a tree
Converting from infix to post fix notation (RPN)
Which tree traversal algorithm can be used to output a list in ascending order? (1)
In order traversal
What type of algorithm is a binary search algorithm? (1)
an example of a divide and conquer algorithm
Give one disadvantage of using linear search (1)
inefficient for large lists
Give two situations where linear search would be an appropriate choice (2)
If a list is unordered or if the list is small
Suggest one advantage of using binary search over linear search (1)
Binary search is much quicker than linear search for large sorted lists
State one Disadvantage of using a instead of Linear search (1)
List must be sorted for a binary search
Why is a binary search more efficient than a linear search? (2)
The list of possible values is halved each time.
State the number of comparisons needed to run through one pass of the bubble sort for a lost of 10 items:
10