Page 106 - Computer science 868 Class 12
P. 106

3.3.3 Purpose of Writing an Algorithm
              An algorithm is written with the following purposes:
              •  An algorithm improves the overall efficiency of a program.
              •  Every step in an algorithm follows a logical sequence, so it helps in program development and debugging.

              •  An algorithm provides a proper understanding of the input requirement, output format and flow of the process.
              •  An algorithm measures the performance of the methods in different cases (i.e., best case, worst case and average
                 case).
              •  An algorithm also reduces the cost of design.

              3.3.4 Disadvantages of an Algorithm
              Some of the disadvantages of using an algorithm are:
              •  Developing an algorithm is a time-consuming process.
              •  Complex algorithms are very difficult to design and understand.

              •  There is no definite industry standard for writing an algorithm.
              •  It is difficult to design branching and looping procedures in an algorithm.

              3.3.5 Properties of a good Algorithm
              An effective and efficient algorithm must have the following properties:
              •  Accuracy: Algorithm must provide the correct solution to a given problem in an unambiguous manner.
              •  Finiteness: Algorithms must produce correct output after a finite number of steps and terminate after that.
              •  Input: An algorithm must receive zero or more inputs in a specified format.
              •  Output: An algorithm must produce one or more outputs in a specified format.
              •  Language independence: An algorithm must be language-independent, which means that the instructions when
                 coded in any programming language will produce the same result.
              •  Effectiveness: Each instruction in an algorithm should be adequate and will eventually provide the correct solution
                 to the problem.
              •  Memory: Multiple algorithms may provide the correct solution to a given problem, but the one which utilises less
                 memory is better.
              •  Time: Lesser the time taken to produce the correct output to a problem, the better the algorithm.


                   3.4 COMPUTATIONAL COMPLEXITY AND BIG O NOTATION
              This topic will be covered in detail later in this book. In this section, an introduction of Computational complexity is
              given for better analysing of an algorithm.

              We know that there are multiple ways of deriving a solution to a problem. So, the same problem may have different
              correct algorithms, all giving the output. Thus, all the algorithms are effective. However, an efficient algorithm is one
              that produces the correct output in minimum time and utilises less memory space.
              We can thus conclude that for the same size of the input, an algorithm that performs the task in the smallest number of
              operations is considered the most efficient one. Besides this, the efficiency of an algorithm depends on the following
              two factors:
              •  Space factor: It is measured by calculating the maximum memory space required by an algorithm. The algorithm
                 that utilises the least memory is considered the best one.
              •  Time factor: It is the total time taken by an algorithm to execute each step with respect to its input size. The
                 algorithm that performs the task in the least number of steps is considered the most efficient one.



                104104  Touchpad Computer Science-XII
   101   102   103   104   105   106   107   108   109   110   111