Representing Algorithms

Understand and explain the terms:

  • algorithm
  • decomposition
  • abstraction

Algorithm

Write down the steps needed to make a cup of coffee.

  1. Fill the kettle with water
  2. Turn the kettle on
  3. While the kettle is boiling
  4. Get a cup
  5. Get a teaspoon
  6. Get the coffee
  7. Put 1 tsp of coffee in the cup
  8. When the kettle has boiled pour the water into the cup

Algorithm

An algorithm is a set of instructions that, when followed, complete a task. 

All computer programs are algorithms.

Not all algorithms are programs.

Decomposition

  • Breaking a problem into a number of sub-problems,
  • so that each sub-problem performs an identifiable task,
  • which might itself be further subdivided.

Decomposition

  1. Make a cup of coffee.
  1. Fill the kettle with water
  2. Turn the kettle on
  3. While the kettle is boiling
  4. Get a cup
  5. Get a teaspoon
  6. Get the coffee
  7. Put 1 tsp of coffee in the cup
  8. When the kettle has boiled pour the water into the cup
  1. Boil water
  2. Put coffee in the cup
  3. Pour water in the cup
  1. Make a cup of coffee.
  1. Fill the kettle with water
  2. Turn the kettle on
  3. While the kettle is boiling
  4. Get a cup
  5. Get a teaspoon
  6. Get the coffee
  7. Put 1 tsp of coffee in the cup
  8. When the kettle has boiled pour the water into the cup
  1. Boil water
  2. Put coffee in the cup
  3. Pour water in the cup

Decomposition

  1. Make a cup of coffee.
  1. Fill the kettle with water
  2. Turn the kettle on
  3. While the kettle is boiling
  4. Get a cup
  5. Get a teaspoon
  6. Get the coffee
  7. Put 1 tsp of coffee in the cup
  8. When the kettle has boiled pour the water into the cup
  1. Boil water
  2. Put coffee in the cup
  3. Pour water in the cup

Decomposition

Abstraction

Walk into the kitchen and up to the kettle. Pick up the kettle, open the lid and take the kettle to the sink. Position the kettle under the cold tap and turn on the tap, remembering not to allow the kettle to overfill. When there is enough water in the kettle, turn off the tap and place the kettle back where it belongs. Turn on the kettle and wonder why I am writing all this information down...

Abstraction

Abstraction is the process of removing unnecessary detail from a problem.

Abstraction

Walk into the kitchen and up to the kettle. Pick up the kettle, open the lid and take the kettle to the sink. Position the kettle under the cold tap and turn on the tap, remembering not to allow the kettle to overfill. When there is enough water in the kettle, turn off the tap and place the kettle back where it belongs. Turn on the kettle and wonder why I am writing all this information down...

Abstraction

Walk into the kitchen and up to the kettle. Pick up the kettle, open the lid and take the kettle to the sink. Position the kettle under the cold tap and turn on the tap, remembering not to allow the kettle to overfill. When there is enough water in the kettle, turn off the tap and place the kettle back where it belongs. Turn on the kettle and wonder why I am writing all this information down...

Abstraction

Walk into the kitchen and up to the kettle. Pick up the kettle, open the lid and take the kettle to the sink. Position the kettle under the cold tap and turn on the tap, remembering not to allow the kettle to overfill. When there is enough water in the kettle, turn off the tap and place the kettle back where it belongs. Turn on the kettle and wonder why I am writing all this information down...

Abstraction

Walk into the kitchen and up to the kettle. Pick up the kettle, open the lid and take the kettle to the sink. Position the kettle under the cold tap and turn on the tap, remembering not to allow the kettle to overfill. When there is enough water in the kettle, turn off the tap and place the kettle back where it belongs. Turn on the kettle and wonder why I am writing all this information down...

Abstraction

Walk into the kitchen and up to the kettle. Pick up the kettle, open the lid and take the kettle to the sink. Position the kettle under the cold tap and turn on the tap, remembering not to allow the kettle to overfill. When there is enough water in the kettle, turn off the tap and place the kettle back where it belongs. Turn on the kettle and wonder why I am writing all this information down...

Abstraction

Walk into the kitchen and up to the kettle. Pick up the kettle, open the lid and take the kettle to the sink. Position the kettle under the cold tap and turn on the tap, remembering not to allow the kettle to overfill. When there is enough water in the kettle, turn off the tap and place the kettle back where it belongs. Turn on the kettle and wonder why I am writing all this information down...

Questions

  1. Define the following terms
    1. Decomposition
    2. Abstraction
  1. A programmer is creating software to send and receive encrypted messages via email. Describe how decomposition can be used to allow this problem to be solved.
  1. A chess club develops a system to store details about games played. For each game, the winner's and loser's names are stored alongside the date that the game was played. Explain how abstraction has been used in the development of this system.

Answers

  1. Define the following terms
    1. Decomposition
    2. Abstraction
  • Decomposition is breaking a problem down into smaller sub-problems.
  • Once each sub-problem is small and simple enough, it can be tackled individually.
  • Abstraction is removing or hiding unnecessary details from a problem, so that the important details can be focused on.

Answers

  1. A programmer is creating software to send and receive encrypted messages via email. Describe how decomposition can be used to allow this problem to be solved.
  • Create the text for the message
  • Choose the encryption method
  • Generate or select the key
  • Send the encrypted text
  • Share the key
  • Decrypt the text

Answers

  1. A chess club develops a system to store details about games played. For each game, the winner's and loser's names are stored alongside the date that the game was played. Explain how abstraction has been used in the development of this system.
  • The details of the game are removed
  • The players details are limited to the name
  • Winner and loser are identified without further information
  • No ranking is involved

1a Representing Algorithms I

By David James

1a Representing Algorithms I

Computer Science - Fundamentals of Algorithms - Representing Algorithms

  • 441