Algorithms Implementation in Java