Presentation is loading. Please wait.

Presentation is loading. Please wait.

Introduction to The Design & Analysis of Algorithms

Similar presentations


Presentation on theme: "Introduction to The Design & Analysis of Algorithms"— Presentation transcript:

1 Introduction to The Design & Analysis of Algorithms
Lecture:Hao Wu Mobil:

2 Contents Introduction
Fundamentals of the Analysis of Algorithm Efficiency Brute Force Divide-and-Conquer Decrease-and-conquer Transform-and-conquer

3 Contents(continuous)
Space and Time Tradeoffs Dynamic Programming Greedy Technique Limitations of Algorithm Power Coping with Limitations of Algorithm Power

4 Introduction Notion of Algorithm
Fundamentals of Algorithmic Problem Solving Important Problem Types Fundamental Data Structures

5 Notion of Algorithm An algorithm is a sequence unambiguous instructions for solving problem,i.e.,for obtaining a required output for any legitimate input in a finite amount of time.

6 Euclid algorithm Step 1: If n=0,return the value of m. otherwise proceed to Step 2. Step 2: r=m%n Step 3:m← n,n← r. Go to step 1; m,n,r1,r2,……rk,0 m,n>r1 >r2,……>rk>0 rk = GCD(m,n)=GCD(n,r1)=….

7 Consecutive integer checking algorithm(pseudocode)
t ←min(m,n) While(m%t||n%t) --t; Return t;

8 Middle school procedure for computing gcd(m,n)
Step 1:Find the prime factors of m; Step 2:Find the prime factors of n; Step 3:Find the common factor(s). p1≤p2≤p3≤p4… Gcd(m,n)= p1*p2*p3*p4…

9 Algorithm for finding the list of primes not exceeding n
p is a prime,2p,3p,…,kp are not primes. …(p=2) …(p=3) If n<p2,and is not a prime,not remain on the list on the earlier passes.

10 Algorithm Sieve(n) //Implements the sieve of Eratosthenes
//Input :A positive integer //Output:Array L of all prime numbers ≤n For p=2 to n do a[p]=p For p=2 to sqrt(n) do if a[p] is a prime j=p*p while j ≤n do a[j]=0 j=j+p for p=2 to n do l[i]=p i=i+1 Return L

11 Fundamentals of Algorithmic Problem Solving
Choosing between exact and approximate problem solving Deciding on appropriate data structure Algorithm design techniques Method of specifying an algorithm Proving an algorithm’s correctness Analyzing an algorithm Coding an algorithm

12 Important Problem Types
Sorting Searching String processing Graph problems Combinatorial problem Geometric problems Numerical problems

13 Fundamental Data Structures
Linear Data Structures Graphs Trees Sets and Dictionaries


Download ppt "Introduction to The Design & Analysis of Algorithms"

Similar presentations


Ads by Google