The Gateway to Computer Science Excellence
First time here? Checkout the FAQ!
x
+3 votes
298 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?
in Algorithms by (385 points) | 298 views

3 Answers

+2 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.
by Junior (985 points)
+2
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/
0
yeah nicely explained. liked the Groot :p
+1
@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.
by (201 points)
0 votes

Depth vs Height

by Loyal (9.2k points)
edited by

Related questions

+4 votes
1 answer
2
asked Nov 22, 2016 in DS by thor Loyal (6.7k points) | 227 views
0 votes
0 answers
4
asked Sep 28, 2018 in Programming by Vaishnavi01 (143 points) | 93 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
50,092 questions
55,237 answers
190,755 comments
85,991 users