Introduction
An algorithm is a clear, ordered set of steps for solving a problem or completing a task. Before programmers open an editor, good thinkers sketch the plan. Recipes, subway directions, and “how to submit homework” checklists are algorithms in everyday clothes.
In What is Code, you learned that computers need precise instructions. Algorithms are those instructions in human-friendly form. This lesson trains you to write steps that are complete, ordered, and testable—skills you will reuse with variables, loops, and conditions. Strong planners also type notes faster with regular practice.
Learning Objectives
By the end of this lesson, you will be able to:
- Define algorithm, sequence, and pseudocode
- Break a messy goal into numbered steps
- Include decision points and repeat actions when needed
- Test an algorithm by walking through an example
- Explain why algorithms matter before learning syntax
Main Lesson
The everyday algorithm
Suppose you want toast:
- Get bread.
- Place bread in toaster.
- Set level.
- Start toaster.
- Wait until toast pops.
- Remove carefully.
- Add topping if you want.
If you skip “get bread,” the plan fails. If you switch “remove” and “start,” you get a nonsense order. Algorithms care about completeness and order.
Properties of a good beginner algorithm
| Property | Meaning | Beginner check |
|---|---|---|
| Clear | Each step is understandable | Could a classmate follow it? |
| Ordered | Sequence matters | Are steps numbered? |
| Finite | It ends | Is there a finish condition? |
| Effective | It solves the real goal | Does a walk-through work? |
| Precise enough | Less guesswork | Did you remove “somehow”? |
You will refine precision over time. Day-one goal: no mystery verbs like “handle it” without saying how.
Sequence, selection, and repetition (preview)
Algorithms are built from three classic ideas:
- Sequence — Do steps in order (A, then B, then C).
- Selection (decisions) — If something is true, do one path; otherwise do another. See Conditions and Logic in Coding.
- Repetition (loops) — Repeat a step until a stop rule is met. See Loops.
Example — borrowing a library book:
- Find the book (sequence).
- If it is available, take it to checkout; else place a hold (selection).
- While the due date has not arrived, renew or finish reading reminders (repetition idea).
Pseudocode: the bridge language
Pseudocode is informal structured English for algorithms. It is not strict Python or JavaScript. It helps you think without fighting syntax.
```text
START
SET score TO 0
ASK user for answer
IF answer is correct THEN
ADD 1 TO score
ELSE
SHOW try-again message
SHOW final score
END
```
Later, you will turn plans like this into functions and real code—or into block coding stacks.
Inputs, processes, outputs in algorithms
Algorithms often mirror the IPO idea from computer basics:
- Input — What information starts the process?
- Process — What transformations happen?
- Output — What result appears at the end?
Example — attendance checker:
- Input: list of student names, list of present names
- Process: compare lists, count absences
- Output: absence report
Ambiguous vs improved steps
| Vague step | Improved step |
|---|---|
| Make the account | Create username, set password meeting school rules, confirm email if required |
| Sort the scores | Arrange scores from highest to lowest |
| Fix the page | If image is missing, show placeholder; if text overflows, wrap lines |
| Do homework | Open assignment, complete questions 1–10, save file, submit before 8pm |
Precision protects you when you translate plans into code later.
Tracing: test before you build
Tracing means walking through the algorithm with sample data using paper or a table. If your quiz algorithm says “add 1 when correct,” try answers right/wrong/right and confirm the score becomes 2. Tracing finds holes early—cheaper than debugging a half-built program.
Algorithms in real software
Search engines rank pages with ranking algorithms. Maps estimate routes with path algorithms. Typing sites use comparison algorithms to score accuracy. Recommendation systems use algorithms to suggest videos. You do not need the advanced math yet; you need respect for clear steps.
Key Definitions
- Algorithm — A finite, ordered set of steps to solve a problem or finish a task.
- Sequence — Steps performed one after another in order.
- Selection — Choosing different paths based on a condition.
- Repetition / iteration — Repeating steps until a condition is met.
- Pseudocode — Structured plain-language sketch of an algorithm.
- Trace / dry run — Manually testing steps with sample inputs.
- Input — Data or signals an algorithm starts with.
- Output — Results produced when the algorithm finishes (or updates).
- Efficiency (intro) — How much work an approach needs; beginners focus on correctness first.
- Decomposition — Breaking a big problem into smaller subproblems.
Examples
Example 1: Login check algorithm
Input username and password → if both match stored values, open dashboard; else show error and allow retry up to three times.
Example 2: Finding the highest score
Set highest to first score → for each remaining score, if it is greater than highest, replace highest → show highest.
Example 3: Saving a document
If file has a name, save to that path; else ask for a name, then save.
Example 4: Typing accuracy sketch
For each typed character, compare to target; count matches; accuracy = matches ÷ total × 100. Tools like TYPE10X Practice follow related scoring ideas.
Real-World Scenarios
Scenario A — Group project chaos
Four students start coding a quiz with no shared plan. Features collide. They pause, write one algorithm on the board, assign parts, and finish faster.
Scenario B — Robot obstacle course
A club robot must move forward until a wall sensor triggers, then turn left. Students write the algorithm first; wiring without a plan wastes batteries.
Scenario C — Morning routine remix
Jordan rewrites “get ready” into timed steps with decision points (if raining, pack umbrella). The same habit of clarity transfers to coding homework.
Tips
Warnings
Did You Know
Common Mistakes
- Writing goals instead of steps (“Make a great game”)
- Skipping edge cases (empty list, wrong password, zero scores)
- Assuming order does not matter
- Using words like “handle,” “fix,” or “manage” without detail
- Jumping into syntax before the plan is testable
Interactive Exercise
Algorithm Makeover (15 minutes)
Take this vague plan: “Make a sandwich and eat it.”
Rewrite it as:
- At least eight numbered steps
- One decision (IF … THEN … ELSE)
- One repeated action with a clear stop (WHILE / REPEAT UNTIL)
Trace it for two cases: all ingredients present vs missing one ingredient.
Practice Questions
- What is an algorithm?
- Why does order matter in algorithms?
- What is pseudocode used for?
- Give an example of selection in an everyday algorithm.
- How does tracing help before coding?
Mini Challenge
Design an algorithm for a “classroom helper bot” that:
- Greets a student by name (input)
- Checks whether homework is submitted
- Reminds or congratulates accordingly
- Ends after helping three students (repetition limit)
Write it in pseudocode and present a 90-second walk-through.
Summary
Algorithms are ordered, finite plans for solving problems. Good beginner algorithms are clear, testable, and precise enough to reduce guesswork. Sequence, selection, and repetition are the building blocks you will soon express with real coding tools. Master planning now, and every later lesson—from variables to your mini project—becomes easier.
Student Checklist
- [ ] I can define an algorithm and pseudocode
- [ ] I can write ordered steps with at least one decision
- [ ] I know why tracing matters
- [ ] I improved a vague plan into a clearer one
- [ ] I completed the makeover exercise and mini challenge
Teacher Notes
- Use physical card-sorting or recipe rewriting before digital tools.
- Celebrate precision improvements, not fancy vocabulary.
- Create a gallery walk of student pseudocode.
- Preview next lesson by asking: “Where would we store the changing score?”
- Cross-link to typing practice for writing long step lists efficiently.
FAQ
Q: Is an algorithm the same as a program?
Not exactly. An algorithm is the plan; a program is the plan expressed in a programming language and made runnable.
Q: Do all algorithms need computers?
No. Humans run algorithms constantly. Computers run them extremely fast and repeatedly.
Q: How detailed should my steps be?
Detailed enough that a classmate can follow them without asking you what you “meant.”
Q: What if there are many correct algorithms?
Often true. Beginners should aim for correct and clear first; efficiency can come later.
Q: What should I study next?
Continue to Variables to learn how programs store changing information.
Related Lessons
Related Blog Posts
- Read practical learning guides on the TYPE10X Blog
- Strengthen keyboard skills for writing plans at Practice
Next Lesson CTA
You can now plan problems as clear step lists. Next, learn how programs remember changing values—continue to Variables.