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

Question: 1 / 400

What is the worst-case insertion complexity of a binary search tree?

O(n)

The worst-case insertion complexity of a binary search tree is O(n). This occurs in situations where the tree becomes unbalanced, typically when elements are inserted in a sorted order. In such cases, each new element is added as the right child of the previous element, resulting in a structure that resembles a linked list rather than a balanced tree.

In a binary search tree, insertion involves traversing the tree to locate the correct position for the new element. When the tree is unbalanced, this traversal can take linear time, as you may have to go through every existing node to find the proper insertion point. Thus, in this worst-case scenario, the time complexity for insertion is proportional to the total number of nodes, which gives us O(n).

Balanced binary search trees, such as AVL trees or Red-Black trees, maintain their structure to ensure that the height of the tree remains logarithmic relative to the number of elements. However, in a regular binary search tree without self-balancing properties, the insertion can degrade to linear time depending on the order of insertion.

Get further explanation with Examzify DeepDiveBeta

O(1)

O(log n)

O(n log n)

Next Question

Report this question

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy