Saltearse al contenido

Chapter 1 - What is an Algorithm?

Esta página aún no está disponible en tu idioma.

Computers are all around us. They can be big or small. A cell phone is a computer. So is a calculator, a tablet, or even some refrigerators and cars! But how do these machines know what to do?

The answer is: we tell them what to do! We give computers instructions, and they follow those instructions carefully. In computer science, we have a special word for this: algorithm.

1.1 Algorithms and Sequences

An algorithm is a set of steps we give to a computer to solve a problem or do a job. When you tell a computer to play music, send a message, or solve a math problem, it uses an algorithm to do that.

The order of the steps is called a sequence. If the steps are out of order, the computer won’t know what to do!

Let’s think about this in real life. What do you do when you get ready for school?

Maybe:

  1. Wake up
  2. Get dressed
  3. Eat breakfast
  4. Brush your teeth
  5. Go to school

What if you did those things in a silly order—like brushing your teeth before waking up? That wouldn’t work! That’s why the order (sequence) matters.

1.2 Pretend You’re the Computer!

Let’s play a fun game. Imagine your teacher is a robot. Your job is to help the robot reach a toy named Glitch on the other side of the room. But there’s a trick—you can only give one instruction at a time. Try saying:

  • “Walk forward”
  • “Turn left”
  • “Turn right”

Each command is one step in your algorithm. The robot (teacher) will only do what you say, in the order you say it. If you mix up the steps, the robot might walk into a desk or go the wrong way!

After trying with the teacher, you can play the game with a partner. One person is the robot, and the other gives instructions. Then you switch roles. That’s how computer scientists practice giving clear algorithms.

1.3 Playing with the Foos

Now let’s try coding with a tablet or computer using the codeSpark Academy App. This app has fun puzzles with characters called the Foos. You will help a character named Gracie find donuts by giving her the right commands.

Use the “Test and Learn” steps:

  • Understand the problem: What does Gracie need to do?
  • Plan your steps: What commands should she follow?
  • Test your sequence: Try your steps and see what happens!
  • Learn from the result: Did it work? If not, what can you change?

Start with level 1 of the “Donut Detective” game. After we practice one puzzle together, you’ll try some puzzles by yourself. Don’t worry if you don’t get it right the first time—real computer scientists try, learn, and try again!

1.4 Algorithms in Real Life

Let’s draw an algorithm! Think of something you do every day—like brushing your teeth or eating a snack. On a paper, fold it into 4 squares and draw each step. You just made a real-life algorithm!

Now, write your own algorithm with a partner. Then trade your algorithm with another pair and act it out. Did the steps make sense? Were they in the right order?

1.5 Let’s Reflect

Talk with your class about these questions:

  • What did you learn about algorithms?
  • Why is sequencing important when giving instructions?
  • How did you use “Test and Learn” when solving puzzles with the Foos?

Great work! Now you’re thinking like a computer scientist. Keep practicing how to give clear instructions in the right order—that’s the key to good coding!

Vocabulary

TermDefinition
ComputerA machine that follows instructions to do tasks like solving problems or playing music.
InstructionA command given to a computer that tells it what to do.
AlgorithmA set of steps or instructions used to solve a problem.
SequenceThe specific order in which instructions are given and followed.
CodeThe language or symbols we use to write instructions for computers.
ProgrammerA person who writes code and gives instructions to computers.
GlitchA pretend character used in lessons to help us learn about instructions.
StepOne part of a sequence or algorithm.