Changed most of the stuff, removed the old trie implementation and replaced it with a simple trie just for illustration purposes of the algorithm, also added boost library for using it's smart pointers, I've used boost::shared_ptr throughout the code.