data structure and algorithm implementation in Java