Time Complexity

<aside> 💡

Time Complexity: It is used to measure efficiency of algorithm, in terms of speed, as the input size grows.

</aside>

Time complexity **≠** time taken by algorithm

image.png

image.png

Binary search efficency >>>> Linear search efficency

To represent time complexity we use Big O Notation.

Big O notation (O): A mathematical notation used to classify the efficiency of algorithms based on how their runtime grows with input size.

We measure it in the worst case.

<aside> 💡

Linear Search time complexity ⇒ O(n)

Binary Search time complexity ⇒ O(log n)

</aside>

Types of Big O Notations