1 - Algorithm and Complexity
1 - Algorithm and Complexity
Text Books:
1. Horowitz and Sahni, “Fundamentals of Data structures”, Galgotia
publications,1983
Reference Books:
2.R.L. Kruse, B.P. Leary, C.L. Tondo, “Data structure and program
design in C”, PHI, 2009( Fourth Impression)
Course Objective (CO):
Value of function
function fA(n)=30n+8
eventually
becomes
larger... fB(n)=n2+1
Increasing n
More Examples …
c1+c1+...+c1 = c1 x N (N+1) x c2 + N x c1 =
(c2 + c1) x N + c2
Algorithm 3 Cost
sum = 0; c1
for(i=0; i<N; i++) c2
for(j=0; j<N; j++) c2
sum += arr[i][j]; c3
for all n ≥ 5
– 100n + 5 ≠ (n2)
c, n0 such that: 0 cn2 100n + 5
100n + 5 100n + 5n ( n 1) = 105n
– n ≠ (n2): c1 n2 ≤ n ≤ c2 n2