The Big 'O' Notation

The Big 'O' Notation

Understanding Time Complexities

ยท

2 min read

The term `time complexity` is a pretty common term in the computer science world. It is the total amount of computer time it takes for an algorithm to run or execute all its operations.

The Big O Notation on the other hand is a mathematical concept used as a metric system for denoting time complexities or classifying different algorithms according to their time complexity.

Types Of Time Complexities

Constant Time Complexity: O(1)

This is one of the most common time complexity.

This is a time complexity in which the time execution of the algorithm remains constant and fixed no matter the input size.

It is the fastest time complexity.

Linear Time Complexity: O(n)

This is another common time complexity.

This is a time complexity where the time execution of the algorithm is dependent on the size of the input (n)

You normally see this complexity in algorithms working with loops, such as algorithms traversing through an array

Logarithmic Time Complexity: O(log n)

This is a time complexity where the time execution of the algorithm is dependent on the halving of the n input size.

An example of an algorithm with this time complexity is the binary search algorithm, where input size is halved at intervals in search for a target node.

Quadratic Time Complexity: O(n^2)

This is a time complexity where the time execution of the algorithm is dependent on the square of the size of the input (n).

This is normally found in algorithms that have a nested loop.

Exponential Time Complexity: O(2^n)

This is a time complexity where the time execution of the algorithm is dependent on the double growth rate of each n input.

This kind of time complexity is normally found in algorithms with recursions.

It's one of the worst time complexities ๐Ÿ˜‚

Factorial Time Complexity: O(n!)

It's a pretty uncommon time complexity.

This is a time complexity in which the time execution of the algorithm is dependent on the factorial of the input (n) size.

This time complexity is usually caused by trial and error algorithms such as brute force algorithms.

Here's a chart on the speed of the algorithms:

We've come to the end of this article, thanks for reading ๐Ÿ˜„

Don't forget to like this article and give me a follow โค

If you want to get better at landing jobs then this playlist is for you: https://www.youtube.com/playlist?list=PLRm2b-7tzI8UyIvT-kfS5yUQW_ozV6LnI

Bye!

ย