logo

AQA A-Level Computer Science practice

Explain why the time complexity of binary tree search is O(log n). In your answer, describe what happens to the search after each comparison and relate this to the number of levels that may need to be examined.

Try the question first, then check the answer and practise the same topic again.

At a glance

Question

Type

practice

Style

Topic

Searching algorithms

Exam-style question

Try this first

Explain why the time complexity of binary tree search is O(log n). In your answer, describe what happens to the search after each comparison and relate this to the number of levels that may need to be examined.

Answer and explanation

Concise answer

Binary tree search compares the target with the current node and then follows only one of the two branches.

Why this is correct

The essential points are that a comparison selects one branch, the search does not examine both branches at every step, and the resulting number of levels is logarithmic in the number of values. These points justify O(log n).

Use the concise answer above for a quick check, then reveal the full model answer and detailed explanation.

Common mistake

No common mistake is linked to this question yet.

Related flashcards

No flashcards are published for this page yet.

Related practice questions