Advanced Algorithm Analysis: Lecture # 02
Advanced Algorithm Analysis: Lecture # 02
Analysis
Lecture # 02
05/24/17 1
Previous Lecture
Introduction to Course
Diagnostic Quiz
05/24/17 2
Todays Lecture
Algorithm
Use of Algorithms
Algorithm Designing
Algorithm Analysis
Experimental proof of efficiency of an
Algorithm
*Mathematical Approach
Assignment 01
05/24/17 3
Algorithm
Problem Statement
Relationship b/w input and output
Algorithm
Procedure to achieve the relationship
Definition
A sequence of computational steps which
transform the input to output
Instance
The input needed to compute solution
Correct Algorithm
for every input it halts with correct output
05/24/17 4
Use of Algorithms
Human Genome Project
Internet
Electronic Commerce
Manufacturing & Commercial Setting
Communication Links (Graph)
Matrix Multiplication
Proof of equation
05/24/17 5
Algorithms Design
Design
DataStructure
Techniques
Hard Problems
05/24/17 6
Algorithms Analysis
Efficiency
Speed
Memory
Bench Marks
05/24/17 7
Running Time to Sort Array of 2000 Integers
Supercomputer 0.087
05/24/17 8
Comparison
Array Size Home Desktop
Comp Comp
125 12.5 2.8
250 49.3 11.0
500 195.8 43.4
1000 780.3 172.9
2000 3114.9 690.5
05/24/17 9
Graphical Comparison
1000
f2(n)
05/24/17 10
Analysis of Results
f(n) = a n2 + b n + c
where a = 0.0001724, b = 0.0004 and c = 0.1
n f(n) a n2 % of n2
125 2.8 2.7 94.7
250 11.0 10.8 98.2
500 43.4 43.1 99.3
1000 172.9 172.4 99.7
2000 690.5 689.6 99.9
05/24/17 11
Complexity Classes
Adjective O-Notation
Classes
Constant O(1)
Logarithmic O(log n)
Linear O(n)
n log n O(n log n)
Quadratic O(n2)
Cubic O(n3)
Exponential O(2n)
Exponential O(10n)
05/24/17 12
Complexity Method Name
05/24/17 13
Running Time
2 n
4 65.5 3.7*1063 5.7*10294 2.1*1031563
(Year)
(Yrs)
05/24/17 14
Insertion Sort
05/24/17 15
Insertion Sort
05/24/17 16
Insertion Sort
05/24/17 17
Insertion Sort
05/24/17 18
Selection Sort
Void Selection (Input Array A)
intMinPos, temp, i, j;
for(i = n-1; i > 0; i--)
MinPos = i;
for ( j = 0; j < i; j++)
A[ MinPos ] = temp;
05/24/17 19
Lecture Summary
Algorithm
Use of Algorithms
Algorithm Designing
Algorithm Analysis
Experimental proof of efficiency of an
Algorithm
*Mathematical Approach
Assignment 01
05/24/17 20