1) topological sort 2) ex 2 of coursera's standford machine learning