Interview Questions

254.Suppose you a have function which returns a word char* GetWord() from a document.....

Microsoft Interview Questions and Answers


(Continued from previous question...)

254.Suppose you a have function which returns a word char* GetWord() from a document.....

Question:
Suppose you a have function which returns a word char* GetWord() from a document. Write a data structure which holds the words in the most efficient way. If the words are repeated, find the number of repeated words.
a)What data structure you used?
b) What algorithm you implemented?
c) What is the level of the algorithm.



maybe an answer:


where every node contains the word and its corresponding frequency. Insertion procedure is standard insertion procedure for a trie, and to find the list of repeated words, just do any order traversal for the given trie, since every node is visited only once it would be an O(n) solution.

(Continued on next question...)

Other Interview Questions