What are algorithms?

An algorithm is a sequence of instructions or a set of rules to get something done. They can be found all around us in day to day life.

Discuss Discuss Discuss


Discuss Kōrero Mai: Where else can you find algorithms?


Here is a short video that explains algorithms

Comparing everyday tasks that humans do using algorithms and how an app uses algorithms in its program.


Discuss Algorithm - hātepe




What are algorithms in digital technologies?

If we want to tell a computer to do something, we have to write a computer program that will:

  • tell the computer, step-by-step, exactly what we want it to do, and
  • how we want it to do it.

This step-by-step program will need planning, and to do this we use an algorithm.

An algorithm is a sequence of instructions or a set of rules to get something done. Algorithms are written for a human, rather than for a computer to understand. In this way algorithms differ from programs.


To start to write an algorithm we need to know what the final output needs to be. We also need to decide on what inputs will trigger the output.


Think about a toaster as a technological system. Think about its inputs and outputs. What are the steps needed to create and eat some toast? Spend some time thinking about these questions and try to construct a list of steps in your mind.



Sequential instructions using decomposition

In the ‘draw toast’ task you have learned how to break a large task down into small bite size chunks and have thought about the logical sequence of instructions - what did you need to do first, second, third, etc. You may have noticed:

  • Although everyone’s drawings are all different, they are all fundamentally correct. There are many ways to decompose a problem and there is no real “right” or “wrong.”

  • The drawings may be different in content, they tend to be similar in structure. In the task the sequential instructions tend to contain three to seven drawings, connected by lines or arrows.

A sequence is a step by step a list of instructions that run in a logical order. No instruction will be skipped. Decomposition is breaking down a complex problem or system into smaller parts that are more manageable and easier to understand.


Exact Instruction Challenge


Discuss Kōrero Mai: How did the children use sequencing? How did they use decomposition? What happened when they had a problem?




Algorithms in digital technologies

Algorithms are often used as a starting point for creating a computer program, and they are sometimes written as a flowchart or in pseudocode. A simple program represented in pseudocode would look like this:

OUTPUT 'What is your name?'
	INPUT user inputs their name
	STORE the user's input in the name variable
	OUTPUT 'Hello' + name
	OUTPUT 'How old are you?'
	INPUT user inputs their age
	STORE the user's input in the age variable
	IF age >= 70 THEN
		OUTPUT 'You are aged to perfection!'
	ELSE
		OUTPUT 'You are a spring chicken!'

The same program represented in a flowchart would look like this.

Flowchart


What makes a successful algorithm?

  • Decomposing a large task and abstracting unnecessary elements
  • Sequencing tasks into steps
  • Understanding importance of the order of the steps
  • Recognising and using patterns
  • Using Iteration - repeats or loops
  • Debugging problems
Flowcharts Explained Flowcharts Descriptions




Test your knowledge!

Test your knowledge of this lesson and submit your response to show proof of completion.