This preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Unformatted text preview: Algorithm Analysis EEE 13 Lecture 02 Algorithm Analysis ● Considers how Input affects the performance of the algorithm ● Usual Criteria – Processing Time – Memory Usage – Other resources Empirical Approach ● Actual – Measures performance in use ● Random data – Generic approach, may not be representative ● Perverse data – Attempt worst case analysis Theoretical Approach ● Study the following cases: – worst case performance – Average performance – Best case performance ● Independent of actual implementation Growth of functions ● Often we simply study how the run time T depends on the input size N ● Time is usually associated to the number of operations ● T = f(N) – N might be ● degree of polynomial ● file size ● number of char in a text string ● etc. /* Assuming each operation takes 1 unit of time */ int func1( int aList[ ], int N) { int iSum; int i; iSum = ; /* 1 */ i = ; /* 1 */ while( i < N) { /* N+1 */ iSum += aList[i]; /* 3N */ i ++ ; /* N */ } return iSum; /* 1 */ } /* f(N) = 5N + 4 */ /* Assuming each operation takes 1 unit of time */ void func2( int aList[ ], int N) { int iSum; int i; int j; for (i = ; i < N; i ++ ) { /* 1+N+1+N = 2N+2 */ for (j = ; j < N; j ++ ) /* N*(2N+2) */ printf( “%d\n” , aList[j] * aList[i]); /* N*(4N) */ } } /* f(N) = 6N 2 + 4N + 2 */ Big Oh ● We use the Onotation to allow us to classify algorithms according to upper bounds on their total running times...
View
Full
Document
This note was uploaded on 01/13/2011 for the course EEEI 13 taught by Professor Ramos during the Winter '10 term at University of the Philippines Diliman.
 Winter '10
 Ramos

Click to edit the document details