Use java language to implement these algorithms and data structure.