# There are about 80+ different types of Tree Data Structure 🥴 # but we'll talk about four Tree DS now:
- Tree (general kind)( that Data Structure which has root, child node(branchs, leaves) )
- Binary Tree (That special kind of Tree that can have only Two Child Nodes)
- Binary Search Tree.
- Heap.
# ========= Binary Tree =========
# A Binary Tree could have imum of two childern. Hence, in a binary Tree, any given node could have zero, one or two nodes but not more than two 🤐. # They cannot have more than two Nodes or Children
A
/ \
D C
/ \ / \
E F I L
# ========= Binary Search Tree (BST) ============
# 'Binary Search Tree (BST) is a special kind of Binary Tree (BST), it follows Two Rules:
- The value of the Left Child Node will be smaller than the value of Parent Node
- and the value of the Right Child Node will be greater or higher the value of Parent Node.
5
/ \
2 8
/ \ / \
1 4 6 11
/ \
9 14
# ============= Heap ============
# Basically, A 'Heap' is also a special kind of 'Binary Tree'.
# When the value of any Parent Node is higher or equal to any Child Node, the Tree is called 'Max Heap' 😎
Max Heap
12
/ \
10 8
/ \ /
5 6 2
# and when the value of any Parent Node is lower or equal to any Child Node, the Tree is called 'Min Heap' 😎
Max Heap
2
/ \
3 5
/ \ /
4 6 8

0 Comments