What Is an Algorithm?
Steps to solve a problem.
An algorithm is a list of steps that solves a problem. A recipe is an algorithm. So are the directions to a friend's house. In programming, an algorithm is the steps your code follows, to turn an input into an answer.

- Steps that solve a problem
- A recipe, directions
- Input in, answer out
Finding the biggest number
Here's a tiny algorithm. Find the biggest number in a list. We start by assuming the first number is the biggest. Then we look at each number in turn. If it's bigger than our best so far, it becomes the new best. Run it. Nine is the biggest.
def biggest(numbers):
best = numbers[0]
for n in numbers:
if n > best:
best = n
return best
print(biggest([4, 9, 2, 7]))9
Good algorithms
There's usually more than one way to solve a problem. A good algorithm gives the right answer every time, including for strange inputs, like an empty list. It finishes in a reasonable time, even for huge inputs. And it doesn't waste memory. This course is about choosing well.
Summary
An algorithm is a list of steps that turns an input into an answer. Good ones are correct, fast, and lean. Next, why this matters so much.
Key takeaways- Steps to solve a problem
- Correct, fast, lean
- Many ways to solve one problem