Fundamental Algorithms implementation in java