Algorithmic Efficiency
Algorithmic Efficiency
Algorithmic Efficiency
Intro, Complexity
Finding Complexities
Best, Worst & Average Cases
Efficiency ensures that the result is achieved with using minimal energy, memory,
time, etc.
These are external factors which can be controlled upto some extent, but varies too much.
Internal Complexity
Internally we can tweak the program by improving two things :
Optimizing these two will result into faster results with lesser size.
Time Complexity
Time complexity of a program is the number of instructions that a program
executes.
for i in range(20):
print(‘Ye Rashi thi’)
time complexity = 20
Big-O Notation
Big O Notation is used to depict an algorithm’s growth rate. It checks the
algorithm’s performance as input size grows.
ooooohhh….
Comparing two Algorithms
N 1 10 20 100 1000
It is generally found when the problem is divided into fractions (usually in ½).
p = -1
q=n
while(p+1)<q:
m=(p+q)/2
if A[m] > m:
p=m
else:
q=m