All About Binary Tree (BT)

All About Binary Tree (BT)

Some Important Key points about Binary Tree.

ยท

2 min read

Binary Tree

Binary Tree is one of the starting part of non-linear data structure, it is one of the key concepts of Data Structures. In Binary Tree data is stored in Hierarchical order. Binary Tree is defined as a Tree data structure with 2 nodes right or left along with the data element. Each node have at most two nodes left or right.

Why we study?

The reason is Sorting. Binary search trees, a variant of binary trees are used in the implementation of sorting algorithms to order items. A binary search tree is simply an ordered or sorted binary tree such that the value in the left child is less than the value in the parent node.

binary-tree-to-DLL.png In binary tree there is no guarantee of sorted data which means, sometimes data stored in sorted manner or sometimes not, it's totally depended on the way of insertion.

Types of Binary Tree

  1. Balanced Binary Tree
  2. Full Binary Tree
  3. Perfect Binary Tree
  4. Complete Binary Tree
  5. Degenerate Binary Tree and many more...

Terminologies associated with Binary Tree

  1. Root
  2. Node
  3. Parent - The node who have a sub-node of its own.
  4. Child - Who came from the other node.
  5. Leaf Node - The node who doesn't have any child.

Traversals are the key point of Binary Tree, if you have knowledge about traversals in Binary tree then you can solve any problem related to Binary Tree with some own logics.

Some famous Traversals which have major role:

  1. In-order Traversal
  2. Preorder Traversal
  3. Post Order Traversal
  4. Vertical Order Traversal
  5. Morris Traversal

The catch on the above traversals is preorder, in-order, post-order as well as vertical order have space complexity is big o(n) but in the Morris traversal space complexity is big O(1) because Morris traversal work on the Binary thread concept.

If you learnt above points and concepts genuinely then you have to move forward and solve the famous questions on the various platform such as leetcode easily.

ย