Back to homeTechnology and Digitalisation · 2nd ESO · Change subject
Start for free
ESO Y2 · Technology and Digitalisation
Digital content creation · Simple creation and programming

Algorithms and computational thinking

Before you write a single line of code, you need to be completely clear about the steps you have to take. That list of exact steps is an algorithm, and thinking in this way — breaking things down, looking for patterns, keeping only what matters — is computational thinking.

Before you start, make sure you know: Programs and applications (1st ESO)
Before you start, make sure you know: Algebraic language (1st ESO)

What an algorithm is

Linear flowchart showing from top to bottom the ordered steps of a recipe: start, collect ingredients, mix, serve and end. Start Step 1: collect ingredients Step 2: mix Step 3: serve End
Practice★☆☆Not started
Write the algorithm, as a numbered list of steps, to make a cheese sandwich, so that a person who has never made one can follow it without doubt. Review your list and…

Write the algorithm, as a numbered list of steps, to make a cheese sandwich, so that a person who has never made one can follow it without doubt. Review your list and check that no steps you took for granted are missing.

Solve
Practice★☆☆Not started
Write the algorithm for preparing a glass of cocoa milk in six to eight steps, so precise that a robot could follow them: quantities, order of steps, and how to check…

Write the algorithm for preparing a glass of cocoa milk in six to eight steps, so precise that a robot could follow them: quantities, order of steps, and how to check that the cocoa has dissolved before finishing.

Solve
Practice★☆☆Not started
In the "frying an egg" recipe, identify the input (ingredients and utensils), the process (steps involving heat and the frying pan), and the output (the result). Explain…

In the "frying an egg" recipe, identify the input (ingredients and utensils), the process (steps involving heat and the frying pan), and the output (the result). Explain why thinking in this way helps to write clear algorithms.

Solve
Practice★☆☆Not started
A recipe says "stir the sauce until it thickens". Explain why an algorithm must always terminate and what could happen if the sauce never thickens. Rewrite that step so…

A recipe says "stir the sauce until it thickens". Explain why an algorithm must always terminate and what could happen if the sauce never thickens. Rewrite that step so that the cook does not end up stirring forever.

Solve

Decisions and repetitions in the flowchart

Flowchart with a conditional structure that branches the path according to a decision, using a diamond. Start Is the light low? yes switch on lamp no lamp off repeat
Practice★☆☆Not started
These steps of the "going to school" algorithm are out of order: (a) enter the classroom, (b) get up, (c) have breakfast, (d) leave the house, (e) get dressed, (f) walk…

These steps of the "going to school" algorithm are out of order: (a) enter the classroom, (b) get up, (c) have breakfast, (d) leave the house, (e) get dressed, (f) walk to school. Put them in the correct order and add a decision to the algorithm: what to do if it is raining when leaving the house.

Solve
Practice★☆☆Not started
The figure shows, using interlocking blocks, the algorithm for an automatic reading lamp that should turn on only when light is low, but one block is missing. Indicate…

The figure shows, using interlocking blocks, the algorithm for an automatic reading lamp that should turn on only when light is low, but one block is missing.

on start repeat forever if light is low turn on the lamp else ?

Indicate which block you would place in the gap and explain in your own words how the complete algorithm works, step by step.

Solve
Practice★☆☆Not started
Read this algorithm: (1) pick up the deck of cards, (2) while cards remain in your hand, deal one to each player starting on your left, (3) when no cards remain,…

Read this algorithm: (1) pick up the deck of cards, (2) while cards remain in your hand, deal one to each player starting on your left, (3) when no cards remain, announce "dealt". Explain in one sentence what the algorithm does and point out which part is the loop and when it terminates.

Solve
Practice★★☆Not started
Trace this algorithm with $n = 7$: (1) start with the value of $n$, (2) repeat three times: add 2, (3) subtract 5, (4) write the result. Note down the value after each…

Trace this algorithm with $n = 7$: (1) start with the value of $n$, (2) repeat three times: add 2, (3) subtract 5, (4) write the result. Note down the value after each step, give the final result, and explain what a trace is and why performing it by hand is useful.

Solve
Practice★★☆Not started
Write the algorithm to count how many people enter through the classroom door using only a "counter" variable starting at 0: what you do each time someone enters, how…

Write the algorithm to count how many people enter through the classroom door using only a "counter" variable starting at 0: what you do each time someone enters, how you know when to stop counting, and what value the counter will have at the end.

Solve

Decomposing, recognising patterns and abstracting

A big problem, in the shape of a puzzle piece, is divided by a cut into two smaller subproblems that fit together. big problem subproblem 1 subproblem 2
Practice★★☆Not started
Decompose the problem "organising the end-of-year party" into four smaller sub-problems and write two concrete steps to solve each one. Explain the advantage of breaking…

Decompose the problem "organising the end-of-year party" into four smaller sub-problems and write two concrete steps to solve each one. Explain the advantage of breaking down a large problem in this way.

Solve
Practice★★☆Not started
To sort a deck of cards there are several different algorithms, and some are faster than others. Explain with an everyday example how the same problem can be solved by…

To sort a deck of cards there are several different algorithms, and some are faster than others. Explain with an everyday example how the same problem can be solved by multiple algorithms and what it means for one to be "better" than another.

Solve
Practice★★☆Not started
Recognising patterns means finding the repeating rule. Find the pattern in these three sequences and express it as a clear rule: (a) 5, 10, 15, 20, ..., (b) 100, 90, 80,…

Recognising patterns means finding the repeating rule. Find the pattern in these three sequences and express it as a clear rule: (a) 5, 10, 15, 20, ..., (b) 100, 90, 80, 70, ..., (c) Monday: 1 press-up, Tuesday: 2, Wednesday: 4, Thursday: 8, ... State what value would come next in each one.

Solve
Practice★★☆Not started
A tube map does not draw the real city: it removes distances, curves, and streets, keeping only stations and connections. Explain what abstraction is using this example…

A tube map does not draw the real city: it removes distances, curves, and streets, keeping only stations and connections. Explain what abstraction is using this example and then apply it to the floor plan of your school: which three features would you include and which three would you remove?

You can do it on paper and send a photo with your answer.

Solve
Practice★★★Not started
You are looking for a word in a 500-page dictionary. Compare these two algorithms: opening at the first page and advancing one by one, or opening in the middle and…

You are looking for a word in a 500-page dictionary. Compare these two algorithms: opening at the first page and advancing one by one, or opening in the middle and discarding the unneeded half. Explain which is more efficient, why it only works if the pages are sorted, and estimate how many "page openings" each method requires.

Solve
Practice★★★Not started
Two people prepare breakfast together for four guests: coffee needs to be made, bread toasted, juice squeezed, and the table set. Divide the tasks between the two while…

Two people prepare breakfast together for four guests: coffee needs to be made, bread toasted, juice squeezed, and the table set. Divide the tasks between the two while respecting dependencies (you cannot serve coffee before making it) and explain which tasks can be done simultaneously and which cannot, giving their order.

Solve

Edge cases and errors in algorithms

Flowchart illustrating an edge case by means of a check before carrying out an action. Start Any sandwiches left? yes hand one out no warn: no more
Practice★★★Not started
The algorithm for a canteen hands out a sandwich to each attendee, but fails when there are more attendees than sandwiches. Explain what an "edge case" is in an…

The algorithm for a canteen hands out a sandwich to each attendee, but fails when there are more attendees than sandwiches. Explain what an "edge case" is in an algorithm, propose how distribution should behave in that situation, and rewrite the problematic step so that the algorithm does not fail.

Solve
Practice★★★Not started
A cash machine only contains $20\ \text{€}$ notes and its algorithm dispenses the requested amount in notes. Explain what happens when someone requests $75\ \text{€}$,…

A cash machine only contains $20\ \text{€}$ notes and its algorithm dispenses the requested amount in notes. Explain what happens when someone requests $75\ \text{€}$, why this is an edge case, and rewrite the cash machine rules so that it always provides a sensible response.

Solve
Practice★★★Not started
Design the complete algorithm, with numbered steps that include decisions and loops, for a pedestrian crossing with a button: what happens from when someone presses the…

Design the complete algorithm, with numbered steps that include decisions and loops, for a pedestrian crossing with a button: what happens from when someone presses the button until the lights return to their initial state, including the timings for each light.

Solve
Practice★★★Not started
Think of a program that plays noughts and crosses. Describe the strategy it would follow on each turn: what board data it must inspect, in what order, and what rules you…

Think of a program that plays noughts and crosses. Describe the strategy it would follow on each turn: what board data it must inspect, in what order, and what rules you would use to decide where to place the mark. There is no need to write code: state the rules in natural language.

Solve
Practice★★★Not started
The figure shows, using interlocking blocks, the skeleton of a secret number guessing game, but inside the loop a piece is missing so that the game can give clues to the…

The figure shows, using interlocking blocks, the skeleton of a secret number guessing game, but inside the loop a piece is missing so that the game can give clues to the player.

on start repeat until correct ask for a number ? say Correct!

Describe which block (or blocks) you would place in the gap so that the game tells the player whether their number is greater or smaller than the secret number, and explain the complete operation of the algorithm: what is repeated, when it terminates, and what happens if the player gets it right on the first try.

Solve
Practice★★★Not started
Two algorithms are proposed for classroom recycling: (a) each day, the person responsible sorts all the day's rubbish into three bins, and (b) each week, in turns, a…

Two algorithms are proposed for classroom recycling: (a) each day, the person responsible sorts all the day's rubbish into three bins, and (b) each week, in turns, a pair sorts everything accumulated. Evaluate both against criteria of total time, sorting errors, and distribution of effort, and choose one with justification.

Solve
Practice★★☆Not started
A recipe says: "add salt and simmer for a while on medium heat". Explain why a computer could not follow that instruction and rewrite it as a precise algorithm step,…

A recipe says: "add salt and simmer for a while on medium heat". Explain why a computer could not follow that instruction and rewrite it as a precise algorithm step, stating quantities, timings, and how to check that the step is complete.

Solve
Practice★★☆Not started
This "doing the laundry" algorithm contains a bug: (1) put all clothes into the washing machine, white and coloured together, (2) add detergent, (3) choose the long…

This "doing the laundry" algorithm contains a bug: (1) put all clothes into the washing machine, white and coloured together, (2) add detergent, (3) choose the long hot-water programme, (4) hang out to dry. Find two problematic steps, explain what could go wrong in each, and rewrite the corrected algorithm including a prior sorting step.

Solve

Summary

See all the exercises in this section