A calculator to predict big-O of sorting functions
Project description
Big-O Caculator
A big-O calculator to estimate time complexity of sorting arrays.
inspired by : https://github.com/ismaelJimenez/cpp.leastsq
Usage
You can call which array to test
Big-O calculator
Args:
functionName ([string]): function name to call
array ([string]): "random", "sorted", "reversed", "partial"
from bigO import bigO
def bubbleSort(array): # in-place | stable
"""
Best : O(n) | O(n) Space
Average : O(n^2) | O(n) Space
Worst : O(n^2) | O(n) Space
"""
isSorted = False
i = 0
while not isSorted:
isSorted = True
for j in range(len(array) - 1 - i):
if array[j] > array[j + 1]:
array[j], array[j + 1] = array[j + 1], array[j]
isSorted = False
return array
tester = bigO.bigO()
complexity, _ = tester.test(bubbleSort, "random")
print(complexity) # O(N^2)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
big-O calculator-0.0.1.tar.gz
(3.0 kB
view hashes)
Built Distribution
Close
Hashes for big_O_calculator-0.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a064f59e9f8e9f25d4b64f009488a5ef355d2d32ddde096baed6edd75755e505 |
|
MD5 | 2deab7d7c52724262eb578fe4ab2f1ef |
|
BLAKE2b-256 | 462940876123ed39e37a2c46f687aa71a92a71b6ff71f3e90afd44d0d8427271 |