Practice mode Data Structures

The keys 10, 20, 30, 40, 50 are inserted in that order into an empty, unbalanced binary search tree. What is the height of the resulting tree, counting edges on the longest path?

Correct answer D. 4

Explanation

Each new key is larger than all earlier ones, so it always becomes the right child of the previous node, producing a chain of five nodes and four edges. Such a degenerate tree behaves like a linked list, making search O(n) instead of O(log n). A height of 2 would require a balanced shape, which is exactly what self-balancing trees such as AVL trees maintain.

Report a problem

Answer checked How we write and check questions

Tip: press A, B, C or D to answer, and N for the next question.

Advertisement

Have a question about this answer?

Your email address will not be published. Required fields are marked *

Links and website addresses are not allowed in comments.