Page 69 - Digicode_AI_class_6
P. 69

In our daily life, we have to solve various problems by using different strategies. These strategies
            are called problem-solving techniques. Some of these techniques are algorithms and mind maps.

            Algorithm

            An algorithm is a set of steps in a sequential manner to solve a problem or to complete a task.
            These steps are the foundation to a program. They are important to programming as recipes are for
            cooking.

            Writing an Algorithm

            The construction of the Algorithm is the stage which requires creative thinking and finding the best
            possible combination of steps to get the result. For example,
            Example 1: Algorithm for going to the market to purchase a pen

             Step 1   Start.

             Step 2   Go to the market.

             Step 3   Check your wallet for cash.

             Step 4   Go to the stationery shop.

             Step 5   Ask for your favourite pen.

             Step 6   If pen is available, then go to step 7 otherwise go to step 10.

             Step 7   Give money to the shopkeeper.

             Step 8   Keep the purchased pen safely.

             Step 9   Go back home and go to Step 12.

             Step 10  Ask for any other brand of pen.

             Step 11   Go to step 6.

             Step 12   End.


            Example 2: Complete the algorithm to find sum and product of three numbers.
             Step 1   Start.

             Step 2   Read (Input) the three number as "a","b","c" from the user.

             Step 3   Find sum = a + b + c.

             Step 4   Find product = a × b × c.
                                                                             When we search anything on
             Step 5   Print sum and product.
                                                                          Google, it gives us result based on
             Step 6   End.                                                    an algorithm written for it.






                                                                                 Algorithmic Intelligence  67
   64   65   66   67   68   69   70   71   72   73   74