12.Binary Search Tree & Threaded Binary Tree
12.Binary Search Tree & Threaded Binary Tree
Binary search trees provide an excellent structure for searching a list and at the same
time for inserting and deleting data into the list.
•All items in the left of the tree are less than the root.
•All items in the right subtree are greater than or equal to the root.
• Traversal
• Search
• Insertion
• Deletion
Preorder Traversal : 23 18 12 20 44 35 52
Post order Traversal: 12 20 8 35 52 44 23
In order Traversal: 12 18 20 23 35 44 52
2. Insert 39, 22, 99, 67, 42, 60, 42, 77, 86, 14, 5, 13
3. Insert 3,7,9,2,3,4,6,11,1
2. Delete 17
3. Delete 54
➢ In a threaded BST, null pointers are replaced with pointers to the successor node
in a specific traversal order.
Inorder traversal of a Binary tree can either be done using recursion or with the use of stack.
The idea of threaded binary trees is to make inorder traversal faster and do it without stack and without
recursion.
A binary tree is made threaded by making all right child pointers that would normally be NULL point to the
inorder successor of the node (if it exists).