ProgrammingModerateTCS NQT · Wipro pattern
Which statement about the bisect module is FALSE?
- A. bisect_left returns the first index where x could be inserted without breaking the order
- B. bisect_right returns the index just after the last element equal to x
- C. bisect runs in O(n) because it scans the list linearly
- D. bisect needs the list to be sorted to give a meaningful answer
Correct answer: C. bisect runs in O(n) because it scans the list linearly
bisect halves the search range at each step, so it takes O(log n) comparisons. The other three statements are true.
More Python Programming questions
- What is printed? python def mink(piles, h): lo, hi = 1, max(piles) while lo < hi: mid = (lo + hi) // 2 if sum(-(-p // mid) for p in piles)…
- What is printed? python import heapq def huff(freqs): h = list(freqs) heapq.heapify(h) cost = 0 while len(h) > 1: a = heapq.heappop(h) b =…
- What is printed? python def zeros(n): c = 0 while n: n //= 5 c += n return c print(zeros(100), zeros(25))
- What is printed? python def mincut(s): n = len(s) pal = [[False] n for in range(n)] for i in range(n - 1, -1, -1): for j in range(i, n)…
- What is printed? python def triecount(words, pref): root = {} for w in words: node = root for ch in w: node = node.setdefault(ch, {})…
- What is printed? python M = 109 + 7 N = 10 fact = [1] (N + 1) for i in range(1, N + 1): fact[i] = fact[i - 1] i % M def nCr(n, r): return…