Algorithms implementation using Java