The Gateway to Computer Science Excellence
First time here? Checkout the FAQ!
x
+3 votes
208 views
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 (419 points) | 208 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 (695 points)
Consider visiting d link mentioned below. I hope d descp helps u. :)
http://typeocaml.com/2014/11/26/height-depth-and-level-of-a-tree/
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 (113 points)
0 votes

Depth vs Height

answered by Boss (5.5k points)
edited by

Related questions

+4 votes
1 answer
1
asked in DS by thor Boss (9.5k points) | 155 views
+3 votes
3 answers
2


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

33,712 questions
40,255 answers
114,367 comments
38,883 users