Algorithms hw1 problems 1 and 2