Tutelage

Lessons › coding and computer science · taught by Leo

What is an algorithm? Input, process, output

Learn that an algorithm is a clear, step-by-step process that takes input and produces an output.

Learn this with Leo, freeA voiced lesson with a live whiteboard, quizzes and a tutor you can call, at tutelage.app

A recipe with exact steps

An algorithm is just a set of exact steps to solve a problem. Think of it like a recipe for a computer.

The key idea is that the steps are clear, in order, and finish the job.

If the steps are vague, the computer cannot guess what you mean.

Big idea: input, process, output

An algorithm takes input, does steps, and gives an output.

A good way to picture an algorithm is input, process, output.

Input is what you start with. Process is the steps. Output is the result.

That pattern shows up in programs, math, and everyday tasks.

Predict: is this an algorithm?

Which one is an algorithm?

  1. A clear list of steps to make a sandwich
  2. A random guess
  3. A feeling
Show answer

A clear list of steps to make a sandwich: Yes. A clear list of steps is exactly what an algorithm is.

Worked example: sort three numbers

Let’s work a tiny algorithm. Suppose we want to sort 7, 2, 5 from small to large.

First, compare 7 and 2. Since 7 is bigger, swap them.

Then compare the next pair until the numbers are in order.

Now the output is 2, 5, 7.

Quick check: next step

In the sorting rule, what should you do if the first number is bigger than the second?

  1. Swap them
  2. Ignore it
  3. Stop forever
Show answer

Swap them: Correct. Swapping fixes the order and lets the algorithm keep going.

Why steps must be precise

Algorithms work because the steps are precise enough to repeat.

That makes the result predictable, which is perfect for computers.

If two people follow the same algorithm, they should get the same answer.

Algorithms in real life

Algorithms can be simple or huge.

A brushing-teeth routine is an algorithm. So is a search engine.

Some algorithms are short, and some are complicated.

The size does not matter. The clear step-by-step structure does.

Your turn: choose the algorithm

Which choice is most like an algorithm?

  1. Turn left, then go 2 blocks, then enter the school
  2. Go somewhere nice
  3. Wait and see
Show answer

Turn left, then go 2 blocks, then enter the school: Yes. That is a step-by-step procedure with a clear order.

Recap: algorithm checklist

Here is the checklist: input, exact steps, output.

If the steps are clear enough to repeat, you have an algorithm.

That is the big idea to remember.

Learn this with Leo, freeA voiced lesson with a live whiteboard, quizzes and a tutor you can call, at tutelage.app