树的深度和高度有什么区别?

编程入门 行业动态 更新时间:2024-10-16 22:20:48
本文介绍了树的深度和高度有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

这是一个来自算法理论的简单问题.它们之间的区别在于,在一种情况下,您计算根节点和具体节点之间最短路径上的节点数和其他边数.哪个是哪个?

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 that depth and height are properties of a node:

  • 节点的深度是从节点到树根节点的边数.根节点的深度为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.

树的属性:

  • 树的高度将是其根节点的高度,或等效地,其最深节点的深度.

  • The height of a tree would be the height of its root node,or equivalently, the depth of its deepest node.

树的直径(或宽度)是任意两个叶节点之间最长路径上节点的数量.下面的树的直径为 6 个节点.

The diameter (or width) of a tree is the number of nodes on the longest path between any two leaf nodes. The tree below has a diameter of 6 nodes.

更多推荐

树的深度和高度有什么区别?

本文发布于:2023-11-29 16:12:02,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1646907.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:有什么区别   深度   高度

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!