Embercode
✕
HeapsQuick quiz

Kth and closest points in Python

7 questions. Covers K closest points with a size-k heap in Python.

Questions 1 to 5 of 7

  1. 1. A list of numbers arrives one at a time, and you cannot keep the whole list in memory. You want the 100th largest. Which method from the kth-largest lesson fits?
  2. 2. In a sorted list of 10 numbers, which index holds the 3rd largest number? Indexes count from 0.
  3. 3. Which statements about the three kth-largest methods are true? Choose all that apply.

    Pick every answer that is true.

  4. 4. Which statements about squared distances in Python are true? Choose all that apply.

    Pick every answer that is true.

  5. 5. What does this code print? ``python import heapq heap = [] for x in [7, 2, 9, 4, 5]: heapq.heappush(heap, x) if len(heap) > 3: heapq.heappop(heap) print(heap[0]) ``

5 question(s) left on this page.