Step-by-Step Thinking
An algorithm is a set of step-by-step instructions for accomplishing a task. That is it. Despite the word's association with code and computers, algorithms are something you use every day — often without realizing it.
This chapter explores what algorithms are, how they appear in everyday life, and how the same step-by-step thinking applies to technology.
What Is an Algorithm?
An algorithm has four characteristics:
- It has a clear starting point. You know where to begin.
- It has defined steps. Each step is specific enough that someone (or something) can follow it without guessing.
- It has a clear ending point. You know when you are done.
- It produces a result. Following the steps leads to an outcome.
Notice that none of these require a computer. An algorithm is a way of thinking, not a piece of technology.
Everyday Algorithms
A Recipe
A recipe is one of the purest examples of an algorithm:
Scrambled Eggs Algorithm
1. Crack 3 eggs into a bowl
2. Add a pinch of salt
3. Beat with a fork until blended
4. Heat a pan over medium heat
5. Add a tablespoon of butter
6. Wait until butter melts and begins to foam
7. Pour in the egg mixture
8. Stir gently with a spatula every 15 seconds
9. When eggs are mostly set but still slightly wet, remove from heat
10. Serve immediately
This has a clear start (crack eggs), defined steps, a clear end (serve), and a result (scrambled eggs). Anyone who can follow these steps can make scrambled eggs, even if they have never cooked before.
Assembly Instructions
Furniture assembly instructions are algorithms:
Bookshelf Assembly
1. Lay side panel A flat on the floor
2. Insert 4 dowels into the pre-drilled holes
3. Attach shelf B to the dowels
4. Repeat for shelves C, D, and E
5. Attach side panel F
6. Stand the unit upright
7. Secure the back panel with 8 screws
The order matters. You cannot attach the back panel before the shelves are in place. This sequential dependency is a key feature of many algorithms.
A Morning Routine
Your morning routine is an algorithm you execute daily:
1. Alarm goes off
2. Get out of bed
3. Go to bathroom
4. Shower
5. Get dressed
6. Make coffee
7. Eat breakfast
8. Check calendar for the day
9. Leave the house
Some of these steps have flexibility in their order (you could make coffee before showering), while others have strict dependencies (you cannot get dressed before showering if you want to shower). Recognizing which steps depend on each other is a fundamental part of algorithm design.
The Building Blocks of Algorithms
Most algorithms, no matter how complex, are built from three basic structures:
Sequence
Steps that happen one after another in order.
1. Open the jar
2. Scoop out peanut butter
3. Spread on bread
Selection (Decisions)
Steps where you choose a path based on a condition.
1. Check the weather
2. If it is raining, take an umbrella
3. If it is not raining, wear sunglasses
Repetition (Loops)
Steps that repeat until a condition is met.
1. Pick up a dish from the pile
2. Wash the dish
3. Place it in the drying rack
4. If there are more dishes, go back to step 1
5. If the pile is empty, you are done
Every algorithm — from a recipe to a search engine — is some combination of these three structures.
Why Step-by-Step Thinking Matters
It forces clarity
When you write out steps explicitly, vagueness becomes visible. "Make the project better" is not an algorithm. "Identify the three slowest pages, measure their load times, and optimize the largest image on each page" is closer to one.
It reveals gaps
Writing steps in order often exposes missing steps. A recipe that says "mix the ingredients and bake" skips crucial details: what temperature? For how long? In what kind of pan?
It makes work transferable
If your process lives only in your head, it cannot be taught, automated, or improved. Writing it down as explicit steps means someone else — or a machine — can follow it.
It enables automation
Computers do exactly what they are told, step by step. They cannot fill in gaps or make assumptions. Step-by-step thinking is the bridge between a human idea and a working program.
Algorithms in Technology
Sorting
Arranging items in order is one of the most fundamental algorithms in computing. You already do this intuitively:
Sorting a Hand of Playing Cards
1. Look at the first two cards
2. If they are out of order, swap them
3. Move to the next pair
4. Repeat until no more swaps are needed
Computers sort millions of items using the same basic idea, just with more sophisticated strategies for doing it quickly.
Searching
Finding a specific item in a collection is another core algorithm:
Finding a Word in a Dictionary
1. Open the dictionary to the middle
2. Is the word on this page?
3. If yes, you found it — done
4. If the word comes before this page alphabetically, look in the first half
5. If the word comes after, look in the second half
6. Repeat with the remaining half until found
This "divide and conquer" approach is far faster than reading every page from the beginning — and it is the basis of binary search, one of the most important algorithms in computer science.
Processing Pipelines
Many systems process data through a series of steps, just like an assembly line:
Order Processing Pipeline
1. Receive the order
2. Validate payment information
3. Check inventory
4. If item is in stock, reserve it
5. If item is out of stock, notify the customer and stop
6. Calculate shipping costs
7. Charge the payment method
8. Generate a shipping label
9. Send confirmation email
Each step transforms or checks the data before passing it to the next step. This is the same sequential thinking you use in a recipe, applied to a business process.
From Algorithm to Code
The gap between an algorithm and code is smaller than most people think. If you can write clear, specific steps, you are most of the way to writing a program.
Algorithm: Calculate the total price of items in a shopping cart.
1. Start with a total of 0
2. For each item in the cart:
a. Look up the item's price
b. Multiply the price by the quantity
c. Add the result to the total
3. Return the total
This reads like plain English, but it is precise enough that a programmer could translate it into any programming language in minutes. The hard part was not the code — it was thinking through the steps clearly.
Common Pitfalls
Skipping steps
The most common problem is assuming steps that are obvious to you. "Just sort the list" skips the question of how. When writing an algorithm, pretend you are explaining to someone who knows nothing about the task.
Ambiguous instructions
"Cook until done" is ambiguous. Done according to whom? What does done look like? Good algorithm steps are specific enough that two different people following them would do the same thing.
Forgetting edge cases
What happens when the input is empty? What if there are zero dishes to wash? Zero items in the cart? A good algorithm handles these unusual cases, not just the normal path.
Making it too complicated
If an algorithm is hard to follow, it is probably doing too much at once. Break it into smaller sub-algorithms. Instead of one giant recipe, have a main recipe that references separate instructions for the sauce and the pasta.
Confusing the order
When steps depend on each other, getting the order wrong produces incorrect results. You cannot frost a cake before baking it. Carefully consider which steps must come before which.
Key Takeaways
- An algorithm is a set of step-by-step instructions with a clear start, end, and result — not just a computer concept.
- Everyday algorithms include recipes, assembly instructions, morning routines, and navigation directions.
- All algorithms are built from three structures: sequence, selection (decisions), and repetition (loops).
- Writing steps explicitly reveals gaps, forces clarity, and makes processes transferable and automatable.
- In technology, sorting, searching, and processing pipelines are core algorithms built from the same step-by-step thinking.
- The hard part is usually thinking through the steps clearly, not translating them into code.