System Design · interview question
During a live coding session, you're asked to calculate the time complexity of your solution. What is the time complexity of a binary search algorithm?
Multiple choiceHardchapter-20-curatedpremiumsystem-designdefending-tradeoffs
Answer and explanation
Correct answer
B. O(log n)
Why
Binary search has a time complexity of O(log n) because it divides the problem size by half at each step, efficiently narrowing down the search range in a sorted array.
Test yourself on System Design
A free test with instant, explained results. No account needed.
More System Design questions
- You are reviewing a codebase and spot a potential security issue. Which practice is most effective for mitigating SQL…
- Which approach is the strongest way to start a senior system-design answer?
- When discussing SQL databases, what does ACID stand for, and why is it important?
- During a code review, you spot a potential race condition. What is one effective way to address this in Java?
- In a system design interview, you're asked about CAP theorem. Which two properties can a distributed database…
- In a live coding interview, why is it beneficial to explain your approach aloud while coding?