Interview Questions

222. What data structure you use for a dictionary - search and insert logic

Microsoft Interview Questions and Answers


(Continued from previous question...)

222. What data structure you use for a dictionary - search and insert logic

Question:
What data structure you use for a dictionary - search and insert logic


maybe an answer:


in C++ , Suggest STL Map.

Map<String,String> Dictionary;
Dictionary[word] = meaning ;


Advantage :
Maps store data in sorted order , will be beneficial when u need to print all words starting from particular character insertion and search in log n search can be improved if we save iterators for words starting from each character then when search for particular word is requested , get the saved iterator for first character of that word and search word from there .

(Continued on next question...)

Other Interview Questions