Source code of Algorithm I (Coursera)