A finite set of steps for performing a computation.
Finite in the sense of both the description and in that eventually the algorithm terminates. So not all programs are algorithms.
We typically use “algorithm” to describe parts of a program that have a particularly well-defined purpose.
Searching
Sorting
These are the two kinds the College Board wants you to know about.
Let’s find the algorithms.
These days we also often talk about “The Algorithm” to describe things like how TikTok decides what videos you’re most likely to watch.
Those are indeed algorithms but they are hugely complex and made up of many, many little-“a” algorithms.
We can talk about algorithms independently of how they are expressed in code.
Actual code “implements” an algorithm.
But there are characteristics of an algorithm that all implementations of that algorithm will share.
Also there can be different algorithms for achieving the same ends.
So we sometimes need to analyze algorithms to see how they compare.
Correctness
Time: how long does it take?
Space: how much memory does it need?
What is an algorithm to determine on what page, if any, the word “trellis” occurs in this book?
How about in this book?
Suppose I gave you a novel that was twice as long as Great Expectations, how much longer do you think it would take to find a random word in it?
Now suppose I gave you an unabridged dictionary that was twice as big as the original dictionary—how much longer would that take?
Since algorithms aren’t tied to a particular implementation it’s not that useful to talk about how long they take in terms of actual time.
Instead we talk about how their runtime grows as the size of the problem grows.
Finding a word in a bigger book is a bigger problem than finding it in a smaller book. If the book doubles, what does that do to how long the algorithm takes?