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, 2022 in Python by Soham
• 9,710 points
1,746 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, 2022 by Rahul
• 9,680 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
6,959 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,090 points
7,601 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,100 points
3,967 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,100 points
11,866 views
0 votes
1 answer

Competitive Programming Algorithm Sock Drawing Probability Question

Another way to look at the problem ...READ MORE

answered Mar 25, 2022 in Machine Learning by Dev
• 6,000 points
575 views
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, 2022 in C++ by Damon
• 4,960 points
2,874 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,370 points
1,403 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, 2022 in Python by Rahul
• 9,680 points
22,602 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, 2022 in Python by Rahul
• 9,680 points
2,488 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP