Algorithm
Algorithm
Objectives:
- Writing basic solution procedure to problems
- Ordering solution steps
Lesson : Introductive Activity; Cook recipe INTRODUCTION
Algorithm is a part of our daily life. We accomplish any task by following an algorithm. For example
making a cake, Computing rectangle surface.
Computer science is based in programs or applications whose execution can be summarized as:
problem posed – analysis – algorithm – program – compilation – execution.
An Algorithm is a well-defined step by steps instructions specifying how to complete a task.
1 DEFINITION
An algorithm is a well-defined set of step-by-step instructions for solving a problem in a finite
amount of time. A set of instructions is not an algorithm if there is no definite stopping place, or if
the instructions are too vague to be followed clearly. An algorithm cannot be directly executed by a
computer, but it has to be translated into a program using a programming language.
2 CHARACTERISTICS OF A GOOD ALGORITHM A good algorithm:
RECIPE
- 1 lemon- 1 orange- 1 pineapple- 1 litter of water- 3 eating spoon
INGREDIENTS (inputs)
of sugar- 1 eating spoon of grated ginger
- Wash lemon and orange- Cut them into small pieces and put
COOKING(set of them to the fridge- Peel the pineapple and cut them into small
instructions) pieces- Mix the pieces of lemon, orange, pineapple, water, grated
(processes) ginger;- Grind them- Sleeve it to extract the juice- Then put the
juice into the fridge
EXERCISE: write and algorithm to make a cup of tea Solution: Algorithm Making _ a_cup_ of_ tea
Inputs: Sugar, water, ovaltin, milk, fire Set of instructions:
1- Prepare the Fire