Page 43 - TP_iPlus_V2.1_Class8
P. 43
i + CHARACTERISTICS OF A GOOD ALGORITHM
The main characteristics of a good algorithm are:
• Precision: Each step is precisely defined.
• Uniqueness: Result of each step should be uniquely identified and only depend on the result
of the preceding step.
• Finiteness: It should stop after a finite number of instructions are executed.
• Well-Defined Input: The input to an algorithm must be clearly specified and precisely defined.
• Well-Defined Output: The output produced by the algorithm must also be clearly specified
and precisely defined.
• Effectiveness: The algorithm should be efficient in terms of time and space.
i + USES OF AN ALGORITHM
Algorithm is commonly used for:
• Performing data processing • Performing computer and mathematical operations
• Manipulating data • Searching for a particular data
• Algorithms make decision-making more consistent and efficient.
i + WRITING AN ALGORITHM
Writing an algorithm is a crucial step in problem-solving and programming, as it aids in planning
and visualising the solution before it is translated into code. Creating an algorithm requires
creative thinking to determine the most effective way to sequence steps to achieve the desired
outcome. For example,
A. Algorithm to find product, sum and difference of two numbers.
Step 1 Start.
Step 2 Read two numbers and store them in A and B.
Step 3 Multiply two numbers A and B and store the result in Product.
Step 4 Print the product.
Step 5 Add two numbers A and B and store the result in Sum.
Step 6 Print the sum.
Step 7 Subtract the number B from the number A store the result in Difference.
Step 8 Print the Difference.
Step 9 Stop.
B. Algorithm to compare two numbers A and B.
Step 1 Start.
Step 2 Read two numbers and store them in A and B.
Step 3 Compare number A and B. If A is less than B, print "A is smallest" and go to Step 5.
Step 4 Compare number A and B. If B is less than A, print "B is smallest" and go to Step 5.
Step 5 Stop.
C. Making a cup of tea.
Step 1 Start.
Step 2 Collect kettle, teabags, water, milk, sugar, cup.
41
Algorithms and Flowcharts

