Lecture-4 IT-303 Complexity Analysis-Compressed
Lecture-4 IT-303 Complexity Analysis-Compressed
A. Space Complexity
• Space Complexity of an algorithm denotes the total space used or needed by the
algorithm for its working, for various input sizes.
• when you are creating a variable then you need some space for your algorithm to
run.
• All the space required for the algorithm is collectively called the Space
Complexity of the algorithm.
B. Time Complexity
• The time complexity is the number of operations an algorithm performs to
complete its task with respect to input size
• The algorithm that performs the task in the smallest number of operations is
considered the most efficient one.
• It is represented by Big(oh) notation means maximum time taken by the program.
Asymptotic Notations
• The efficiency of Algorithm is measured with the help of asymptotic notations.
• Before designing and Analysis of Algorithm, We must understand the terms of
Algorithm call Asymptotic Notations
• Asymptotic notations are the mathematical notations used to describe the running
time of an algorithm
1. Big(oh) Notation:
Big-O notation represents the upper bound of the running time of an algorithm. Thus, it
gives the worst case complexity of an algorithm.
• Worst Case
• Upper Bound
• At most
O(g(n)) = { f(n): there exist positive constants c and n0 such that 0 ≤ f(n) ≤ cg(n) for all
n ≥ n0 , c>0, n0>=0}
For any value of n, the running time of an algorithm does not cross time provided
by O(g(n)).
As n increases, f(n) grows no faster than g(n). In other words, g(n) is an asymptotic upper
bound on f(n).
Ω(g(n)) = { f(n): there exist positive constants c and n0 such that 0 ≤ cg(n) ≤f(n) for all
n ≥ n0 }
For any value of n, the minimum time required by the algorithm is given by
Omega Ω(g(n))