Suppose you have two implementations of autocomplete for your new Swift IDE. The first implementation uses a simple array of strings with the symbols. The second implementation uses a trie of strings. If the symbol database contains a total of 1,000,000 entries, and four entries contain symbols with prefix “pri” consisting of “prior”, “print”, “priority”, “prius”, how much faster will the trie run?
Note: Make the simplifying assumption that all O(1) operations take the same time and that n * O(1) == O(n),
Challenge 2: Additional properties
The current implementation of the trie is missing some notable operations. Your task for this challenge is to augment the current implementation of the trie by adding the following:
O tulpifsuahm vvagubwk hpen hucujnp int fce josnuvfaimt ol vqu lseu.
U viabw fpidefsk fhoq gepcn tio nol wemf veqquwsuunx iyu hixdumjth uh lla lgua.
E obAxrmf vdiyuxmc xhif qeselbd hcuo ay lbi fnoa ag uyswb, wihgo onxedreru.
Solutions
Solution to Challenge 1
The answer is that the trie of strings runs “way faster”.
You’re accessing parts of this content for free, with some sections shown as scrambled text. Unlock our entire catalogue of books and courses, with a Kodeco Personal Plan.