Data Structures · Question 21 · Medium

Data Structures question 21

The keys 45, 20, 60, 10, 30, 25, 50 are inserted in that order into an empty Binary Search Tree. What is the height of the resulting tree, where height is the number of edges on the longest root-to-leaf path?

  1. 3
  2. 6
  3. 2
  4. 4
Answer and explanation

Answer: A. 3

Explanation: 45 is the root; 20 and 60 are its children; 10 and 30 go under 20; 25 goes left of 30; 50 goes left of 60. The longest path is 45-20-30-25, which has 3 edges.

Previous: Which of the following is a non-linear data structure? · Next: What is the prefix (Polish) form of the infix expression (A + B) * (C - D) ?

Practise data structures

Try a fresh set of data structures questions with an explanation after every answer, free and without signing up: Data Structures practice. Or sit a full placement mock test.

More data structures questions

More technical & programming practice

Algorithms · Object-Oriented Programming · DBMS · SQL · Operating Systems · Computer Networks · Software Engineering · Cloud & DevOps

LogicWiz Exams home · All practice topics · Placement mock tests · Daily 10 challenge