Digital_dictionary


segmentation fault

@swatiguptasg
The problem is arising because you are changin the value of root in every dfs call, that too in a loop. If you change the value of root in an iteration, that changed value of root is used in the next iteration.
Make your dfs recursive call like this instead
dfs(root->children[k.first],str+k.first,v);

Also , there are some other things missing in your code such as you missed adding new words in case they are not found and missed to print “No suggestions” as well. Make those changes as well.

1 Like

thanks tarun, he correctly pointed out all the errors.
please try to fix those errors on yourself.

after you tried, you can check the corrected code here: https://ide.codingblocks.com/s/215058

thanks

1 Like