2.2: Unit Summary
- Page ID
- 47385
\( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \) \( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)\(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\) \(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\)\(\newcommand{\AA}{\unicode[.8,0]{x212B}}\)
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.
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.