Signup/Sign In
PUBLISHED ON: JUNE 26, 2022

Difference Between General Tree and Binary Tree

Introduction

Both of these data formats are based on nodes. We'll look at the key differences between binary trees and binary search trees in this post. Before we go into the distinctions, let's learn a little more about each of them.

What is General Tree?

A general tree is a data structure in which each node may have either zero or many child nodes. It can't possibly be empty. The degree of a node in a generic tree is unrestricted. The root node is the topmost node in a generic tree. A generic tree has a lot of subtrees. Because the nodes of the general tree cannot be arranged according to specified criteria, the subtree of a general tree is unordered. Each node has one in-degree (number of parent nodes) and n maximum out-degree (number of child nodes) in a generic tree.

What is Binary Tree?

The binary tree is a more advanced form of the general tree. A binary tree is one in which each node may only have two children. The degree of a node in a binary tree is limited because nodes in a binary tree may have no more than two child nodes (or degree two). The root node is the topmost node in a binary tree, and there are primarily two subtrees: left-subtree and right-subtree. The binary tree, unlike the normal tree, may be empty. The subtree of a binary tree is ordered, unlike the general tree, since the nodes of a binary tree may be arranged according to specified criteria.

Comparison Table Between General Tree and Binary Tree

General Tree Binary Tree
  • A generic tree is a data structure with an endless number of offspring for each node.
  • A binary tree is a data structure with at most two nodes to the left and right of each node.
  • It's impossible for a General tree to be empty.
  • It is possible for a Binary tree to be empty.
  • In a generic tree, there is no limit to the degree of node.
  • A binary tree's nodes can't have more than two degrees.
  • The subtrees of the general tree are not arranged in any particular sequence.
  • The binary tree's subtrees are sorted.
  • The root of a tree has an in-degree of 0 and a maximum out-degree of n.
  • The root of a binary tree has an in-degree of 0 and a maximum out-degree of 2.
  • Each node in a generic tree has an in-degree of one and a maximum out-degree of n.
  • Each node in a binary tree has an in-degree of one and a maximum out-degree of two.

Conclusion

A tree is a data structure with several nodes, one of which is the root and the others are the root's offspring nodes. A binary tree is a particular form of tree. The major difference between a tree and a binary tree is that a tree organises data in a hierarchical structure, while a binary tree is a sort of tree in which a parent node may only have two child nodes.



About the author:
Adarsh Kumar Singh is a technology writer with a passion for coding and programming. With years of experience in the technical field, he has established a reputation as a knowledgeable and insightful writer on a range of technical topics.