Monthly Archive: May, 2015

Fun with binary search

Everybody knows binary search. Now, two problems with a twist: Count the number of elements smaller than a given value in a sorted array Count the number of elements equal to a given… Continue reading

Binomial distribution

Starting from the following implementation of binomial distribution, public static double binomial(final int n, final int k, final double p) { if (n == 0 && k == 0) { return 1; }… Continue reading