Why is the brute-force approach less ideal here?
Practice this question from Find First and Last Position - Boundary Binary Search Pattern Practice Quiz, with options and an explanation.
Question
Why is the brute-force approach less ideal here?
Option A — Correct answer
Linear scanning can degrade to O(n).
Option B
It is always O(1)
Option C
It avoids all comparisons
Option D
It only works for binary trees
Explanation
Linear scanning can degrade to O(n).