Embercode
✕
Dicts and SetsQuick quiz

Time store and top K

8 questions. Covers Top K frequent words in Python: heap versus bucket sort.

Questions 1 to 5 of 8

  1. 1. Which statements about get(key, t) on the time store are true? Pick all that apply.

    Pick every answer that is true.

  2. 2. Which statements about the three top-K methods are true? Pick all that apply.

    Pick every answer that is true.

  3. 3. What does this program print? ``python import bisect times = [3, 6, 8, 12] values = ['p', 'q', 'r', 's'] def get(t): i = bisect.bisect_right(times, t) return '' if i == 0 else values[i - 1] print('[' + get(2) + ']', get(7), get(11)) ``
  4. 4. What does this program print? ``python from collections import Counter words = ['cat', 'dog', 'cat', 'emu', 'dog', 'cat'] counts = Counter(words) entries = sorted(counts.items(), key=lambda e: e[1]) print(entries[0][0], entries[1][0]) `` The counts are cat=3, dog=2 and emu=1.
  5. 5. Why does set refuse a timestamp that is not larger than the last stored timestamp for that key?

5 question(s) left on this page.