This is the 30th day of my participation in the August Text Challenge.More challenges in August

Big O notation

The growth order of the algorithms specified in the big O notation.

Source: Big O Cheat Sheet.

Here is a list of some of the most common big O notations and how they compare to input data of different sizes.

Big O notation Count 10 elements Count 100 elements Count 1000 elements
O(1) 1 1 1
O(log N) 3 6 9
O(N) 10 100 1000
O(N log N) 30 600 9000
O(N^2) 100 10000 1000000
O(2^N) 1024 1.26 e+29 1.07 e+301
O(N!) 3628800 9.3 e+157 4.02 e+2567

The complexity of data structure operations

The data structure The connection To find the insert delete note
An array of 1 n n n
The stack n n 1 1
The queue n n 1 1
The list n n 1 1
Hash table n n n In the case of a full hash function, order one.
Binary search tree n n n n In the balanced tree case, it’s order log of n.
B tree log(n) log(n) log(n) log(n)
Red and black tree log(n) log(n) log(n) log(n)
AVL tree log(n) log(n) log(n) log(n)
Bloom filter 1 1 There is a probability of misjudgment (misjudgment of existence)

The complexity of array sorting algorithms

The name of the The optimal On average, The worst memory stable note
Bubble sort n n^2 n^2 1 Yes
Insertion sort n n^2 n^2 1 Yes
Selection sort n^2 n^2 n^2 1 No
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) n^2 log(n) No In the in-place version, memory complexity is usually order log(n).
Hill sorting n log(n) Dependent on gap sequence n (log(n))^2 1 No
Count sorting 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 – The ascending order of the longest key