Basic HTML Version

|  | Table of Contents |  | View Full Version

Page 66 - 2615_KEC
P. 66

    Uniqueness: The result of each step can be uniquely identified and only depends on the result
                        of the preceding step.

                         Finiteness: It stops 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.

                      USES OF AN ALGORITHM
                      An algorithm is mainly used for:                                  Just as a peacock’s call can
                                                                                       signal upcoming rain, computer
                         Performing data processing
                                                                                        algorithms can predict future
                         Performing logical and mathematical operations                events based on data patterns.
                         Manipulating data

                         Searching for a particular data

                                WRITING AN ALGORITHM

                      Algorithm provides a step-by-step solution to the problem. Let’s write an algorithm for some
                      problems.

                      MAKING A CUP OF TEA
                      Step  1   Start.

                      Step  2    Collect Kettle, Teabags, water, milk, sugar and cup.

                      Step  3   Boil the water in the kettle.
                      Step  4   Pour the boiling water into the cup.

                      Step  5    Add milk, sugar and put a teabag in the cup.
                      Step  6   Stir the tea, and the tea is ready.

                      Step  7   Stop.

                      CALCULATE THE SUM OF TWO NUMBERS
                      Step  1   Start.

                      Step  2    Read two numbers and store them in A and B.

                      Step  3   Add two numbers A and B.

                       64   Premium Edition-VI

| 61 62 63 64 65 66 67 68 69 70 71 |