CS-402 Introduction of Algorithm

You might also like

Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 16

Program: B.

Tech, Computer Science and Engineering, 4thSem,


2nd year
CS-402: ADA
Unit-I
Topic: Introduction of Algorithm

Jan –June, 2022-23


Lecture-2
Pankaj Sharma
Assistant Professor , Department of Computer Science and
Engineering
Overview
• What is Algorithm ?
• Difference between Algorithm and Program.
• Properties of Algorithm .
• Final Goal ?

CS-402
2
Prerequisite for the Subject
• Discrete Mathematics - sets, functions, relations.
• Basic probability.
• Basic knowledge of Data Structure.
• Basic knowledge of programming like C,C++,Java.

CS-402
3
What is Algorithm ?
• Algorithm is any well-define computational procedure that takes some value, or
set of values as input and produce some value or set of values as output.
• A sequence of computational steps that transfer input into the output.
• Ex:
• Problem:- Addition of two number
• Solution:- It may be in any language.

CS-402 <SELO: 1,3,5> <Reference No.: R1, R2> 4


Cont…
• Algorithm
• ADD ()
• {
• Read a;
• Read b;
• return (a+b);
• }
• This algorithm written in pseudo code which is independent from any language.

CS-402 <SELO: 1,3,5> <Reference No.: R1, R2> 5


Cont…

CS-402 <SELO: 1,3,5> <Reference No.: R1, R2> 6


Difference between Algorithm and Program
Algorithm Program
It is written at design time. It is written at implementation
time.

A person should have domain knowledge A programmer.


Ex:-An Accountant , Hospital Manager or it may
be a programmer
Written in any language. It must be in written in any
specific programming language.

Hardware and Software Independent Hardware and Software dependent

Analysis Testing

CS-402 <SELO: 1,3,5> <Reference No.: R1, R2> 7


Properties of Algorithm
• It should produce the output within the finite amount of time.
• It should be programming language independent.
• Every statement should be unambiguous.
• Means algorithm is correct.
• Ex:- If we make an algorithm to find even and odd number then it work for all.

CS-402 <SELO: 1,3,5> <Reference No.: R1, R2> 8


Cont…
• It should produce same output for a given input for any instance of time.
• Every step in the algorithm will be related to each other.
• If all the above properties are satisfied by algorithm the it is well defined.

CS-402 <SELO: 1,3,5> <Reference No.: R1, R2> 9


Question

CS-502 <SELO: 3,5> <Reference No.: R1, R2>


Cont…
• We can conclude the properties of algorithm as follows:-
• It must take input and produce output for it.
• Definitness.
• Finitness .
• Effectiveness.

CS-402 <SELO: 1,3,5> <Reference No.: R1, R2> 11


Cont…
• Finiteness: For any input, the algorithm must terminate after a finite number of
steps.
• Definiteness: All steps of the algorithm must be precisely defined.\
• Effectiveness: It must be possible to perform each step of the algorithm
correctly and in a finite amount of time

CS-402 <SELO: 1,3,5> <Reference No.: R1, R2> 12


Final Goal

CS-402 <SELO: 1,3,5> <Reference No.: R1, R2> 13


Question

CS-402 <SELO: 1,3,5> <Reference No.: R1, R2>


References

1. Coremen Thomas, Leiserson CE, Rivest RL; Introduction to Algorithms; PHI


2. Horowitz & Sahani; Analysis & Design of Algorithm
3. Dasgupta; algorithms; TMH
4. Ullmann; Analysis & Design of Algorithm;
5. Michael T Goodrich, Robarto Tamassia, Algorithm Design, Wiely India
6. Rajesh K Shukla: Analysis and Design of Algorithms: A Beginner's Approach;
Wiley

CS-402
15
CS-402
16

You might also like