Ace the A Level Computer Science OCR 2025 – Code Your Way to Success!

Question: 1 / 400

What type of search algorithm employs O(log n) time complexity?

Linear Search

Binary Search

The option indicating Binary Search is correct because it efficiently halves the search space with each comparison. This method works on sorted data and operates by repeatedly dividing the range of potential locations for the target value in half.

At each iteration, the algorithm compares the target value to the middle element of the current range. If the target is equal to the middle element, the search is successful. If it's less than the middle element, the search continues in the lower half; if it’s greater, the search continues in the upper half. This halving process results in a time complexity of O(log n), where n is the number of elements in the dataset.

In contrast, the other search algorithms mentioned do not achieve this logarithmic efficiency. Linear Search and Sequential Search both examine each element in sequence and thus operate with a time complexity of O(n). Hash Table Search can offer average time complexities of O(1) for lookups but relies on hashing techniques rather than a systematic search process. Hence, Binary Search stands out for its logarithmic time complexity due to its method of reducing the search space strategically.

Get further explanation with Examzify DeepDiveBeta

Hash Table Search

Sequential Search

Next Question

Report this question

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy