The Gateway to Computer Science Excellence
First time here? Checkout the FAQ!
+3 votes

Suppose you are given a binary tree with n nodes, such that each node has exactly eiter zero or two children. The maximum height of the tree will be

  1. $\frac{n}{2}-1$
  2. $\frac{n}{2}+1$
  3. $(n-1)/2$
  4. $(n+1)/2$
asked in DS by Veteran (96.2k points)
recategorized by | 1.9k views
In GATE question they mention the definition of height. Here nothing is mentioned so maybe we can take the height of level 0 as zero.

3 Answers

+2 votes
Best answer
Question is about full binary tree..

If it is left or right biased than gives the maximum height...

Maximum height is( n-1/ 2) taking root at height 0.
answered by Boss (25.3k points)
selected by
but if we take height at 1,  ans will be which one is correct ? and why ? plzz clarify me
Height of the tree is equal to largest level of the Tree.
+1 vote
Given Tree is a strictly binary tree, having either 0 or 2 children

such trees always contains odd number of nodes

if n=5, then max height will be 2 which is (n-1)/2

if n=7, then max height will be 3 which is again (n-1)/2

So, answer is C
answered by (283 points)
0 votes

Ans is option C)

answered by (185 points)

Related questions

Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true
49,587 questions
54,197 answers
71,151 users