← Quiz: Interval Problems: all 10 questions
Quiz: Interval Problems · Question 4 of 10
Inserting a new interval into a list that is already sorted and non-overlapping takes how long?
Inserting a new interval into a list that is already sorted and non-overlapping takes how long?
- A.O(n²)
- B.O(n log n), because you must sort again
- C.O(log n) always
- D.O(n), with one walk: before, overlapping, after
Answer & explanation
Correct answer: O(n), with one walk: before, overlapping, after
The list is already in order, so no new sort is needed.
Can you get the rest right without peeking?
Take the timed Quiz: Interval Problems quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →