Well known algorithms in scala