Choosing a search algorithm
You're building name search over a list of 10,000 contacts. How do linear search and sort-then-binary-search compare, and what would you actually use in a shipping app?
You're building name search over a list of 10,000 contacts. How do linear search and sort-then-binary-search compare, and what would you actually use in a shipping app?
Linear is O(n), binary search is O(log n), but you pay O(n log n) to sort first. Exact match wants a Dictionary, prefix match wants lower bound on a sorted array, and substring match wants a local DB index or a precomputed token inverted index.
CS fundamentals and algorithmsShort answerExpert
You need search autocomplete that works offline: 500,000 candidate words, and on every…
#trie #search
CS fundamentals and algorithmsShort answerBasics
If you had to implement a hash map yourself, how would you build it?
#dictionary
CS fundamentals and algorithmsShort answerAdvanced
You need to write an in-memory image cache with LRU eviction yourself. Which data…
#dictionary
CS fundamentals and algorithmsMultiple choiceIntro
Which of these Swift collection operations have O(1) average time complexity? Select all…
#dictionary