Embercode
✕
HeapsQuick quiz

Medians and indexed heaps

7 questions. Covers Indexed heap with decrease-key in Python.

Questions 1 to 5 of 7

  1. 1. In the indexed heap from this lesson, what does one decrease-key cost when the heap holds n items?
  2. 2. Python's heapq has no decrease-key. If you lower a key by pushing a second copy with heappush and skip the old copy when it comes out, what does the push cost, and what goes wrong?
  3. 3. In the sliding window median lesson, the values 1, 3 and -1 are added in that order using the two-halves design. Which split is correct?
  4. 4. In the indexed heap, what does pos[id] hold?
  5. 5. What does this print? ``python from collections import Counter delayed = Counter() delayed[5] += 1 delayed[5] += 1 delayed[9] += 1 print(delayed[5], delayed[9], 7 in delayed) ``

5 question(s) left on this page.