Introduction to Tree data structures

Parag Naik
3 min readNov 5, 2021

--

In the realm of data structures, Linked list, array can be described as a linear data structure unlike trees which are non-linear, hierarchical data structures.

A tree can be defined as a collection of nodes in which node stores a value and a list referencing to children nodes. Best real life example of tress is folder structure in our computers.

Tree

What is a Binary tree?
A binary tree can be described as a data structure consisting of a node where each node has up to two child nodes that create a branches of tree. This two children are called left node and right node. Child node always contains a reference to parent node. The top most node of the tree is called the root node, the node which is left of the root node is called left node which serves as the root for the left sub tree, whereas the one to the right is called the right node which also serves as the root node for the right sub-tree.

Save tree

Types of binary trees:-
1. Full Binary Tree-A binary tree which has either 0 nodes or 2 nodes is called a full binary tree.

Full Binary Tree

2. Complete Binary tree-A binary tree in which all the levels are completely filled except the last level and the last level should have all the nodes left as possible.

Complete Binary Tree

3. Perfect Binary tree-In a perfect binary tree, all the leaf nodes are at same level.

Perfect Binary tree

4. Balance binary tree- If the height of the binary tree is O(Log n), where n is number of node such tree is a balance binary tree.

Balance binary tree

5. Degenerated tree-A degenerated tree is a tree where all the internal node has one child , such tree act like a linked list in terms of performance.

Degenerated tree

Conclusion:-
Tree data structure have many real world examples like compression algorithms, wireless networks and memory allocation. It is time to rise from ashes. cheers-PN

--

--