Complexity of algorithms
Each algorithm has its own complexity, which can be expressed in mathematical notation. This overview shows the typical complexity of algorithms according to the size of the input data (i.e. the number of elements they work with) and which types of algorithms are suitable for which type of task.
In general, there is a best specialized algorithm for each type of problem. No algorithm is universally best, and you always need to know your context.
Big O Notation
The Big O Notation is used to classify algorithms according to how their runtime or memory requirements increase with increasing input size.
The following chart shows the most common growth orders of algorithms specified in Big O Notation.
Below is a list of some of the most commonly used Big O notations and a comparison of their performance with respect to different input data sizes.
|Big O Notation||Complexity for 10 elements||Complexity for 100 elements||Complexity for 1000 elements|
|O(N log N)||30||600||9000|
Complexity of data structure operations
|Binary Search Tree||n||n||n||n||In the case of a balanced tree, the complexity will be O(log(n)).|
|Bloom Filter||-||1||1||-||When searching for |
Complexity of sorting algorithms
|Heap sort||n log(n)||n log(n)||n log(n)||1||No|
|Merge sort||n log(n)||n log(n)||n log(n)||n||Yes|
|Quick sort||n log(n)||n log(n)||n2||log(n)||No|
|Shell sort||n log(n)||depends on the sequence||n (log(n))2||1||No|
|Counting sort||n + r||n + r||n + r||n + r||Yes||r - the largest number in the array|
|Radix sort||n * k||n * k||n * k||n + k||Yes||k - length of the longest key|
Jan Barášek More about the author
The author works as a senior developer and software architect in Prague (Czech republic, Europe). He designs and manages large web applications that you know and use. Since 2009 he has gained a wealth of experience which he passes on through this website.
I'd be happy to help:Contact