Western Governors University (WGU) ICSC2100 C949 Data Structures and Algorithms I Practice Exam

Question: 1 / 400

What is typically the worst-case complexity for searching in a binary tree?

O(log n)

O(n)

In a binary tree, the worst-case complexity for searching is O(n) because a binary tree does not have a guaranteed structure like a binary search tree (BST) does. In the worst-case scenario, the tree can be highly unbalanced, resembling a linked list, where every node only has one child. In such a case, to find a specific value, you may need to traverse through all n nodes of the tree. Each node is checked one by one, which leads to a linear time complexity of O(n).

This contrasts with more structured tree types, like balanced binary search trees, where searching can efficiently achieve O(log n) complexity. However, since the question pertains to a general binary tree without any specific balance or ordering condition, O(n) is the correct characterization for the worst-case search time.

Get further explanation with Examzify DeepDiveBeta

O(n log n)

O(1)

Next Question

Report this question

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy