Started afresh. Implementing from book Algorithms.