 # 12.02 Solve problems using an algorithm

Lesson

## Ideas

Do you know how to use an algorithm to describe a set of steps? Try this one.

### Examples

#### Example 1

We want to order these three digit numbers from smallest to largest by following the algorithm below:

705, \,281, \,106

1. Order the numbers from the lowest to highest hundreds digit.

2. Is there more than one number with the same hundreds digit?

• If no - STOP

• If yes - Order them from the lowest to highest tens digit.

3. Is there more than one number with the same hundreds and tens digits?

• If no - STOP

• If yes - Order them from the lowest to highest units digit.

4. STOP

a

List the hundreds digit of each number from smallest to largest.

Worked Solution
Create a strategy

Write the numbers in a place value table.

Apply the idea

Here are the numbers in a place value table:

Looking at the hundreds, we can see that the hundreds digits in order from lowest to highest are: 1, \,2, \,7.

b

Will the algorithm STOP at step 2?

Worked Solution
Create a strategy

Use the answer from part (a) to follow step 2 of the algoritm.

Apply the idea

Step 2 tells us to STOP if there is not more than one number with the same hundreds digit.

The hundreds digits from part (a) are all different: 1,2,7. So, the algorithm will STOP at step 2.

c

Using your answers above, put the numbers 705,281, and 106 in order from smallest to largest.

Worked Solution
Create a strategy

Write the numbers according to the list of hundreds from part (a).

Apply the idea

Step 1 tells us that we should write the numbers in order of their hundreds digits from lowest to highest:

106, \,281, \,705

Idea summary

It's important when following algorithms to do each step one at a time and in order, this is the same as how computers read code.

## Solve problems with algorithms

This video explores an example of an algorithm that is used to both setup and solve a problem.

### Examples

#### Example 2

We are going to subtract these two numbers, using the subtraction algorithm below:

91-26

1. Is the units digit of the first number less than the units digit of the second number?

• If no - GO TO step 2.

• If yes - regroup the tens from the first number to give a ten to the units, then GO TO step 2.

2. Subtract the units of the second number from the units of the first number.

3. Subtract the tens of the second number from the remaining tens of the first number.

4. Write the final answer by adding the results of steps 2 and 3.

a

Fill in the blanks below:

The units digit of the first number is .

The units digit of the second number is .

Worked Solution
Create a strategy

Write the numbers in a place value table.

Apply the idea

Here are 91 and 26 in a place value table:

The units digit of the first number is 1.

The units digit of the second number is 6.

b

What do we need to do at step 1?

Worked Solution
Create a strategy

Use the answers from part (a).

Apply the idea

Since 1 \lt 6, we need to regroup the tens from the first number, 91, to give a ten to the units, then GO TO step 2.

c

Fill in the blanks below:

We can regroup the tens part of 91 as 90=⬚+10, in order to give 10 to the units part, which will become 1+10=⬚.

Worked Solution
Create a strategy

For the first blank, subtract 10 from the tens value of the first number.

For the second blank, evaluate the number sentence.

Apply the idea

The tens value of 91 is 90. So, 90-10=80.

We can regroup the tens part of 91 as 90=80+10, in order to give 10 to the units part, which will become 1+10=11.

d

Complete step 2: Subtract the units of the second number from the units of the first number.

Worked Solution
Create a strategy

The units of the first number is the result from part (c).

Apply the idea

The units of the first number is now 11 and the units of the second number is 6.

e

Complete step 3: Subtract the tens of the second number from the remaining tens of the first number.

Worked Solution
Create a strategy

The tens of the first number is the tens found from part (c).

Apply the idea

The tens of the first number is now 80 since we moved 10 to the units. The tens value of 26 is 20.

f

Complete step 4: Write the final answer by adding the results of steps 2 and 3.

Worked Solution
Create a strategy

Add the tens found in part (e) to the units found in part (d).

Apply the idea
Idea summary

We can use algorithms to add or subtract numbers.