0% found this document useful (0 votes)
0 views2 pages

Assignment No-04

The document outlines an assignment focused on the study and implementation of threaded binary trees (TBT), emphasizing their advantages in space management. It includes objectives for learning about TBT, implementing it for real-life problems, and understanding various operations. Additionally, it provides an algorithm for inorder traversal and tasks for creating and manipulating a threaded binary search tree.

Uploaded by

Someone Random
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
0 views2 pages

Assignment No-04

The document outlines an assignment focused on the study and implementation of threaded binary trees (TBT), emphasizing their advantages in space management. It includes objectives for learning about TBT, implementing it for real-life problems, and understanding various operations. Additionally, it provides an algorithm for inorder traversal and tasks for creating and manipulating a threaded binary search tree.

Uploaded by

Someone Random
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

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.

Figure 1: Threaded Binary Tree


In applications where we have a constraint of space, or even when there is a use case of storing

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

Algorithm for Inorder Traversal of Threaded Binary Tree

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

4. Move to In-Order Successor:

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)

5. Repeat: Go back to step 2 until all nodes are visited

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

1. Insert a new node 2. Inorder and preorder traversal

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:

You might also like