DS CSIT Lecture 03
DS CSIT Lecture 03
DS CSIT Lecture 03
Data Structures
Lecture-03
for i ← 1 to n
if i%2 = 0
print “even number”
else
print “odd number”
• Time Efficiency
– The time efficiency determines how fast an algorithm
solves a given problem.
– Quantitatively, the time taken by the algorithm to produce
an output with a given input.
1,2,8: Once
3: N+1 iteration
4,5,6,7: Once per each iteration
of for loop, i.e., N iteration
Total: 1+1+1+(N+1)+N+N+N+N = 5N + 4
The complexity function of the
algorithm is : f(N) = 5N +4