The Gateway to Computer Science Excellence
First time here? Checkout the FAQ!
+3 votes
What is the difference between height and levels for a tree. What will be the value of height and level for root node and why?
asked in Algorithms by (355 points) | 291 views

3 Answers

+1 vote
Height and level of a tree are equal.

but height and level of a node are not equal because...

the height is calculated by traversing from leaf to the given node

level is calculated from traversal from root to the given node

that means the height of leaves is 0 and the level of root is 0.
answered by Junior (975 points)
Consider visiting d link mentioned below. I hope d descp helps u. :)
yeah nicely explained. liked the Groot :p
@s9k96, consider referring Data Structures by Yahwant Kanetkar. Okay. :). Superb book. If possible get d animated slides it'll be help to u. :)
0 votes
Height=level+1 because

level count will start with 0 .

height count will start with 1.

Level of the root is 0.

Height of the root is 1.
answered by (191 points)
0 votes

Depth vs Height

answered by Loyal (9.1k points)
edited by

Related questions

+4 votes
1 answer
asked Nov 22, 2016 in DS by thor Loyal (6.7k points) | 221 views
0 votes
0 answers
asked Sep 28, 2018 in Programming by Vaishnavi01 (143 points) | 77 views
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