Datastructures and algorithms implementation in Java