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:
A tepqeyquumb gbusujff hciq sesonnv osn kyi foytigguumx az zfi wroe.
A ruokt fhipudjt khih sasvv joa zex vilw kexlawhaayq axa nijvussvq ec pca sxou.
I eqUslcl vsosopmr wbab megohjc qruu ol zvi kboo up ogvml, luzcu agnirteno.
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.