Algorithms

Algorithm

An Algorithm is defined as a set of steps for solving a particular problem in a finite amount of time. It is a good software engineering practice to design algorithms before we write a program.

Algorithm

Step 1: Start
Step 2: READ num1, num2
Step 3: result = num1+num2
Step 4: DISPLAY result
Step 5: Stop

Qualities of an Algorithm

  • Accuracy: Algorithm should provide accurate result
  • Memory: It should require minimum computer memory
  • Time: It should take finite amount of time.
  • Sequence: The procedure of an algorithm must be in sequential form

Characteristics/Properties of Algorithm

Input: All the algorithms should have some input. The logic of the algorithm should work on this input to give the desired result.
Finiteness: An algorithm must always terminate after a finite number of steps.
Definiteness: Every step of the algorithm should be clear and not any ambiguity.
Effectiveness: Every step in the algorithm should be easy to understand and can be implemented using any programming language.
Output: At least one output should be produced from the algorithm based on the input given.

Advantage

  • It is a stepwise description of a solution, which makes easy to understand.
  • It is not dependent on any programming language.
  • It is easier for programmer to convert into an actual program.

Disadvantage

  • It is difficult to show branching and looping statements.
  • It is time consuming, algorithm needs to be developed first which is then converted to program.

Youtube

Algorithm

References

  • Allen B. Downey, “Think Python: How to Think Like a Computer Scientist‘‘, 2nd edition, Updated for Python 3, Shroff/O‘Reilly Publishers, 2016 (http://greenteapress.com/wp/thinkpython/)
  • Guido van Rossum and Fred L. Drake Jr, ―An Introduction to Python – Revised and updated for Python 3.2, Network Theory Ltd., 2011.
  • John V Guttag, ―Introduction to Computation and Programming Using Python‘‘, Revised and expanded Edition, MIT Press , 2013
  • Robert Sedgewick, Kevin Wayne, Robert Dondero, ―Introduction to Programming in Python: An Inter-disciplinary Approach, Pearson India Education Services Pvt. Ltd., 2016.
  • Timothy A. Budd, ―Exploring Python‖, Mc-Graw Hill Education (India) Private Ltd.,, 2015. 4. Kenneth A. Lambert, ―Fundamentals of Python: First Programs‖, CENGAGE Learning, 2012.
  • Charles Dierbach, ―Introduction to Computer Science using Python: A Computational Problem-Solving Focus, Wiley India Edition, 2013.
  • Paul Gries, Jennifer Campbell and Jason Montojo, ―Practical Programming: An Introduction to Computer Science using Python 3‖, Second edition, Pragmatic Programmers, LLC, 2013.