On completion of this unit the student should be able to establish the efficiency of simple algorithms and explain soft limits of computability.
Detailed example
Investigating methods for solving recurrence relations
Students are required to be able to fluently solve recurrence relations by applying the Master Theorem. One way in which students could be supported to develop a deep understanding of the Master Theorem is by exploring how the three different cases in the Master Theorem arise. This can also assist students to improve their understanding of recurrence relations in general.
Consider a divide and conquer algorithm for finding the lowest item in a list of length n. It divides the list into two halves, finds the minimum of each half and then calculates the global minimum. The recurrence relation for this algorithm is shown below.
Consider also the mergesort algorithm. Its recurrence relation is shown below.
A third recurrence relation could also be considered.
The time complexity of algorithms with these algorithms can be investigated in a range of ways. One method is to draw their call tree and observe the running time in each call of the algorithm. For example:
Figure 3
It can be seen that for the first recurrence relation, the sum of each level of the call tree increases as the execution goes deeper into the call tree. It can also be observed that each level of the call tree is more than the sum of all previous levels. It can be concluded that for this type of algorithm, most of the work is being done in the leaves of the call tree.
The depth of the call tree is (n).
The sum of the rows is
A question that could lead students in their investigation is:
Under what conditions is most of the work done in the leaves of the call tree? When is most of the work done in the root of the tree? When is the work spread evenly at each depth of the tree?
Another method that students can use to analyse recurrence relations is repeated substitution. To do this, the recurrence relation is repeatedly substituted into itself until a recognisable pattern is noticed. For example:
At this point, the pattern 1 + 2 + 4 + 8 + … might be observed. Students who have studied sequences and series in mathematics will be able to apply those skills here.