Join Regular Classroom : Visit ClassroomTech

Introduction to Algorithm – CodeWindow.in

What is Algorithm?

An algorithm is a finite set of instructions that if followed accomplishes a particular task. In other word, an algorithm is any well defined computational procedure that transforms some value or set of values i.e. “Input” into some value or set of values i.e. “Output”.

Criteria of an Algorithm

a) Input : Zero or more Quantities

b) Output: At least one quantity is produced.

c) Definiteness: Each instruction is clear and unambiguous.

d) Finiteness: The algorithm must terminate after a finite number of steps.

e) Effectiveness: Every instruction must be very basic and feasible.

An algorithm can be represented by-

  1. Languages (Like English)

  2. Flow Charts

  3. Pseudo Code (C, Pascal etc.)

An algorithm has two parts:

a) Heading: Algorithm name (<Parameter List>)

b) Body: Statements enclosed within braces { }. An algorithm may or may not return a value.

From  the data structure point of view, following are the some important categories of algorithms:

a) Search : Algorithm to search an item in a data structure.
b) Sort : Algorithm to sort items in a certain order.
c) Insert: Algorithm to insert item in a data structure.
d) Update: Algorithm to update an existing item in a data structure.
e) Delete : Algorithm to delete an existing item from a data structure.

Notation of Algorithm used in Pseudo Code

  1. Comments begin with // and continue until end of line. For multiple line comment use /* ……..*/

  2. Blocks are indicated by matching braces { }. and statements are terminated by semi-colon(;). Semi-colon is known as Statement Terminator.

  3.  An identifiers begins with a letter. The data types of variables are not implicitly declared.

  4. Asignment of values to variables is done as <variable>:<expression>;

  5. Logical operators ‘and’, ‘or’, ‘not’, and relational operators <, <=, =, > are provided.

  6. Elements of multi-dimensional arrays are accessed using [ and ] as example, Arr[i,j] – the (i,j) th element of the array Arr.

  7. Conditional statement from : if <condition> then <statement> and if <condition> then <statement> else <statement>

  8. Input and output are done using the instructions “read” and “write” respectively.

  9. While: while<condition>do {…………}

  10. For: for variable := value1 to value2 step do {…………}

Recent Posts