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()
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file MedianHeapPython-1.0.6.tar.gz.
File metadata
- Download URL: MedianHeapPython-1.0.6.tar.gz
- Upload date:
- Size: 1.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/39.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.6.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f9465f911fc5ed6d34d88cf2efc0a2f0d2bf17009378472272e348b8b70ad335
|
|
| MD5 |
76155f2d4f1b0551f48bbdb06e56ecf1
|
|
| BLAKE2b-256 |
6a07f3a02bdeca5e4a2fd4fe131497c7d31ef9fc2e9e52b1a85dfcf095885a5e
|