Implementation of algorithms in Java