Performance Measurement of the Algorithm
Performance Measurement of the Algorithm
2
TIME COMPLEXITY: BIG O NOTATION
Definition Usage Graphical Representation
Big O notation describes the Big O is crucial. It helps in
upper bound. It represents evaluating algorithm efficiency.
the worst-case scenario. It does this by focusing on
growth rate.
Example
O(n) means linear time. O(n^2) means quadratic time. These represent
growth relative to input size.
3
TIME COMPLEXITY: BIG Ω NOTATION
Definition Usage Graphical Representation
Big Omega (Ω) gives the lower This notation is less commonly
bound. It shows the best-case used. It can provide a more
scenario. optimistic perspective.
Example
Ω(1) means constant time. The algorithm is at its
most efficient here.
4
TIME COMPLEXITY: BIG Θ NOTATION
Definition Usage Graphical Representation
Big Theta (Θ) gives the tight Θ provides a precise estimate. It
bound. It describes average-case is useful for algorithms with
complexity. consistent performance.
Example
Θ(n log n) is common. It is found in efficient sorting
algorithms.
5
MEASURING TIME COMPLEXITY : CONSIDER
A SIMPLE LOOP:
6
SPACE COMPLEXITY: MEMORY ANALYSIS
Example 1: Constant Space O(1)
Definition def swap(a, b):
temp = a
Space complexity measures memory.
a=b
It is memory usage relative to input size. b = temp
• Uses only a few variables → O(1) space
Importance Example 2: Linear Space O(n)
Efficient algorithms minimize space. def create_list(n):
This is especially important for large datasets. arr = [i for i in range(n)]
return arr
• Uses extra space for list → O(n) space.
Metrics
Auxiliary space is additional space used.
Total space includes input data too.
7
CONCLUSION
Measuring the performance of an algorithm is essential for determining its
efficiency in terms of time and space complexity. By analyzing asymptotic
notations (Big-O, Big-Ω, Big-Θ) and conducting empirical testing, we can
assess how an algorithm behaves with increasing input sizes. Optimizing
performance involves selecting the right data structures, minimizing
unnecessary computations, and reducing memory usage. A well-balanced
algorithm ensures scalability, making it suitable for real-world applications.
Ultimately, performance measurement helps in choosing the best algorithm
for a given problem, leading to faster and more efficient software.
8
REFERENCES
• Fundamentals of Data Structures of C, Ellis Horowitz, Sartaj Sahni, Susan Anderson
freed
• Data Structure and Algorithmic Thinking with Python, Narasimha Karumanchi, Career
Monk Publications.
9
THANK YOU