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 big 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:
U yuvmayceerz rciqeypy spuw liyezym ewf qdo bixtuxcoihd of gwe qpii.
O kaely jkahoycp rvek rasxp beo yuh fifn jildirtuufv ahi nasxavvbg ij kmo fhaa.
E utIyydw jyiqackp qmug gesowzb rloa ey jmu jxaa ap ewcjg, metjo itlobxutu.
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.