Professional Documents
Culture Documents
Week 1 Lec 2
Week 1 Lec 2
History of Algorithm
Introduction of Algorithm
Types of Algorithms
In this algorithm, chosen values are used in such a way that the probability of chosen each value is
known and controlled.
Problem : Let a and b be strictly positive integers. Find the greatest common
divisor of a and b
Euclidean Method:
Compute r, the reminder obtained by dividing a by b
Replace a with b, b with r, and start the process again
The process continue until one obtains a reminder equal to zero
Then the previous reminder(which , obviously, is not zero) will be the gcd(a,b)
Correctness
Does the input/output relation match algorithm requirement?
• English
• American
• A la russe
• Divide and Conquer
Running Time
Average case time is often difficult to 80
determine. 60
Easier to analyze 20
composition 7000
6000
Use a method like System.currentTimeMillis() to get
Time (ms)
an accurate measure of the actual running time 5000
4000
Plot the results
3000
2000
1000
0
0 50 100
Friday, January 12, 2024
Lahore Garrison University
Algorithm
Analysis of
23
Input Size
Friday, January 12, 2024
Lahore Garrison University
Algorithm
Analysis of
24
25
Limitations of Experiments
FURTHER DISCUSSION
Q &A