Skills101
← All practice quizzes

Quiz: Design Search Autocomplete

5 questions · new set on every retakeNo time limitPass: 60%+10 XP on first pass

Suggest the top searches for every prefix in a few milliseconds. Build a trie that stores the top suggestions at each node in Python, then design the data pipeline, sharding and caching around it.

Log in to take the quiz

Free account · see your score, answers and explanations, earn XP

  1. Question 1

    Why store the top-k suggestions at every trie node?

  2. Question 2

    What does this print?

    top = [(700, "java"), (900, "javascript"), (50, "jam"), (400, "java ide")]
    top.sort(key=lambda p: (-p[0], p[1]))
    print([q for c, q in top[:2]])
    
  3. Question 3

    Why is the trie rebuilt from logs in batches instead of updated on every search?

  4. Question 4

    10 million users make 10 searches a day, typing about 6 characters each. Roughly how many requests per second is that?

  5. Question 5

    What does this print?

    trie = {}
    for w in ["cat", "car", "dog"]:
        node = trie
        for ch in w:
            node = node.setdefault(ch, {})
    print(len(trie), len(trie["c"]["a"]))
    
🎯 Today’s placement challenge — 10 questions, no login. Can you score 10/10?Take today’s challenge →