Algorithms: Final Steps
The finale of the Algorithms series: we gather everything we learned in nine posts (variable, conditional, loop, list, function, dictionary), combine it in one program, and point to the next step.
Series · Algorithms
- 1. What Is an Algorithm? — Programming From Scratch
- 2. Algorithms: Flowcharts
- 3. Algorithms: Pseudocode
- 4. Algorithms: Variables
- 5. Algorithms: Conditionals
- 6. Algorithms: Loops
- 7. Algorithms: Lists
- 8. Algorithms: Functions
- 9. Algorithms: Dictionaries
- 10. Algorithms: Final Steps
Long road, wasn’t it? We started by asking what an algorithm is; now you’ve got a whole toolbox in your hands: variables, conditionals, loops, lists, functions, dictionaries.
This is the last post in the series. I won’t teach a new topic here. Instead we’ll look back: what did we learn, and how do these pieces connect? Then we’ll bring them all together in one small program and close things out. Relax; this one is a bit of a victory lap.
What you learned is really just a few ideas
Nine topics can look intimidating. But here’s the nice part: they all revolve around a few simple ideas. Look back and what we learned splits naturally into three groups.
1. Holding a piece of information somewhere
Every program first has to put something somewhere. A number, a name, a bunch of grades… We grew this step by step.
First there was the variable: a box you put one thing in and write a name on. You said age ← 30, done. Then things got bigger and the list arrived: not one box but a row of boxes, all sharing a single name. When you said grades[3] you looked at the third box. Remember how “which position the box is in” and “what’s inside it” were two different things, that mailbox example.
Last came the dictionary: here you reached a box not by a position number but directly by name. grades["Ada"]. Just like a phone book; to find someone’s number you don’t count “which person were they,” you look up their name.
From a single thing, to an ordered bunch of things, to a thing found by name. The same need (storing a piece of information) in three ever-stronger forms.
2. The program deciding and repeating
You held the information; now what does the program do with it? Usually two things: sometimes it makes a decision, sometimes it repeats the same work.
The decision part was the conditional. IF grade ≥ 50 THEN ... ELSE .... Passed, or failed? The path splits by the situation. The repeating part was the loop. Instead of copying the same lines fifty times, you said “repeat until this is done.” A loop is really just a decision asked over and over; that’s why it and the conditional are relatives.
3. Tidying up the mess
As a program grows, it starts to sprawl. The function was exactly what helped here: giving a group of steps a name and making them a single piece. We wrote average(list) once and then called it as often as we liked. We didn’t even need to know exactly what happened inside; hand it the list, take the average. A black box.
And how did we put all of this on paper? That was the job of the first three posts: we drew an algorithm as a flowchart and wrote it as pseudocode. Underneath it all was one simple idea: breaking a job into clear, ordered steps. Remember that tea-brewing example from the very beginning? That’s the one.
| For what? | Topic | In one sentence |
|---|---|---|
| Putting on paper | Algorithm, Flowchart, Pseudocode | Breaking a job into clear steps, drawn/written |
| Holding information | Variable, List, Dictionary | A single thing, an ordered bunch, a thing found by name |
| Deciding and repeating | Conditional, Loop | Deciding by the situation and repeating |
| Tidying up | Function | Splitting work into named, reusable pieces |
Let’s bring it all together
Now the fun part. Let’s take all the pieces we learned and gather them into one program.
Let’s make a little class report. We’ve got students and their grades; we’ll compute each one’s average, check whether they passed or failed, and at the end count how many passed. Sounds like a lot of work, but you already know how to do every bit of it:
FUNCTION average(list) total ← 0 i ← 1 WHILE i ≤ length(list) DO total ← total + list[i] i ← i + 1 ENDWHILE RETURN total / length(list)ENDFUNCTION
report ← { "Ada": [90, 85, 100], "Can": [40, 35, 45], "Ece": [70, 65, 80] }passCount ← 0
FOR EACH student IN report avg ← average(report[student]) IF avg ≥ 50 THEN status ← "Passed" passCount ← passCount + 1 ELSE status ← "Failed" ENDIF PRINT student + ": average " + avg + " → " + statusENDFOR
PRINT "Total passed: " + passCountRun it and it prints:
Ada: average 91.67 → PassedCan: average 40 → FailedEce: average 71.67 → PassedTotal passed: 2Stop for a second and look at this. This tiny program has all nine topics of the series in it: a function (average), a dictionary (report), lists as values, a loop (for each student), a conditional (pass/fail), variables (avg, status, passCount), an accumulator (passCount), and PRINT throughout. Let’s see the same program as a flowchart too:
flowchart TD
A(["Start: report dictionary ready, passCount ← 0"]) --> B{"Is there a<br/>next student?"}
B -- Yes --> C["avg ← average(report[student])"]
C --> D{"avg ≥ 50?"}
D -- Yes --> E["status ← Passed<br/>passCount ← passCount + 1"]
D -- No --> F["status ← Failed"]
E --> G["PRINT student + status"]
F --> G
G --> B
B -- No --> H(["PRINT Total passed<br/>Done"])This is really what programming is. Small, simple pieces; on their own they don’t do much. But put them together the right way and, together, they handle a big job. And you can do this now.
Where to next?
Through this series we learned how a computer thinks, on paper. The next step is telling that same way of thinking to a real computer. Don’t worry, the hardest part is already behind you.
flowchart LR
A["1–3<br/>Algorithm · Flowchart · Pseudocode"] --> B["4–6<br/>Variable · Conditional · Loop"]
B --> C["7–9<br/>List · Function · Dictionary"]
C --> D["10<br/>Final Steps"]
D --> E["A real language<br/>Python / JavaScript"]- Pick a language. The one most recommended for beginners is Python. It’s easy to read, and honestly it looks almost exactly like pseudocode. If you want to build things that run in the browser, on web pages, JavaScript is a great choice too. Which one you start with really doesn’t matter; the core ideas are the same in every language, and you already know them.
- Translate your pseudocode into real code. This is easier than you’d think, because you already built the skeleton. Most of the time the work is just fitting the words to that language. Our
PRINTbecomesprintin Python,console.login JavaScript. You write=instead of←.WHILE … ENDWHILEturns into awhileblock. The logic doesn’t change, only the way it’s written. - Write small things. A calculator, a tiny to-do list, a number-guessing game… Small projects you can actually finish are the best teacher. And one more thing: don’t be afraid to make mistakes. Code will break, it’ll throw errors, and you’ll find and fix them. That’s how you learn the most.
A small thank you
One last thing. Behind every idea we learned in this series there were real people, each of them once the first to think these things up. Let’s name a few:
- al-Khwarizmi, whose name we invoke when we say “algorithm” today, was a 9th century mathematician who also founded algebra.
- George Boole built the true/false logic of conditionals.
- Ada Lovelace wrote the first program back in 1843. Yes, the first programmer was a woman.
- Behind lists are the Fortran language and Dijkstra, who asked “why do we count from zero?”
- David Wheeler brought the idea of the function; Grace Hopper brought the idea of the “library” and the first compiler.
- That fast-lookup trick (hashing) behind the dictionary was Hans Peter Luhn’s work.
Summary
Related posts
Frequently asked questions
What did we learn in this algorithm series?
We learned how a computer "thinks," with pen and paper. We started with what an algorithm is, then saw how to draw it as a flowchart and write it as pseudocode. After that we stored information in variables, decided with conditionals, repeated with loops, held data with lists and dictionaries, and split our jobs into tidy pieces with functions. Without writing a single line of real code, we grasped the core ideas of programming.
How do the topics we learned connect to each other?
They fall into three main groups. Holding information: variable (a single thing), list (an ordered bunch of things), dictionary (a thing found by name). Managing what the program does: conditional (a decision) and loop (a repetition). And tidying up: the function (splitting work into named, reusable pieces). Flowcharts and pseudocode were our tools for putting all of this on paper. Real programs use all these pieces nested together.
How do I turn a problem into an algorithm?
First break the problem into small, clear steps (like the tea-brewing example in the first post). Decide what information you need to hold: a variable, a list, or a dictionary? Use a conditional where a decision is needed, a loop where repetition is needed. Wrap repeated or nameable jobs in a function. Then test the steps on paper with a trace table. That is exactly what we did throughout this series.
What should I learn after this series?
It's time to move to a real programming language. Everything you learned in pseudocode (variables, conditionals, loops, lists, functions, dictionaries) has an almost one-to-one equivalent in a language like Python or JavaScript. Practice by writing small programs: a calculator, a to-do list, a number-guessing game. The best way to learn is not reading but writing.
Which programming language should I choose?
The one most often recommended for beginners is Python. It is easy to read and very close to pseudocode. If you're drawn to things that run in the browser, on web pages, JavaScript is a great start too. Honestly, which first language you pick doesn't matter much; the core ideas are the same in every language, and you already know them. Pick one, stick with it, and the rest follows.
How do I translate pseudocode into real code?
Pseudocode is already the skeleton of a program; turning it into real code is usually just fitting the words to that language. For example, the PRINT in pseudocode becomes print in Python and console.log in JavaScript. You write = instead of ←, and WHILE … ENDWHILE becomes a while block. The logic doesn't change at all, only the way it's written.
When should I use a list versus a dictionary?
Use a list when you'll walk the data in order from start to end, or when the order itself matters; you reach an element by its position (list[3]). Use a dictionary when you need quick access from a name or an id to a piece of information; you reach a value by its key (grades["Ada"]). The two aren't rivals: a dictionary's value can be a list, and a list's element can be a dictionary.
Can I really learn to program?
Yes. Programming isn't an inborn talent but a learnable skill. If you solved the hardest part (thinking like an algorithm) in this series with a pen, you've already cleared the toughest hurdle. The rest is a matter of practice. Write small, finishable projects, don't be afraid to make mistakes, and work at it a little every day. A few months from now, things that look hard today will feel easy.