I said true and walked through the math: binary search runs log n iterations, each random access on a linked list costs O(n), so you get O(n log n).
Start by clarifying that the statement is false, then explain that binary search requires random access to achieve O(log n), which a linked list does not provide. Describe how the lack of random access forces a linear scan to find the middle element, resulting in O(n) time complexity for the search itself, and note that the O(n log n) figure might arise from a flawed analysis that incorrectly assumes O(log n) iterations each taking O(n) time.
Pro tip: Demonstrate deeper understanding by contrasting with array-based binary search and mentioning that while the search is O(n), the overall algorithm (if you include finding the middle each time) is still O(n), not O(n log n). This shows you can analyze algorithmic trade-offs precisely.
State whether the statement is true or false. Here, it is false.
Binary search relies on random access to the middle element in O(1) time, which arrays provide but linked lists do not.
In a linked list, finding the middle element requires traversing from the head, taking O(n) time.
Even if you could halve the search space each time, each halving step costs O(n) to find the new middle, leading to O(n) overall (not O(n log n)).
Explain why O(n log n) is incorrect: it would imply O(log n) iterations each costing O(n), but the total work across iterations is O(n) because the traversal distances decrease geometrically.
AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.