Skills101
← All practice quizzes

Heaps & Priority Queues Quiz

8 questions10 minPass: 60%+10 XP on first pass

Min-heap vs max-heap, Top K, Kth largest, merging sorted lists and the two-heap median.

Log in to take the quiz

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

  1. Question 1Select all that apply

    What are the costs of a binary heap's operations? (select all that apply)

  2. Question 2

    To find the k-th LARGEST element in O(n log k), you keep…

  3. Question 3

    What does this print?

    import heapq
    h = [5, 1, 8, 3]
    heapq.heapify(h)
    print(heapq.heappop(h))
    
  4. Question 4

    How do you get max-heap behaviour with Python's heapq?

  5. Question 5

    In Java, how do you create a max-heap of integers?

  6. Question 6

    Merging k sorted lists with N total nodes using a heap of list heads takes…

  7. Question 7

    For the running median (Find Median from Data Stream), which structure is standard?

  8. Question 8Select all that apply

    Which questions are good fits for a heap? (select all that apply)