Introduction to Trees: C++ Data Structures

Introduction to Trees:

  • 'Tree' is a data structure which is good to store hierarchical data in the computer's memory.
  • Trees are non-linear data structures.
  • It is composed of nodes and each node contains links to two or more other nodes. The links are, however, one-way links. This produces a hierarchy of nodes. Thus Trees are unidirectional in nature.
  • Trees thus are non-linear data structures.
Image result for tree data structure

Some terminologies:

Consider the image above.
The node with A on it is called the Parent Node. B, C, D are its children and A is their parent. B, C, D are siblings. E, F, G, H, I, J are grandchildren of A and latter is the grandparent of the former. Other such common relationships are also true like E and G are cousins, C is the uncle of E.

Similar such notations apply to each node. B has its children as E and F, so on and so forth.


The node with no parent is called the 'Root node of the tree, it is one per tree. And all the nodes with no children are called as leaf nodes.

Depth of node X: Length of the path from the root to x
Height of node X: the Longest path from X to a leaf node.

Trees can be divided into many categories. The most common among them is one in which any node can not have more than two children. Such type of tree is called as Binary Tree. Binary Trees are by far the most common type of trees.


Read further about Binary Trees Here: https://rishabhjainiitbhu.blogspot.com/2019/07/binary-trees-c-trees.html
Read Binary Search Trees Here: https://rishabhjainiitbhu.blogspot.com/2019/07/binary-search-tree-implementation-in-c.html

No comments:

Post a Comment

Installing albert on ubuntu 19.04

Installing Albert on Ubuntu 19.04... Albert is not still released for ubuntu 19.04. But still, you can install it using the following ...