Calculates the median of a data stream in O(log n) time using a heap!
Project description
A simple program to take medians using a heap data structure.
What It Does
Calculates the median of data in O(1) time.
Inserting into the data structure takes O(log n) time in the worst case.
Usage
>>> from MedianHeapPython.medianFinder import MedianFinder >>> d1 = 1 >>> d2 = 2 >>> d3 = 3 >>> medianCalculator = MedianFinder() >>> medianCalculator.addData(d1) >>> medianCalculator.addData(d2) >>> medianCalculator.addData(d3) >>> print(medianCalculator.getMedian()) # 2 >>> print()
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
MedianHeapPython-1.0.6.tar.gz
(1.7 kB
view hashes)