recursion

a function that calls itself!
bunnies

We can calulate the number of ears that a certain number of bunnies have recursively.

This video will attempt to explain the concept of recursion using the classic bunny ears scenario.

Task - Coding

Using a high-level programming language of your choice, code the BunnyEars function and write a computer program to call the function and display the returned result.

Fun Fact

When the program compiles/runs, the data related to each recursive call is placed on a stack. This Last in, First out approach is perfect for handling recursive calls until a base case is reached and the series of calls unwinds.


Exercises


Tags

stack queue circular enqueue dequeue fifo empty full