Page 42 - iPlus_Ver_2.0_class_8
P. 42

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.
                  •  Input: It should have well-defined input.

                  •  Output: It should have well-defined output.
                  •  Effective: It is measured 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
                  The construction of the Algorithm is the stage that requires creative thinking and finding the
                  best possible combination of steps to get the result. 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.
                      Step 4    Print the product.

                      Step 5   Add two numbers A and B.
                      Step 6   Print the sum.
                      Step 7   Subtract the number B from the number A.
                      Step 8   Print the difference.
                      Step 9   Stop.
                  B.  Algorithm to find the smallest in 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.


                    40
                         iPlus (Ver. 2.0)-VIII
   37   38   39   40   41   42   43   44   45   46   47