Algorithms written in java