Algorithm and DataStructures in Scala