Big-O notations are used to represent Space or Time complexities of algorithms. There are more notations such as Theta and Omega. But we’ll restrict the discussion to the frequently used Big-O notation. Here are some terminology and complexity in Big-O notations you should keep in mind. BIG-O NOTATIONS – GRAPHICAL – YOU ALREADY KNOW IT […]

## Time complexity of linear search

The time complexity of linear search is O(n). In the best case its time complexity is O (1). In the linear search, you search an element in a list sequentially until you find that element. For example, Suppose you want to find the element 2 in the given list below. You have to traverse the […]

## Time complexity of for loop – O(1) O(n) and O(log n)

Time complexity of for loop can be anything O(1), O(n), O(log n) depending upon the loop conditions and code you write. Time complexity of for loop with various scenarios. a) Every time you run this loop; it will run 10 times. In other word, this for loop takes constant time. So, the time complexity will […]