Five everyday examples
Five common real-life examples of algorithms are map route planning, ranking search results, sorting lists, encryption on secure connections and scheduling on a computer’s processor. Each one is a set of steps that turns a problem into a result. The simplest algorithm many people use without thinking is checking items in a list one at a time, which is brute force.
Linear search: the simplest algorithm
Checking items in a list one at a time until you find the one you want is one of the simplest algorithms there is. It is brute force, because it checks each candidate in turn. Many everyday tasks rely on the same idea, and the examples below go a step further into the systems people use daily.
Route planning in map apps
When you ask a map app for directions, it searches a network of roads and intersections for a short or fast route. Many route planners use variants of Dijkstra’s algorithm, a shortest-path method that works through the network and tracks the best distance found to each point. Real systems also use traffic data and other techniques, so the app you use is more than one algorithm. Readers who want to see how shortest-path methods compare can look at dijkstra algorithm vs bellman ford.
Ranking search results
A search engine has to decide which pages to show first. It uses ranking algorithms that score each page against many signals, then sorts the results by that score. The exact methods are proprietary and change over time, but the basic pattern of scoring and sorting is what makes the results appear in an order.
Sorting lists
Sorting a list of contacts, files, or scores is one of the most common uses of algorithms. Sorting methods differ in speed and in how much extra memory they need. The heapsort algorithm, for example, sorts a list of n items in roughly n log n steps. Simpler methods can be fine for short lists and slow for long ones.
Encryption on secure connections
When you log in to a bank or shop online, the connection is usually encrypted. Encryption algorithms such as AES scramble the data so that someone watching the traffic cannot read it. Encryption also relies on key exchange methods, so the two sides can agree on a secret key without sending it openly.
Scheduling on a computer’s processor
A computer runs many programs at once, but a processor can only run one task at a time on each core. The operating system decides which task gets the processor next, and CPU scheduling algorithms make that choice. Round robin gives each task a short turn in order. Priority scheduling runs the most important waiting task first. Different systems choose different methods depending on what they need to do well.
What these examples have in common
Each example takes a problem with many possible answers or orders and applies a set of steps to reach a useful result. Some are simple, like linear search. Others are far more involved. Learning the basic patterns helps when you meet a new algorithm, because most of them are built from the same kinds of steps.