What is the difference between tree depth and height

0 votes
I have a relatively simple question from the algorithms theory as to what is the difference between them? Is that in one case you count the number of nodes and in the other case, the number of edges on the shortest path between root and concrete node? Could anyone clarify my doubt as to which is which?
Feb 9 in Python by Soham
• 8,730 points
29 views

1 answer to this question.

0 votes

To answer your question, you will have to be aware of the fact that the depth and height are properties of a node: The depth of a node is the number of edges from the node to the tree's root node and also the root node will have a depth of 0.

The given height of a node is the number of edges on the longest path from the node to a leaf. The height would be 0 for a leaf node. For a tree, the height would be the height of its root node and could also be the depth of its deepest node. When talking about the diameter which is also the width of the tree, is the number of nodes on the longest path between any two leaf nodes. The image of the tree below has a diameter of 6 nodes.

image

answered Feb 9 by Rahul
• 8,980 points

Related Questions In Python

0 votes
1 answer

What is the difference between list and tuple?

Lists are mutable(values can be changed) whereas ...READ MORE

answered May 5, 2018 in Python by aayushi
• 750 points
4,819 views
+1 vote
2 answers

What is the difference between classes and labels in machine learning?

Classes and Labels both are almost same things ...READ MORE

answered Apr 3, 2019 in Python by SA
• 1,050 points
3,444 views
0 votes
1 answer

What is the difference between Python and IPython?

There are few differences between Python and ...READ MORE

answered Jul 26, 2018 in Python by Priyaj
• 58,080 points
2,806 views
0 votes
1 answer

What is the difference between re.search and re.match?

The theoritical approach can be this way, re.match is ...READ MORE

answered Aug 10, 2018 in Python by Priyaj
• 58,080 points
6,279 views
0 votes
1 answer
0 votes
0 answers
0 votes
1 answer

Why would anyone use set instead of unordered_set?

Unordered sets must compensate for their O(1) ...READ MORE

answered Jun 1 in C++ by Damon
• 3,380 points
29 views
0 votes
1 answer

Implement Tree(Datastructure) in Java

I wrote a small "TreeMap" class based ...READ MORE

answered May 9, 2018 in Java by sharth
• 3,350 points
835 views
0 votes
2 answers

What's the difference between %s and %d in Python string formatting?

The reason is that they are using ...READ MORE

answered Feb 8 in Python by Rahul
• 8,980 points
29 views
0 votes
3 answers

'python' is not recognized as an internal or external command

Try "py" instead of "python" from command line: C:\Users\Cpsa>py Python 3.4.1 (v3.4.1:c0e311e010fc, May ...READ MORE

answered Feb 8 in Python by Rahul
• 8,980 points
567 views
webinar REGISTER FOR FREE WEBINAR X
Send OTP
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP