What is Tree Data Structure? | Data Structure Tutorial
In this article, you will learn about the Tree Data Structure and other different types of trees.
A tree is a non-linear hierarchical data structure. It consists of a node that is connected by the edges.
Why use the Tree Data Structure?
Linear data structures such as arrays, linked list, stack, and queue stores the data in sequential form. When the size of the linear data structure is expanded, the time complexity also increases. The tree data structure allows the user to have quicker and easier access to the data or the information that can only happen in the linear data structure.
Tree Terminologies
Node: A node always contains a key or values and the address of its child node through pointers. The last nodes of each path in the tree are called external nodes or leaf nodes that do not contain any link/pointer to the child nodes. The node that contains at least one child node is called an internal node.
Edge: It helps in connecting the two nodes. It is kind of linking the two nodes.
Root: The topmost node of the tree is known as the Root.
Height of a Node: The height of a node is the number of edges connected from the node to the deepest leaf. It means longest the path from the node to a leaf node
Depth of a node: The depth of the node is calculated with the number of edges from the root to the node.
Height of a Tree: The height of a Tree is calculated from the height of the root node or the depth of the deepest node.
Degree of a Node: The degree of the node is the number of branches connected with the node.
Forest: A set of disjoint trees is called a forest. The forest can be created by cutting the root of a tree.
Types of tree
- AVL Tree
- B-Tree
- BST (Binary Search Tree)
- Binary Tree
Applications of Tree:
- Heap is a kind of tree that is particularly used for heap sort.
- Binary Search Trees (BSTs) are used to verify whether an element is present or not.
- The updated version of a tree is called tries which are used in modern routers to store the routing data.


