Skip to content
Hard Design: Search Autocomplete (Google)

What is the time complexity of finding top-5 suggestions for a given prefix in an optimized trie with top-K caching?

— Tests your understanding of this concept.

Answer Options

A O(N) — must scan all queries
B O(L) — traverse L characters to reach prefix node, then return cached top-5
C O(K log N) — sort K candidates
D O(N log N) — sort all queries

Want to see the correct answer?

Get the answer with a detailed explanation, plus practice 22+ more Design: Search Autocomplete (Google) questions with adaptive quizzes and timed interviews.

See the Answer on Guru Sishya →

This question is from the Design: Search Autocomplete (Google) topic (System Design Cases).

More Design: Search Autocomplete (Google) Questions