Algorithms implemented in Scala