In the implementation, Can be make a dynamic linked list in the Node for storing the Address of child nodes, and not storing the data of child node
Trie - Implementation
tries are very useful in case of string search operation due to their efficient time complexity. storing data in a structure like unordered_map<char,node*> is important. when you search for any string, you can directly jump to that child using the data in O(1)time.
for eg. you are searching for “cat”, root->m[‘c’] will directly jump to its c child(m is map name.).
if you have only dynamic list of child nodes, first you need to search the node which have data as c, then you can step forward. which would make the time complexity worse.
so you can not have dynamic linked list in the Node for storing the Address of child nodes.
thanks
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.