Fibonacci Numbers—Recursive Approach
Explore the recursive approach to calculating Fibonacci numbers, understand its exponential time complexity, and learn how memoization enhances efficiency using dynamic programming techniques in C++.
We'll cover the following...
Origins of recursion
One of the earliest examples of recursion arose in India more than 2000 years ago, in the study of poetic meter, or prosody. Classical Sanskrit poetry distinguishes between two types of syllables (aksara): light (laghu) and heavy (guru). In one class of meters, variously called or , each line of poetry consists of a fixed number of “beats” (), where each light syllable lasts one beat, and each heavy syllable lasts two beats. The formal study of dates back to the , written by the scholar between 600BCE and 200BCE. observed that there are exactly five 4-beat meters: ——, — • •, • — •, • •—, and • • • •. (Here, each “—” represents a long syllable, and each “•” represents a short syllable.)
Although text hints at a systematic rule for counting meters with a given number of beats, it took about a millennium for that rule to be stated explicitly. In the 7th century CE, another Indian scholar named ...