Implementation of various algorithm in Java