Embercode
✕
Dynamic ProgrammingQuick quiz

LIS in n log n

7 questions. Covers LIS in n log n with bisect and patience piles.

Questions 1 to 5 of 7

  1. 1. What does this program print? ``python import bisect def tails(nums): tails = [] for x in nums: pos = bisect.bisect_left(tails, x) if pos == len(tails): tails.append(x) else: tails[pos] = x return tails print(tails([5, 1, 2, 2, 3])) ``
  2. 2. What does this program print? ``python import bisect def tails(nums): tails = [] for x in nums: pos = bisect.bisect_left(tails, x) if pos == len(tails): tails.append(x) else: tails[pos] = x return tails print(tails([10, 20, 3, 15, 4, 16])) ``
  3. 3. For a list of 100,000 numbers, about how many halving steps does one binary search on the tails list take?
  4. 4. What is the time complexity of the tails method from this lesson for a list of n numbers?
  5. 5. Which statement about the values in the tails list is true?

5 question(s) left on this page.