Professional Documents
Culture Documents
Algorithms Section 3
Algorithms Section 3
Section ( 3 )
Algorithm performance
Algorithm performance : the amount of time and space resources required to execute it.
MO3AZ
Big-O Notation
MO3AZ
Examples
f(n) = 7n + 10
O( f(n) ) = O( n )
f(n) = 4n^2 + n + 12
F(n) Return
= 1 + ( ntotal
+ 1 ;) + n + 1 = 2n + 3 = O(n)
MO3AZ
Examples
X=0; 1
n+3
for( i = -2 ; i < n ;n i++){
+2 F(n) = 1+n+3+n+2+n+2+1= 3n+9
x=x+i; n+2
y=x+2; O(F(n)) = O(n)
} 1
Print(x);
MO3AZ
Compute step execution and big o for the following
code :
int func(a[] ,n ){
int x = 5; 1