Skip to content

Haskell data structure for constant-time queries for the median of a stream of numeric data

License

Notifications You must be signed in to change notification settings

caneroj1/median-stream

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

median-stream

Hackage Build Status
Haskell data structure for constant-time queries for the median of a stream of numeric data, where insertion into the stream occurs in O(nlgn). median-stream uses two heaps (a max-heap and a min-heap) to enable constant time access to the median. If there is an even number of elements in the stream, then the median is the average of the head of the two heaps. If there is an odd number, the median is the head of the max heap.

Usage

Data.MedianStream> let medianStream = empty +> 1 +> 3 +> 4 +> 2
Data.MedianStream> median medianStream
Just 2.5
Data.MedianStream> let medianStream2 = medianStream +> 0 +> (-1) +> 10
Data.MedianStream> median medianStream2
Just 2.0

About

Haskell data structure for constant-time queries for the median of a stream of numeric data

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published