Complexity Analysis Summary

πŸ“˜ Data Structure and Algorithm πŸ‘ 86 views πŸ“… Nov 05, 2025
⏱ Estimated reading time: 1 min

Complexity Analysis Summary

Complexity Analysis is used to measure the efficiency of an algorithm in terms of time and space resources.

Types of Complexity

  • Time Complexity: How the running time grows with input size.
  • Space Complexity: How much extra memory is required.

Common Asymptotic Notations

NotationNameMeaning
O(1)ConstantExecution time independent of input size
O(log n)LogarithmicIncreases slowly with input size
O(n)LinearProportional to input size
O(n log n)LinearithmicCommon in efficient sorting
O(nΒ²)QuadraticNested loops over input
O(2ⁿ)ExponentialDoubles with each increase in input
O(n!)FactorialAll permutations considered

Best, Average, and Worst Case

  • Best Case: Minimum possible time.
  • Average Case: Expected time over all inputs.
  • Worst Case: Maximum time taken for any input.

Example Comparisons

AlgorithmTime ComplexitySpace Complexity
Linear SearchO(n)O(1)
Binary SearchO(log n)O(1)
Bubble SortO(nΒ²)O(1)
Merge SortO(n log n)O(n)
Quick SortO(n log n)O(log n)
DFS / BFSO(V + E)O(V)

Conclusion

Analyzing complexity helps developers compare algorithms and choose the most efficient one for a given task. It’s a crucial skill in algorithm design and optimization.


πŸ”’ Some advanced sections are available for Registered Members
Register Now

Share this Post


← Back to Tutorials

Popular Competitive Exam Quizzes