Data Structures · Question 8 · Medium

Data Structures question 8

A binary tree has height 4, where height is the number of edges on the longest root-to-leaf path. What is the maximum number of nodes it can have?

  1. 15
  2. 16
  3. 31
  4. 32
Answer and explanation

Answer: C. 31

Explanation: A tree of height h has at most h + 1 levels, holding 1 + 2 + 4 + ... + 2^h = 2^(h+1) - 1 nodes. For h = 4 this is 2^5 - 1 = 31.

Previous: What is the postfix form of the infix expression A + B * C - D ? · Next: What is the value of the postfix expression 6 2 3 + - 3 8 2 / + * ?

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