MOO WebTech
Algorithms & Mobiletheory-practicebeginner

L24 — Algorithms & Programs

What is an algorithm? We explore algorithms with everyday examples, learn flowchart symbols, tell apart linear, branching, and cyclic algorithms, and build our very first program in Scratch — right in the browser.

80 min10.02.2026L24

🎯Learning Objectives

  • Explain in your own words what an algorithm is
  • List the main properties an algorithm must have
  • Read a simple flowchart and trace what it does step by step
  • Tell the difference between a linear, a branching, and a cyclic algorithm
  • Build your first tiny program in Scratch directly in the browser — no installation

📖Theory

1. What Is an Algorithm?

Every morning you do almost the same thing: wake up, brush teeth, get dressed, eat breakfast, go to school. If you forget a step, the result is... not great.

An algorithm is a clear, step-by-step plan for solving a task. Each step is simple enough that the "doer" (a person, a robot, or a computer) can perform it without thinking.

Examples from real life that are algorithms:

  • A recipe for making pancakes
  • Instructions for a board game
  • A map route from home to school
  • Steps to solve a math problem

Computers don't know how to solve a problem on their own. We give them an algorithm, and they follow it exactly — every single time, without shortcuts.

2. The Performer (Executor)

The one who carries out the algorithm is called the performer (executor). Each performer only understands a fixed list of commands.

PerformerExample commands it understands
A human cook"crack egg", "stir", "pour into pan"
Scratch cat"move 10 steps", "turn 15 degrees", "say Hi"
Turtle in Blockly"forward", "turn left", "turn right"
Calculator"+", "−", "×", "÷", "="

If you tell the Scratch cat to "bake a cake", nothing happens — that command isn't in its list. The algorithm must only use commands the performer knows.

Rule: always check what your performer can actually do before writing the algorithm.

3. Properties of a Good Algorithm

Not every instruction is an algorithm. A real algorithm has five properties:

  1. Discreteness — broken into clear, separate steps.
  2. Definiteness — each step has only one possible meaning (no "do something with the eggs").
  3. Finiteness — always ends after a finite number of steps (no infinite loops).
  4. Input — there are starting values (ingredients, numbers, a starting position).
  5. Output — the algorithm produces a result (a meal, an answer, a finished drawing).

Tip: if you tell a friend the algorithm out loud and they have to guess what you meant at any step — the definiteness property is broken. Rewrite that step.

4. Ways to Write Down an Algorithm

The same algorithm can be written in different forms, depending on who will read it:

FormExampleWho uses it
Words"Boil water. Put tea bag in cup. Pour water. Wait 3 minutes."A person
FlowchartA diagram made of boxes and arrowsAnyone, very visual
PseudocodeA simplified text that looks like code but isn't realProgrammers, for planning
ProgramReal code in a programming languageA computer

A flowchart is the most useful form for learning, because it shows the structure of the algorithm at a glance.

5. Flowchart Symbols

Every flowchart is built from a small set of shapes. Memorise these five:

ShapeNameMeaning
⬭ (oval)Start / EndThe beginning or the end of the algorithm
▭ (rectangle)ActionA step that does something
◇ (diamond)DecisionA question with a Yes/No answer
▱ (parallelogram)Input / OutputReading a value or printing a result
→ (arrow)FlowThe direction in which steps happen

Example — flowchart for "Make a cup of tea":

Code
    ( Start )
        |
    [ Boil water ]
        |
    [ Put tea bag in cup ]
        |
    [ Pour water into cup ]
        |
    [ Wait 3 minutes ]
        |
    [ Remove tea bag ]
        |
    (  End  )

Tip: to draw flowcharts online, open app.diagrams.net — it's free, works in the browser, no account needed. In the left panel choose the "Flowchart" category.

6. Three Types of Algorithms

Almost every algorithm in the world is a mix of three building blocks.

Linear — steps run one after another, top to bottom. No questions, no repeats.

( Start ) → [ Step 1 ] → [ Step 2 ] → [ Step 3 ] → ( End )

Example: the tea recipe above is linear.

Branching — the algorithm asks a question and takes one of two paths.

Code
( Start )
    |
[ Look outside ]
    |
  < Is it raining? >
   /             \
  Yes            No
   |              |
[ Take umbrella ] [ Wear sunglasses ]
   \             /
    \           /
    (   End   )

Example: crossing the road. "Is the light green?" — Yes → cross. No → wait.

Cyclic (loop) — one or more steps are repeated until some condition is met.

Code
( Start )
    |
[ count = 0 ]
    |
   < count < 4 ? > ──No──> ( End )
    | Yes
[ Draw a square side ]
    |
[ count = count + 1 ]
    |
    └──────────────→ (back to the question)

Example: brushing teeth — repeat "move brush" until all teeth are clean.

7. From Algorithm to Program

A program is an algorithm written in a programming language — a language the computer understands directly.

  • The algorithm is the idea: "ask the user's name, then greet them".
  • The program is that idea written in Python, JavaScript, Scratch, etc.

The same algorithm can be written in many languages — like the same story can be told in Russian or English. The meaning is identical; only the words change.

8. The Tools We'll Use Today

All three work in the browser. Nothing to install.

ToolLinkWhat it's for
Scratchscratch.mit.eduBuild your first program by dragging colourful blocks
Blockly Gamesblockly.gamesFun puzzles — "Maze", "Turtle" — that teach algorithms step by step
draw.ioapp.diagrams.netFree online flowchart editor

Note: for Scratch you can click "Create" without an account. If you want to save your project between classes, sign up with your personal email (free).

💻Code Examples

Example A — A linear algorithm in words and in a flowchart

Task: greet a friend by name.

Steps in words:

  1. Ask the friend's name.
  2. Read the name.
  3. Print: "Hello, <name>!".

Flowchart:

Code
    ( Start )
        |
    ▱ Ask "What is your name?" ▱
        |
    ▱ Read the answer → name ▱
        |
    ▭ Print "Hello, " + name + "!" ▭
        |
    (  End  )

Example B — A branching algorithm

Task: is a number positive or negative?

Code
     ( Start )
         |
    ▱ Read x ▱
         |
      ◇ x > 0 ? ◇
       /        \
     Yes         No
      |           |
 ▭ Print        ▭ Print
   "positive"     "not positive"
      \           /
       \         /
        (  End  )

Example C — A cyclic algorithm (Scratch blocks)

This is how the same "draw a square" idea looks as Scratch blocks. You'll rebuild it yourself in Task 1.

Code
when [green flag] clicked
repeat (4)
    move (100) steps
    turn right (90) degrees
end

The repeat (4) block is a loop — it runs the two steps inside it four times, then stops. Four sides → a square.

✏️Practice Tasks

Task 1My first Scratch program
EASY — IN CLASS
  1. Open scratch.mit.edu and click Create
  2. Delete the default script (right-click any block → Delete)
  3. Drag the yellow when [green flag] clicked block onto the script area
  4. Under Looks → add a say [Hello!] for 2 seconds block
  5. Under Motion → add move (50) steps
  6. Click the green flag above the stage

The cat should greet you and then move. Change the text to your own name. Change 50 to 150 and watch what happens.

💡 Hint
If nothing happens when you press the green flag, the blocks aren't connected. Blocks must "click" together like puzzle pieces — drag one so its notch touches the notch of the previous block. There should be no visible gap.
Task 2Draw a flowchart
MEDIUM — IN CLASS

Open app.diagrams.net"Start a new diagram"Blank Diagram.

Draw a flowchart for this task:

Ask the user's age. If the age is 18 or more, print "You can vote". Otherwise, print "Too young to vote".

Requirements:

  • Use an oval for Start and End
  • Use a parallelogram for Ask age and for the two Print actions
  • Use a diamond for the question age >= 18 ?
  • Connect everything with arrows

When finished, File → Export as → PNG, save the image, and send it to your teacher.

💡 Hint
In draw.io the flowchart shapes are in the left sidebar. Drag an oval onto the canvas, double-click it to type "Start". To connect two shapes, hover over the first shape — blue arrows appear on its sides; drag one to the next shape.
Task 3Solve a Blockly Maze level
HARD — HOMEWORK
  1. Open blockly.games/maze
  2. Play through levels 1, 2, 3, 4, 5 — they're short
  3. Goal: reach level 6, where you need to use the if path and repeat blocks together
  4. Write down in a notebook, in your own words:
    • Which level was the easiest for you?
    • Which level forced you to use a loop for the first time?
    • Which level forced you to use branching (if)?
💡 Hint
If your character walks into a wall, the algorithm is wrong — not the maze. Go back, find the step where the path turns, and insert a "turn" block before that. Use "repeat" so you don't have to drag 20 copies of "move forward".

⚠️Common Mistakes

Giving a step that the performer can't do

Writing "the Scratch cat bakes a cake" is not an algorithm for Scratch — that command doesn't exist. Always use only commands from the performer's list.

Forgetting the End in a flowchart

A flowchart must have exactly one Start (oval) and at least one End. Without an end, the reader doesn't know where the algorithm finishes.

Confusing a rectangle with a diamond

A rectangle is an action ("do this"). A diamond is a question ("is this true?"). A diamond must have two arrows leaving it — one for "Yes" and one for "No".

An infinite loop

repeat until (false) will never stop — the computer spins forever. Every loop needs a condition that eventually becomes true. In Scratch, you can click the red stop sign to break out of an accidental forever-loop.

Skipping steps because "they're obvious"

A recipe that says "make the cake" is not an algorithm — it's a wish. Every step must be small enough that the performer can execute it without thinking.

🎓Instructor Notes

⚡ How to run this lesson (~80 min)

  • [5 min] Hook. Ask the room: "Who can tell me exactly how to make a cup of tea, step by step?" First student usually skips a step; the second corrects them. You've just introduced algorithms without saying the word.
  • [10 min] Theory — what is an algorithm + properties. Keep it fast and example-driven. Don't lecture — keep asking "is this an algorithm or not?" with examples (a recipe ✅, "be happy" ❌, "walk home" — maybe; how would a robot do it?).
  • [10 min] Flowchart symbols on the board. Draw the five shapes. Have the class draw the tea flowchart with you — step by step.
  • [10 min] Linear / branching / cyclic. For each type, show one everyday example and one flowchart example. Don't worry about code yet.
  • [5 min] Demo Scratch on the projector. Open scratch.mit.edu, click Create, drag 3 blocks, press the green flag. Emphasise: "no download, no login, it just works."
  • [25 min] Task 1 in class — first Scratch program. Walk around. Common problems: (a) blocks not connected, (b) student clicks on a block instead of the flag, (c) browser blocks the site → offer the offline alternative scratch.mit.edu/download for the computer lab.
  • [10 min] Task 2 in class — flowchart in draw.io. Demo the first two shapes on the projector. Let them finish on their own. Check each flowchart for: Start + End ovals, diamond with Yes/No labels.
  • [5 min] Wrap up + assign homework. Preview L25: mobile applications. Assign Task 3 (Blockly Maze) — it's fun and they'll happily do it.

💬 Discussion questions

  • "Is making breakfast an algorithm? Why or why not?"
  • "What's the difference between an algorithm and a program?"
  • "Name one algorithm you followed today before coming to class."
  • "Why can't a computer just 'figure out' a task without an algorithm?"

🧰 Classroom resources