18. If degree of all nodes in a tree is either 0, 1 or 2
A tree in which every node can have a maximum of two
children is called Binary Tree.
BINARY TREE
19. If degree of all nodes in a tree is either 0 or 2
A binary tree in which every node has either two or zero number
of children is called Strictly Binary Tree
STRICTLY BINARY TREE
20. A binary tree in which every internal node has exactly two
children and all leaf nodes are at same level is called Complete
Binary Tree.
At level L there must be 2L no. of Nodes
COMPLETE BINARY TREE
22. TREE DATA STRUCTURE:
ARRAY REPRESENTATION
0
1 2
3
4 5
6
7 8 9 10 11 12
A B C D F G H I J K
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 …..
Index computation
If n is the index of parent then,
Index of Left child: 2*n+1
Index of Right Child: 2*n+2
24. Visiting order of nodes in a binary tree is called as Binary Tree
Traversal.
Three traversals
Pre - Order Traversal (Visit-Left-Right)
In - Order Traversal (Left-Visit-Right)
Post - Order Traversal (Left-Right-Visit)
BINARY TREE TRAVERSALS
37. Inorder: DBEAFCG
Preorder: ABDECFG
TRAVERSALS ARE GIVEN
CONSTRUCT THE BINARY TREE
A
Inorder: DBE A FCG
Preorder: A BDE CFG
A
DBE
Inorder: D B E A FCG
Preorder: A B D E CFG
FCG
A
B FCG
D E
Inorder: D B E A FCG
Preorder: A B D E CFG
38. TRAVERSALS ARE GIVEN
CONSTRUCT THE BINARY TREE
A
B FCG
D E
Inorder: D B E A FCG
Preorder: A B D E CFG
A
B C
D E
Inorder: D B E A F C G
Preorder: A B D E C F G
A
B C
D E F G
Inorder: D B E A F C G
Preorder: A B D E C F G
47. Unique Binary Tree can be constructed from
Inorder and Preorder sequences
Inorder and Postorder sequences
But Preorder and Postorder sequences do not guarantee
construction of Unique Binary Tree.
ANALYSIS
48. Recursive traversals make implicit use of Stack
Non-Recursive traversals make explicit use of Stack
NON RECURSIVE TRAVERSAL
55. For all Internal Nodes
Value of Left child node is less than the value of all its ancestors
Value of Right child node is greater than the value of all its ancestors
BINARY SEARCH TREE (BST)
45
12 67
-2 34 50 79
56. In-order traversal of BST is a sorted list of elements in
ascending order
BINARY SEARCH TREE (BST)
Pre-order: 45 12 -2 34 67 50 79
In-order: -2 12 34 45 67 50 79
Post-order: -2 34 12 50 79 67 45
57. Empty NULL pointers are used as threads
Threaded Binary Tree
Single Threaded
Left threaded
Right threaded
Fully threaded
In the left threaded mode if some node has no left child, then
the left pointer will point to its inorder predecessor
In the right threaded mode if some node has no right child,
then the right pointer will point to its inorder successor I
If no successor or predecessor is present, then it will point to
header node.
THREADED BINARY TREE
58. 45
12 67
-2 34 50 79
SINGLE THREADED BINARY TREE
(LEFT THREADED)
59. 45
12 67
-2 34 50 79
SINGLE THREADED BINARY TREE
(RIGHT THREADED)
61. Adelson, Velski & Landis
AVL trees are height balancing binary search tree.
The difference between heights of left and right subtrees
cannot be more than one for all nodes.
AVL TREE
63. Binary search tree: Traversal, searching, insertion and
deletion in binary search tree. Threaded Binary Tree: Finding
in-order successor and predecessor of a node in threaded
tree. Insertion and deletion in threaded binary tree. AVL Tree:
Searching and traversing in AVL trees. Tree Rotations: Right
Rotation, Left Rotation. Insertion and Deletion in an AVL Tree.
B-tree: Searching, Insertion, Deletion from leaf node and non-
leaf node.
B+ Tree, Digital Search Tree, Game Tree & Decision Tree