2.2: Unit Summary
-
- Last updated
- Save as PDF
- Harrison Njoroge
- African Virtual University
In this unit, recursion was introduced. You should now be in a position to describe recursion and where it can be applied. The laws that a recursing algorithm must obey were also introduced as well as condition necessary for a process to be said to have recursed. Examples accompanied these explanations were provided where necessary.
Unit Assessment
Check your understanding!
Class Exercise
Instructions
Answer the following questions on recursion.
- Write an algorithm for finding the k-th even natural number
- Explain how a recursive algorithm works
- Feedback
-
-
The solution
Algorithm:
if k = 1, then return 0; else return Even(k - 1) + 2
- The result of one recursion is the input for the next recursion. The repletion is in the self-similar fashion. The algorithm calls itself with smaller input values and obtains the results by simply performing the operations on these smaller values. Generation of factorial, Fibonacci number series are the examples of recursive algorithms
-
The solution
Grading Scheme
The marks will be awarded as shown below:
|
Question |
Scores (marks) |
|---|---|
|
1 |
2 |
|
2 |
Each line of explanation 2 marks; maximum 8 |
|
Total |
10 |
Unit Readings and Other Resources
The readings in this unit are to be found at course level readings and other resources.