All mock tests are FREE till 31 December — register to save your progress
Unit 7 · Data Structures and Algorithms Paper 2 CS · June 2024 (Cancelled Exam)

The height of a binary search tree built by inserting the words banana, peach, apple, pear, coconut, mango and papaya (in this order, alphabetical comparison) is:

Pick an option to check yourself, or open the answer below.

Show answer & explanation

Correct answer: C. 4

Explanation

banana is the root; peach goes right; apple left; pear right of peach; coconut left of peach; mango right of coconut; papaya (< peach, > mango) right of mango. The longest path banana-peach-coconut-mango-papaya has 4 edges.

More Data Structures and Algorithms questions