What is an Algorithm


An algorithm is a set of step by step instructions for solving a problem to achieve a result.

Important charecteristics of an algorithm

  • An algorithm is well orderd
  • An algorithm has unambiguous operations
  • An algorithm has effectively computable operations
  • An algorithm produces a result
  • An algorithm halts in a finite amount of time

Representation of Algorithms


Flow charts

Example 01


Example 02


Write an algorithm for adding all even numbers between 2 and 1000 to sum Even numbers

  • Initialize Sum-of-even numbers
  • Initialize an index
  • Repeat Until index is 1000
  • Increment the index by 2;
  • Add index to sum-of-even-numbers

In Pseudo code


Sum-of -Even-numbers=0

Number=0

Repeat

Number=Number+2

Sum-of-Even-numbers=Sum-of-Even-numbers +Number

Util Number==10

Design a site like this with WordPress.com
Get started