What traversal over trie gives the lexicographical sorting of the set of the strings?

Category: QuestionsWhat traversal over trie gives the lexicographical sorting of the set of the strings?
Editor">Editor Staff asked 1 month ago

What traversal over trie gives the lexicographical sorting of the set of the strings?
 
(a) postorder
 
(b) preorders
 
(c) inorder
 
(d) level order
 
I need to ask this question from Trie in chapter Trie of Data Structures & Algorithms I
 
This question was posed to me in homework.

1 Answers
Editor">Editor Staff answered 1 month ago

Correct option is (c) inorder
 
Easy explanation – In trie, we store the strings in such a way that there is one node for every common prefix. Therefore the inorder traversal over trie gives the lexicographically sorted set of strings.