2: Recursion
- Page ID
- 46790
\( \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}}\)
Upon completion of this unit the learner should be able to:
- develop algorithms for recursive programs
- implement recursive formulation of a problem
- explain recursion as a form of iteration
Unit Introduction
This unit introduces the learner to the processes that repeat themselfs in a self-similar way. The processes can either call themselves directly or indirectly during their execution. The unit will enable the learner to understand the recursion process and solve problems that are recursive in nature.
- Recursion: a process whereby a method calls itself so as to achieve repetitious
- Base case: a boolean test at which the recursion ceases to “wind up” and starts to “unwind”
- Recursive step: a method call which causes the recursion to “repeat” on each successive iteration (unless the base case is reached)
Learning Activities
- 2.1: Activity 1 - Recursive Algorithm
- The learners are introduced to recursive processes and learn how a method calls itself in order to achieve repetitious behaviour. By using recursive algorithms, the learners will be in a position to solve problems of this nature.
- 2.2: Unit Summary
- 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.