Skip to main content

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


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)

Uploaded Source

Built Distribution

big_O_calculator-0.0.1-py3-none-any.whl (4.9 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page