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 (391 points) | 227 views

3 Answers

0 votes
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 (645 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 (131 points)
0 votes

Depth vs Height

answered by Loyal (6.2k points)
edited by

Related questions

+4 votes
1 answer
asked Nov 22, 2016 in DS by thor Loyal (7.9k points) | 178 views
+3 votes
3 answers

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

36,203 questions
43,662 answers
42,944 users