Implementation of various algorithms in Java