Assignment No-04
Assignment No-04
Title: Study & Implementation of threaded binary tree and operation associated with TBT
Objectives:
1. learn about the abstract data type of TBT
2. make students able to implement threaded binary tree to solve several real-life problems.
3. To understand different operations on threaded binary tree.
Theory:
Threaded Binary Tree: In the linked representation of binary trees, more than one half of the
link fields contain NULL values which results in wastage of storage space. If a binary tree
consists of n nodes then n+1 link fields contain NULL values. So in order to effectively manage
the space, a method was devised by Perlis and Thornton in which the NULL links are replaced
with special links known as threads. Such binary trees with threads are known as threaded
binary trees. Each node in a threaded binary tree either contains a link to its child node or thread
to other nodes in the tree.
large trees in memory, we might need to save up on the extra space invested in the recursion
depth. A threaded binary tree is advantageous in such scenarios where space usage is critical
1. Initialize: Set current to the leftmost node of the tree using the Leftmost(root) function
2. Traversal Loop: While current is not null, repeat the following steps
3. Process Node: Process the current node by performing the desired action using the
ProcessNode function
a. If the current node has a right thread: Set current to the node's right thread
b. Else: Set current to the leftmost node in the right subtree using
Leftmost(current.rightChild)
6. Finish: The algorithm completes when all nodes in the threaded binary tree are
processed
Task:
Create in order threaded binary search tree and implement following operations
3. Convert given binary search tree into threaded binary search tree.
(Note: Here students will write the algorithms for all operations mentioned in above task)
Conclusion: