appendix E. Recursion
If you are reading this book, you are probably already familiar with loops. As discussed in appendix A, for, while, and do-while loops (and some more, depending on the language) all are examples of iteration.
Iterative loops are one straightforward way to repeatedly perform similar actions on a series of elements. Usually loops go hand in hand with certain data structures, for example, containers like lists and arrays.
Loops tend to work well when the data structure has a linear shape; sometimes, though, things are more complicated and a simple loop might not be enough to immediately solve the issue. We will see, for example, how trees and graphs are more challenging than lists. There are workarounds to use loops with ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access