Page 41 - IT_V5.0_Class7
P. 41

Two powerful tools that help in problem-solving are algorithm and flowchart. Let us discuss
                 these in detail.

                    ALGORITHM

                 An algorithm may be defined as “a step-by-step procedure or set of rules to follow in order to
                 solve a specific problem or perform a task.”

                 In computers, an algorithm may be defined as “a step-by-step process that converts the given
                 input into a desired output.”
                 There may be more than one way to solve any problem, so there may be more than one algorithm
                 for a given problem. It is important in computer programming because it provides a systematic
                 way to identify and solve problems efficiently. Once we have an algorithm, we can translate it
                 into a computer program in any programming language.
                        Boost Bits


                  The term “algorithm” originates from the name of the 9th-century Persian mathematician
                  Al-Khwarizmi, whose work laid the foundation for modern algebra and algorithmic thinking.



                 Basic Guidelines to Follow While Writing an Algorithm

                 There are no well-defined rules and standards for writing an algorithm.
                 Some of the basic guidelines that we can follow while writing an algorithm are as follows:

                    It begins with the keyword "Start" and ends with "Stop".
                    It is written in simple, case-insensitive English-like statements.
                    IT is presented in a step-by-step, with or without numbering.
                    It should follows a logical flow: input à process à output.
                    It must terminates after a finite number of steps.

                 Advantages of an Algorithm

                 The advantages of an algorithm are as follows:
                    It is a step-by-step representation of a solution to a given problem.
                    It uses simple English-like statements so that it is easy to understand and write.
                    The problem is broken down into smaller pieces; hence, it is easy to convert it into a program
                    using any programming language.

                 Writing Algorithms

                 Algorithm 1: Write an algorithm for preparing a sandwich.

                 Step 1:  Start
                 Step 2:   Collect bread slices, butter, vegetables (lettuce, tomatoes, cucumbers), cheese, and a knife.
                 Step 3:  Spread butter evenly on one side of each bread slice.

                 Step 4:  Place vegetables and cheese on one slice of bread.
                 Step 5:  Cover with the other slice, buttered side facing in.




                                                                                       Algorithm and Flowchart   39
   36   37   38   39   40   41   42   43   44   45   46