Table of Contents
Suppose you have to design a brand-new algorithm to do something never done before. You could start from scratch, given the problem statement and a programming language textbook, and you might come up with something useful.
But certain distinctive styles of algorithms have arisen over the years, and being familiar with these may give you an edge in coming up with a well-designed algorithm for a new task.
We've actually seen a number of these already, but it's time to put some names to them and take stock of what we've got:
A first question we might ask about any algorithm is how it manages to process multiple “pieces” of data:
Iterative: algorithms that work by looping
Recursive: algorithms that call themselves (directly or indirectly)
Among both iterative and recursive algorithms, we recognize some algorithms by an underlying “idea” of how they work:
Divide and conquer
Generate and test
Now let's look at some common forms of both iterative and recursive algorithms.