Skip to main content

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


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)

Uploaded Source

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