Download presentation

Presentation is loading. Please wait.

Published byRachel Christie Modified over 4 years ago

1
Analysis of Algorithms Rate of Growth of functions Prof. Muhammad Saeed

2
Analysis of Algorithms2 Rate of Growth of functionsRate of Growth of functions

3
Analysis of Algorithms3

4
4

5
nn(log(n))n(log(log(n)))n(log^2(n))n(log(n^2))n^1.5n 10 0011 10-20121 211222 2202442 3415863 472101394 61142022156 81763634238 11261064533711 154015109805715 2060221811219020 27903229617914127 371324747526422237 491936775338634849 6728196117956154667 90406136182781285690 122584191280611691343122 164838268427716772106164 2221198374647323973304222 2991708521973634155182299 40424267251456448538129404 5463440100521677687912750546 7374865139132117972919999737 99568661922473891373131370995 Analysis of Algorithms5

6
Assume N = 100,000 and processor speed is 1,000,000 operations per secondAssume N = 100,000 and processor speed is 1,000,000 operations per second FunctionRunning Time 2N2N over 100 years N3N3 31.7 years N2N2 2.8 hours N*N 1/2 31.6 seconds N log N1.2 seconds N0.1 seconds N 1/2 3.2 x 10 -4 seconds log N1.2 x 10 -5 seconds Running Times Analysis of Algorithms6

7
7 Series and AsymptoticsSeries and Asymptotics

8
Series I Analysis of Algorithms8

9
Series II

10
Infinite Series Analysis of Algorithms10

11
Fundamental Definitions Asymptotics Fundamental Definitions Asymptotics T(n) = O(f(n)) if there are constants c and n 0 such that T(n) cf(n) when n n 0T(n) = O(f(n)) if there are constants c and n 0 such that T(n) cf(n) when n n 0 T(n) = (g(n)) if there are constants c and n 0 such that T(n) cg(n) when n n 0T(n) = (g(n)) if there are constants c and n 0 such that T(n) cg(n) when n n 0 T(n) = (h(n)) if and only if T(n) = O(h(n)) and T(n) = (h(n))T(n) = (h(n)) if and only if T(n) = O(h(n)) and T(n) = (h(n)) T(n) = o(p(n)) if T(n) = O(p(n)) andT(n) = o(p(n)) if T(n) = O(p(n)) and T(n) (p(n)) Analysis of Algorithms11

12
Analysis of Algorithms12 T(n) = O(f(n)) T(n) = (g(n)) T(n) = (h(n)) Asymptotics

13
Analysis Type Mathematical Expression Relative Rates of Growth Big OT(N) = O( F(N) )T(N) < F(N) Big T(N) = ( F(N) ) T(N) > F(N) Big T(N) = ( F(N) ) T(N) = F(N) Relative Rates of Growth Analysis of Algorithms13

14
Relative Growth Rate of Two Functions Compute using LHopitals Rule Limit=0: f(n)=o(g(n)) Limit=0: f(n)=o(g(n)) Limit=c 0:f(n)= (g(n)) Limit=c 0:f(n)= (g(n)) Limit= :g(n)=o(f(n)) Limit= :g(n)=o(f(n)) Analysis of Algorithms14

15
3n 3 = O(n 3 ) 3n 3 + 8 = O(n 3 ) 8n 2 + 10n * log(n) + 100n + 10 20 = O(n 2 ) 3log(n) + 2n 1/2 = O(n 1/2 ) 2 100 = O(1) T linearSearch (n) = O(n) T binarySearch (n) = O(log(n)) Important Rules Analysis of Algorithms15

16
Important Rules Rule 1: If T 1 (n) = O(f(n)) and T 2 (n) = O(g(n)), then a) T 1 (n) + T 2 (n) = max(O(f(n)), O(g(n))) a) T 1 (n) + T 2 (n) = max(O(f(n)), O(g(n))) b) T 1 (n) * T 2 (n) = O(f(n)*g(n)) Rule 2: If T(x) is a polynomial of degree n, then T(x)= (x n ) Rule 3: log k n = O(n) for any constant k. Analysis of Algorithms16

17
General Rules for LoopsLoops Nested LoopsNested Loops Consecutive statementsConsecutive statements if-then-elseif-then-else RecursionRecursion Analysis of Algorithms17

18
Analysis of Algorithms18 Maximum Subsequence SumMaximum Subsequence Sum A case A case

19
int MaxSubsequenceSum( const int A[], const unsigned int N) { int Sum=0, MaxSum=0; for( i = 0; i

20
Maximum Subsequence Sum Algorithm 2 int MaxSubsequenceSum( const int A[], const unsigned int N) { int Sum=0, MaxSum=0; for( i = 0; i

21
Maximum Subsequence Sum Algorithm 3 int MaxSubsequenceSum( const int A[], const unsigned int N) { int Sum = 0, MaxSum = 0, Start = 0, End = 0; for( End = 0; End

22
END Analysis of Algorithms22

Similar presentations

OK

Algorithm Analysis. Algorithm Def An algorithm is a step-by-step procedure.

Algorithm Analysis. Algorithm Def An algorithm is a step-by-step procedure.

© 2018 SlidePlayer.com Inc.

All rights reserved.

Ads by Google

Ppt on banking domain knowledge Ppt on suspension type insulators for sale Ppt on the parliament of india Ppt on online voting system in php Download ppt on motivational thing Ppt on network theory and analysis Ppt on rainwater harvesting in india Free ppt on history of cricket Ppt on decimals for class 5 Ppt on water softening techniques