# 2: Recursion

• • Harrison Njoroge
• African Virtual University
$$\newcommand{\vecs}{\overset { \rightharpoonup} {\mathbf{#1}} }$$ $$\newcommand{\vecd}{\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 \|}$$ $$\newcommand{\inner}{\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 \|}$$ $$\newcommand{\inner}{\langle #1, #2 \rangle}$$ $$\newcommand{\Span}{\mathrm{span}}$$$$\newcommand{\AA}{\unicode[.8,0]{x212B}}$$

## 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.

Unit Objectives

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

## Key Terms

• Recursion: This is a process whereby a method calls itself so as to achieve repetitious
• Base case: Is a boolean test at which the recursion ceases to “wind up” and starts to “unwind”.
• Recursive step: Is 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

This page titled 2: Recursion is shared under a CC BY-SA license and was authored, remixed, and/or curated by Harrison Njoroge (African Virtual University) .