ProgrammingModerateTCS NQT · Wipro pattern

Which statement about the bisect module is FALSE?

  1. A. bisect_left returns the first index where x could be inserted without breaking the order
  2. B. bisect_right returns the index just after the last element equal to x
  3. C. bisect runs in O(n) because it scans the list linearly
  4. 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

Exams that ask this topic