(From the interview)
Let's say you have a DB table with two columns: SearchPhrase (String) | Popularity (Int).
You need to initialize DS so that you can use it to implement autocomplete (e.g. google) conveniently. Requirement: as soon as the data from db is processed in the data structure, when you enter a letter, you get the 10 most popular search phrases from db, starting with this letter, and then when you enter the next, you get 10 .... with these two letters and so on.
The question concerns only planning ds and pseudocoding Insert, Search, etc.
Note: YOU CANNOT USE TRIE DS.
Any ideas?
source
share