成人快手

What is an algorithm?

An algorithm is a set of instructions or rules for completing a task or solving a problem.

We use algorithms to help plan and organise the steps needed to complete many different types of tasks.

Back to top

Types of algorithms

Some examples of these tasks include:

  • navigating to unfamiliar locations using directions
  • developing new skills and techniques
  • learning to speak and write a new language
  • understanding the rules for sports and games
  • writing a program to control a computer-controlled device or system
  • organising internet search results by order of importance
Back to top

Solving problems in the real world

Let's say we have a building with an entrance doorway in a busy public street. We only want people who work in that building to be able to open the doors and enter the building.

The doors are part of a computer system that has several parts, such as:

  • doors with a lock
  • a key card reader
  • a key card with the correct code
  • a

We need to create a computer to control the system and only let in people who have the correct key card.

Before we can write the program, we need to break down or the problem into smaller steps and create an algorithm.

Back to top

Using a flowchart to organise the steps

An algorithm will help us decide on the steps we need and the order we need to put them in.

Let's use a flowchart diagram to help us organise our instructions.

  • At the start, we want the door to be locked.
  • When someone uses a key card in the door lock, we want the computer processor inside the lock to check the key card and see it if has the correct code.
  • If the answer is yes then the light should flash green and the door will unlock.
  • If the answer is no then the light should flash red and the door should stay locked.
Algorithm flowchart showing program for door with key card. Step one: Door locked. Step two: Is the key card code correct? If yes step three: open the door. If no step three: keep the door locked. Step four: End.

By writing our instructions for the door lock down as an algorithm, we can check our instructions are correct and in the right order.

We can then write the computer program to use in the door lock computer system.

Can you see any problems with this algorithm?

Back to top

Using algorithms to check for errors in a program

Sometimes our computer program doesn't produce the outcome we want.

We call a mistake in a computer program a bug.

In our door example, staff notice that once the first person had used the system, the door stayed open and anyone could come into the building.

One of the ways we can find and fix bugs is to go back to the original algorithm and see if we made a mistake in the steps, or the sequence we arranged them in.

We can check our algorithm to remind us what we planned to happen and then think about what actually happened.

Can you see what the problem is by looking at the original algorithm flowchart?

Back to top

Algorithms inside computer systems

Algorithms can also be used inside computer programs and systems to make choices and organise information.

These algorithms are called .

Machine learning algorithms contain sets of rules that tell the computer program how to behave when it receives different types of data.

It can learn how to predict what will happen or decide what to do based on all of the data it receives.

The more data it gets, the better it works.

How did it know I wanted one of those?

These machine learning algorithms can help a social media platform to choose adverts based on the things you look at on the internet.

It applies the many rules from the algorithm to your data and learns the things you like to do.

You will then tend to mainly see adverts for the things you are interested in.

A search engine algorithm has hundreds of rules that organise the data it has collected about different websites. This helps it decide what order to list the search results in.

The algorithm makes sure that only the most popular and relevant websites go to the top of the search results list.

Back to top

Watch: Algorithms

You can find out more about algorithms in this video from 成人快手 Teach

Back to top
Back to top

Computing - Dance Mat Typing. game

Build and test your computing skills with different levels of touch type challenges

Computing - Dance Mat Typing
Back to top

More on Computer science

Find out more by working through a topic