Example data structure and algorithm in java