Algorithms implementations on Scala