The following are examples used in the Big O article.
All these examples require Python 2.7 and Higher in order to work properly.
The following examples are:
- Binary Search (binary.py)
- Bubblesort (bubblesort.py)
- Constant (constant.py)
- Linear Search (linear.py)
O(1) is constant, no matter how many elements are added the resulting operation will always be the same time.
O(N) is linear, it increases operations as the number of elements increases in direct proportion.
O(Log N) is logarithmic or half of linear time, it halves the number of operations required given the same elements as O(n).
O(N²) shows the worst case scenario as operations increase steeply with the increase in number of elements, or quadratic time.