Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

LECTURE – 01

CSE 2201
Algorithm Analysis and Design

REFERENCE BOOKS
1. Fundamentals of Computer Algorithms
By
Ellis Horowitz
Sartaj Sahni
Sanguthrvar Rajasekaran
2. Introduction of Algorithms
By
Thomas H Cormen
Charles E Leisersen
Cliford Stein
3. Algorithms in C++, parts 1-4 : Fundamental data structure, sorting,
searching (3rd edition)
By
Roserl Sedgearik
4. Beginning Algorithms (Wrox beginning guides)
By
Simon Harris
James Ross

LECTURE-01
Algorithm: An algorithm is a finite set of instructions that is followed to
accomplish a particular task.

In addition, all the algorithms must satisfy the following criteria:

1. INPUT: Zero or more quantities are externally supplied.


2. OUTPUT: At least one quantity is produced.
3. DEFINITENESS: Each instruction is clear and unambiguous.
4. FINITENESS: If we trace out the instructions of an algorithm, then for all
cases, the algorithm terminates often the finite number of steps.
5. EFFECTIVESNESS: Every instruction must be very basic so that it carried out
in principle.

The study of algorithm includes many important and active areas of research.
There are four distinct areas of study one can identify.

1. How to devise algorithms: Creating an algorithm is an art which may never


be automated study various design technique.
2. How to validate algorithms: Once an algorithm is devised, it’s necessary to
show that it computes the correct output for all possible legal inputs.
3. How to analyze algorithms: This field of study is called analysis of algorithm.
Analysis of algorithm performs in two ways:
• Time Complexity
• Space Complexity
4. How to test a program: Testing a program consists of two phases:
Debugging and Profiling (performance measurement).

Algorithm Max (A, n)


“A is an array of size n”
{
Result = A[i]
For i=2 to n do
If A[i] > Result then Result =A[i]
Return;
Result;
}
PERFORMANCE ANALYSIS: Develop skill for making evaluative judgements
about algorithms. Performance analysis is the priori estimate that is applied
after developing the algorithm.

1. Does it do what we want it to do?


2. Does it work correctly according to original specifications of the
task?
3. Are there documentation that describes how to use it and how it
works?
4. Are procedures created in such a way that they perform logical
submission?
5. It the code readable?
There are other criteria for judging algorithms that have a more direct
relationship of performance. These have to do with their computing time
and storage requirements.
• Space Complexity: The space complexity of an algorithm is the amount
of space needed to run to completion.
• Time Complexity: The time complexity of an algorithm is the amount
of computing time it needed to run to completion.
Performance evaluation can be loosely divided into two major phases:
1. Priori Estimates Performance analysis
2. Posterior Estimates/ testing performance measurement

EXAMPLE: Space complexity:


Algorithm abc(a, b, c)
{s (p) = 3(a, b, c) return a+b+b+c+(a+b+c)/(a+b)+4.0}
Sum compute is ∑𝑛𝑖=1 𝑎[𝑖]
Rsum ∑𝑛𝑖=1 𝑎[𝑖]
The space needed by each of these algorithms is seen to be the sum of the
following components.
1. A fixed part is independent of characteristics number, size of inputs and
outputs.
➔ Instruction space (space for the code) byte code
➔ Space for simple variables
➔ Fixed size components variables
➔ Space for constants

2. A variable part that consists of the space needed by compounds variables


whose size is dependent on the particular problem instance being solved.
➔ The referenced variable Sp(instance)
➔ The recursion stack

You might also like