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 ...
Get Advanced Algorithms and Data Structures now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.