educative.io

Can we store top suggestions with each node?

we can optimize our storage by storing only references of the terminal nodes rather than storing the entire phrase. To find the suggested terms we need to traverse back using the parent reference from the terminal node

what does that mean? Difficult to imagine. A diagrammatic here would have been better.

3 Likes

Hi @Rahul,

Thanks for posting the question.

What is being suggested here, is to store the termination nodes of all the top terms with each node. So like a tree traversal, you can traverse back from a terminating node all the way up to find the complete ‘term’. We will look into adding a visual representation of this.

Hope this helps.

still not getting the idea. Can you make some animation or slide for this particualr case for us?

This actually doesn’t help. How can you go back to the parent starting from the terminating node? Each node only contains the pointer to the terminating letter which is further down, it doesn’t contain pointer to the parent.

Right, we do need parent pointer in each node to traverse back. That’s what have been suggested too:

To find the suggested terms we need to traverse back using the parent reference from the terminal node. We will also need to store the frequency with each reference to keep track of top suggestions.

Any update on the visual representation? That would certainly aid quite a bit. Thanks.

Well, you probably can do just post order traversal to update bottom-up? Do you see any problems about this approach?