Giter Club home page Giter Club logo

median-calculator's Introduction

Build Status Coverage Status

median-calculator

Description

median-calculator computes the median of a given list of Integer samples.

The class RollingMedianCalculator is responsible for ingesting samples (one at a time) and computing the final median. Samples are stored into an instance of Histogram which keeps track of the samples' frequencies.

Once the input has finished streaming in, RollingMedianCalculator goes through the histogram and computes the median.

Assumptions

  • As of now the algorithm doesn't support even numbers of samples, it will try anyway but it will also warn you.
  • a sample ranges from 0 to 1000
  • the streaming logic is left to the developer, the class App.java implements streaming from the stdin

Requirements

  • java 8
  • maven 3

Build

mvn install

Run

java -jar target/median.jar will listen to the stdin, type a list of samples (i.e 1,2,3,4,5). The application closes the stdin stream and returns once it receives an empty line.

java -jar target/median.jar < examples/example_6 ~ 100 samples
java -jar target/median.jar < examples/example_7 ~ 1000 samples
java -jar target/median.jar < examples/example_big ~ 10^6 samples

median-calculator's People

Contributors

danieleorler avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.