Solution to Coursera's Algorithms Part 1 - 2012