Algorithms excersise