📜  一般树和二叉树的区别

📅  最后修改于: 2021-09-12 11:34:24             🧑  作者: Mango


一般树:
在数据结构中,一般树是一个树,其中每个节点可以有零个或多个子节点。它不能为空。在一般树中,节点的度数没有限制。一般树的最顶层节点称为根节点。一般树中有很多子树。一般树的子树是无序的,因为一般树的节点不能按照特定的标准进行排序。在一般树中,每个节点的入度(父节点数)为 1,最大出度(子节点数)为 n。

二叉树:
二叉树是通用树的特殊版本。二叉树是每个节点最多可以有两个节点的树。在二叉树中,节点的度数是有限制的,因为二叉树中的节点不能有两个以上的子节点(或度数为二)。二叉树的最顶层节点称为根节点,主要有两种子树,一种是左子树,一种是右子树。与一般树不同,二叉树可以是空的。与一般树不同,二叉树的子树是有序的,因为二叉树的节点可以按照特定的标准进行排序。

一般树和二叉树的区别

General tree Binary tree
General tree is a tree in which each node can have many children or nodes. Whereas in binary tree, each node can have at most two nodes.
The subtree of a general tree do not hold the ordered property. While the subtree of binary tree hold the ordered property.
In data structure, a general tree can not be empty. While it can be empty.
In general tree, a node can have at most n(number of child nodes) nodes. While in binary tree, a node can have at most 2(number of child nodes) nodes.
In general tree, there is no limitation on the degree of a node. While in binary tree, there is limitation on the degree of a node because the nodes in a binary tree can’t have more than two child node.
In general tree, there is either zero subtree or many subtree. While in binary tree, there are mainly two subtree: Left-subtree and Right-subtree.

如果您希望与专家一起参加现场课程,请参阅DSA 现场工作专业课程学生竞争性编程现场课程。