Representing Algorithms
Understand and explain the terms:
- algorithm
- decomposition
- abstraction
Algorithm
Write down the steps needed to make a cup of coffee.
- Fill the kettle with water
- Turn the kettle on
- While the kettle is boiling
- Get a cup
- Get a teaspoon
- Get the coffee
- Put 1 tsp of coffee in the cup
- 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
- Make a cup of coffee.
- Fill the kettle with water
- Turn the kettle on
- While the kettle is boiling
- Get a cup
- Get a teaspoon
- Get the coffee
- Put 1 tsp of coffee in the cup
- When the kettle has boiled pour the water into the cup
- Boil water
- Put coffee in the cup
- Pour water in the cup
- Make a cup of coffee.
- Fill the kettle with water
- Turn the kettle on
- While the kettle is boiling
- Get a cup
- Get a teaspoon
- Get the coffee
- Put 1 tsp of coffee in the cup
- When the kettle has boiled pour the water into the cup
- Boil water
- Put coffee in the cup
- Pour water in the cup
Decomposition
- Make a cup of coffee.
- Fill the kettle with water
- Turn the kettle on
- While the kettle is boiling
- Get a cup
- Get a teaspoon
- Get the coffee
- Put 1 tsp of coffee in the cup
- When the kettle has boiled pour the water into the cup
- Boil water
- Put coffee in the cup
- 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
- Define the following terms
- Decomposition
- Abstraction
- 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.
- 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
- Define the following terms
- Decomposition
- 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
- 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
- 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