October 2023
Beginner to intermediate
215 pages
4h 3m
English
This chapter introduces you to recursion through various Python code samples. Recursion is indispensable when working with algorithms that solve tasks involving trees and graphs, both of which are beyond the scope of this book. Recursive algorithms exist even for a simple data structures, such as an array of sorted elements; binary search is such an algorithm.
The first part of this chapter shows you how to calculate arithmetic series and geometric series using iterative algorithms, as well as recursive algorithms. These examples provide a gentler introduction to recursion if you are new to this topic (experienced users will move more quickly through these code samples). Next, you will learn about calculating ...
Read now
Unlock full access