Implemented necessary data structures for redesigned efficient algorithm.