树的深度和高度之间的区别是什么? [英] What is the difference between tree depth and height?

查看:1218
本文介绍了树的深度和高度之间的区别是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是从算法理论的一个简单的问题。它们之间的区别是,在一种情况下算上节点和在根和混凝土节点之间的最短路径上的边缘的其它数数。哪个是哪个?

This is a simple question from algorithms theory. The difference between them is that in one case you count number of nodes and in other number of edges on the shortest path between root and concrete node. Which is which?

推荐答案

我了解到它作为一个的节点的具有深度和高度:

I learned it as a node having a depth and height:

  • 深度节点是从节点到树的根节点边的数量。
    一个根节点将有0的深度。

  • The depth of a node is the number of edges from the node to the tree's root node.
    A root node will have a depth of 0.

节点是边缘上的 的从节点到叶。叶节点将有多少的高度为0。

The height of a node is the number of edges on the longest path from the node to a leaf.
A leaf node will have a height of 0.

这篇关于树的深度和高度之间的区别是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆