Search the courses, subjects, tracks, games and features, or jump straight to a page.
Learn it your way
A short class with Sarah and her students. The other ways are under More.
Sign up free to listen. Transcripts are free to read.
Today, we're going to learn about algorithms, which are step-by-step procedures for solving problems. Can anyone tell me what they think an algorithm is?
Is it like a recipe that tells you what to do in order?
Exactly! Just like a recipe, an algorithm gives us clear instructions. Let's take a look at a simple algorithm for finding the sum of two numbers.
What does the algorithm look like?
I'll write it down: 1. Start, 2. Read number A, 3. Read number B, 4. Add A and B, store the result in SUM, 5. Display SUM, 6. Stop. It's very structured, right?
Yes! It seems simple and easy to follow.
And that's the point! Clarity is key in algorithms.
So, what do we first do in our algorithm?
We start!
Correct! And what comes next?
We read number A!
Perfect! Now remember, these steps prevent confusion and errors.
Let's break down the algorithm we wrote earlier. What do we mean by 'reading number A'?
It means we need to get input from the user, right?
Exactly! Input is crucial for algorithms. Now, what do we do after reading both numbers?
Then we add them together!
Right! We store that result in a variable called SUM. Can anyone explain why we store it instead of just displaying it immediately?
Because we might need to use it later or show it to the user!
Yes! That's the purpose of storing values until they are needed. Finally, how do we finish the algorithm?
We display the result and then stop!
Excellent! Gathering these steps together forms a complete algorithm.
So why is it important to have these defined steps?
To avoid mistakes while coding!
Correct! Writing it out clearly helps prevent errors.
To add two numbers, read then compute, display the result, then call it a hoot!
Imagine a baker who needs to measure ingredients. First, they read the quantities, then mix them, and finally present the delicious cake!
Remember the acronym 'RSA' - Read, Sum, and After (Display the result) to follow the steps of the algorithm.
SIMPLE: Start, Input, Math (calculate), Print (output), Last (stop), End.
Term
Algorithm
Click to flip
Term
Input
Click to flip
Term
Output
Click to flip
Term
SUM
Click to flip
A step-by-step procedure or formula for solving a problem.
Data received by a program for processing.
The data produced by a program after processing input.
An operation that transforms input into output.
A variable used to store the result of an addition operation.
This section presents a simple algorithm for calculating the sum of two numbers, illustrating the step-by-step approach to problem-solving in programming.
In this section, we explore a practical example of an algorithm used to find the sum of two numbers. We outline each step of the algorithm clearly, demonstrating its structure and effectiveness for solving the problem, which is a fundamental aspect of programming.
This section provides a clear example of an algorithm by presenting the problem of calculating the sum of two numbers. An algorithm is defined as a step-by-step procedure to solve a problem; in this case, the algorithm consists of six specific steps that begin with reading two numbers and end with displaying their sum.
SUM before displaying the result.This example serves to illustrate the structure and clarity needed in algorithms as a foundational aspect of programming.