SlideShare a Scribd company logo
Presented to:
Md. Shamsujjoha
 Senior Lecturer of CSE department
 East West University
Presented by:
 Md. Khabbab Hossain Tusher
 Date:03/04/2016
Threaded binary tree
A binary search tree in which each node uses an otherwise-empty left
child link to refer to the node's in-order predecessor and an empty
right child link to refer to its in-Order Successor.
Definition
Slide 1
A Simple Binary Tree
A
B
D
E
C
GF
Slide 2
A
B C
Null D Null Null E Null Null G NullNull F Null
Slide 3
Threaded binary tree
Threaded Binary Tree
 In above binary tree, there are 8 null pointers & actual 6
pointers.
 In all there are 14 pointers.
 We can generalize it that for any binary tree with n nodes
there will be (n+1) null pointers and 2n total pointers.
 The objective here to make effective use of these null
pointers.
 A. J. perils & C. Thornton jointly proposed idea to make
effective use of these null pointers.
 According to this idea we are going to replace all the null
pointers by the appropriate pointer values called threads.
Slide 4
 And binary tree with such pointers are called threaded tree.
 In the memory representation of a threaded binary tree, it is necessary
to distinguish between a normal pointer and a thread.
Slide 5
Threaded Binary Tree:
One-Way
 We will use the right thread only in this case.
 To implement threads we need to use in-order successor of the tree
Slide 6
Threaded Binary Tree:
One-Way
A
B C
Null D Null E Null G NullNull F
Inorder Traversal of The tree: D, B, E, A, F, C, G
Slide 7
Two way Threaded Tree/Double Threads
 Again two-way threading has left pointer of the first node and right
pointer of the last node will contain the null value. The header nodes
is called two-way threading with header node threaded binary tree.
Slide 8
A
B
D
Inorder Traversal of The tree: D, B, E, A, F, C, G
E
C
F G
Dangling
Dangling
Slide 9
• Dangling can be solved as follows
 Introduce a header node.
 The left and right pointer of the header node are treated as normal
links and are initialized to point to header node itself.
Slide 10
A
B
D
Inorder Traversal of The tree: D, B, E, A, F, C, G
E
C
F G
Head
Slide 11
Structure of Thread BT
Node structure
For the purpose of our evaluation algorithm, we assume each
node has five fields:
LTag Left data Right RTag
We define this node structure in C as:
Struct Node{
int data;
struct Node *Left,*Right;
bool Ltag;
boolRtag;
};
Slide 12
L.Tag L.Child head R.child
R.Tag
1 A 1
1 1
0 D 0 0 E 0 0 F 0 0 G 0
1 B 1 1 C 1
Inorder Traversal of The tree: D B E A F C G
Slide 13
Threaded Tree Traversal
• We start at the leftmost node in the tree, print it, and follow
its right thread
• If we follow a thread to the right, we output the node and
continue to its right.
• If we follow a link to the right, we go to the leftmost node,
print it, and continue.
Slide 14
8
75
3
1
6
Start at leftmost node, print it
Output
1
9
Slide 15
8
75
3
1
6
Follow thread to right, print node
Output
1
3
9
Slide 16
8
75
3
1
6
Follow link to right, go to leftmost
node and print
Output
1
3
5
9
Slide 17
8
75
3
1
6
Follow thread to right, print node
Output
1
3
5
6
9
Slide 18
8
75
3
1
6
Follow link to right, go to
leftmost node and print
Output
1
3
5
6
7
9
Slide 19
8
75
3
1
6
9
Follow thread to right, print node
Output
1
3
5
6
7
8
Slide 20
8
75
3
91
6
Follow link to right, go to
leftmost node and print
Output
1
3
5
6
7
8
9
Slide 21
void inOrder(struct Node *root)
{
struct Node *cur = leftmost(root);
while (cur != NULL)
 {
 printf("%d ", cur->data);

 // If this node is a thread node,
then go to
// inorder successor
 if (cur->rightThread)
 cur = cur->right;
 else // Else go to the leftmost child
in right subtree
 cur = leftmost(cur->right);
 }
 }
8
75
3
1
6
9
Slide 22
Threaded Binary Trees
 In threaded binary trees, The
null pointers are used as thread.
 We can use the null pointers
which is a efficient way to use
computers memory.
 Traversal is easy. Completed
without using stack or
reccursive function.
 Structure is complex.
 Insertion and deletion takes
more time.
Normal Binary Trees
 In a normal binary trees, the null
pointers remains null.
 We can’t use null pointers so it is a
wastage of memory.
 Traverse is not easy and not
memory efficient.
 Less complex than Threaded binary
tree.
 Less Time consuming than
Threaded Binary tree.
Comparison of Threaded BT
Slide 23
 Inserting a node to Threaded Binary Tree:
Inserting a node X as the right child of a nodes.
1st Case:
- If G has an empty right subtree, then the insertion is simple
Slide 24
A
B
D
Inserting X as a right child of G
E
C
F G
Head
X
New inorder traversal is: D,B,E,A,F,C,G,X
Slide 25
2nd Case:
If the right subtree of C is not empty, then this right child is made
the right child of X after insertion.
Slide 26
A
B
D
New Inorder Traversal of The tree: D, B, E, A, F, C, X,G
E
F
G
Head
x
C
Slide 27
Advantage
 1. By doing threading we avoid
the recursive method of
traversing a Tree , which doesn’t
use of stack and consumes a lot
of memory and time .
 2 . The node can keep record of
its root .
 3. Backward Traverse is
possible.
 4. Applicable in most types of
the binary tree.
Disadvantage
 1. This makes the Tree more
complex .
 2. More prone to errors when
both the child are not present &
both values of nodes pointer to
their ancestors.
 3. Lot of time consumes when
deletion or insertion is
performed.
Threaded binary tree
Slide 28
 Same as any kind of Binary Tree.
 Used in search and Traverse
based work
APPLICATIONS
Slide 29
Conclusion
 Excellent concept in modern computer science.
 Saves Time and memory.
 Traversal and search are very efficient.
 Insertion and deletion are not so efficient.
Slide 30
References
 http://www.geeksforgeeks.org/inorder-tree-traversal-without-
recursion-and-without-stack/
 http://www.delorie.com/gnu/docs/avl/libavl_183.html
 http://www.math-
cs.gordon.edu/courses/cs321/lectures/threaded.html
 https://prezi.com/1yitau0wnwlg/threaded-binary-tree-in-data-
structures/
 http://stackoverflow.com/questions/6744770/confusion-with-
threaded-binary-tree
 Various Text Book for data structure.
Contacts us
:tkhabbab@gmail.com/
khabbabcse@ewu.edu.bd

More Related Content

What's hot

Lec 17 heap data structure
Lec 17 heap data structureLec 17 heap data structure
Lec 17 heap data structureSajid Marwat
 
Graph traversals in Data Structures
Graph traversals in Data StructuresGraph traversals in Data Structures
Graph traversals in Data Structures
Anandhasilambarasan D
 
Queue ppt
Queue pptQueue ppt
Queue ppt
SouravKumar328
 
B and B+ tree
B and B+ treeB and B+ tree
B and B+ tree
Ashish Arun
 
Graph in data structure
Graph in data structureGraph in data structure
Graph in data structure
Abrish06
 
sorting and its types
sorting and its typessorting and its types
sorting and its types
SIVASHANKARIRAJAN
 
Hashing
HashingHashing
Hashing
Amar Jukuntla
 
Red black tree
Red black treeRed black tree
Red black tree
Dr Sandeep Kumar Poonia
 
trees in data structure
trees in data structure trees in data structure
trees in data structure
shameen khan
 
Trees, Binary Search Tree, AVL Tree in Data Structures
Trees, Binary Search Tree, AVL Tree in Data Structures Trees, Binary Search Tree, AVL Tree in Data Structures
Trees, Binary Search Tree, AVL Tree in Data Structures
Gurukul Kangri Vishwavidyalaya - Faculty of Engineering and Technology
 
Tree Traversal
Tree TraversalTree Traversal
Tree Traversal
Md. Israil Fakir
 
Binary search tree(bst)
Binary search tree(bst)Binary search tree(bst)
Binary search tree(bst)
Hossain Md Shakhawat
 
Deque and its applications
Deque and its applicationsDeque and its applications
Deque and its applicationsJsaddam Hussain
 
Binary Search
Binary SearchBinary Search
Binary Search
kunj desai
 
Graph representation
Graph representationGraph representation
Graph representationTech_MX
 
Binary Tree Traversal
Binary Tree TraversalBinary Tree Traversal
Binary Tree Traversal
Dhrumil Panchal
 
Tree in data structure
Tree in data structureTree in data structure
Tree in data structureghhgj jhgh
 
Doubly Linked List
Doubly Linked ListDoubly Linked List
Doubly Linked List
Ninad Mankar
 
DATA STRUCTURES
DATA STRUCTURESDATA STRUCTURES
DATA STRUCTURES
bca2010
 

What's hot (20)

AVL Tree
AVL TreeAVL Tree
AVL Tree
 
Lec 17 heap data structure
Lec 17 heap data structureLec 17 heap data structure
Lec 17 heap data structure
 
Graph traversals in Data Structures
Graph traversals in Data StructuresGraph traversals in Data Structures
Graph traversals in Data Structures
 
Queue ppt
Queue pptQueue ppt
Queue ppt
 
B and B+ tree
B and B+ treeB and B+ tree
B and B+ tree
 
Graph in data structure
Graph in data structureGraph in data structure
Graph in data structure
 
sorting and its types
sorting and its typessorting and its types
sorting and its types
 
Hashing
HashingHashing
Hashing
 
Red black tree
Red black treeRed black tree
Red black tree
 
trees in data structure
trees in data structure trees in data structure
trees in data structure
 
Trees, Binary Search Tree, AVL Tree in Data Structures
Trees, Binary Search Tree, AVL Tree in Data Structures Trees, Binary Search Tree, AVL Tree in Data Structures
Trees, Binary Search Tree, AVL Tree in Data Structures
 
Tree Traversal
Tree TraversalTree Traversal
Tree Traversal
 
Binary search tree(bst)
Binary search tree(bst)Binary search tree(bst)
Binary search tree(bst)
 
Deque and its applications
Deque and its applicationsDeque and its applications
Deque and its applications
 
Binary Search
Binary SearchBinary Search
Binary Search
 
Graph representation
Graph representationGraph representation
Graph representation
 
Binary Tree Traversal
Binary Tree TraversalBinary Tree Traversal
Binary Tree Traversal
 
Tree in data structure
Tree in data structureTree in data structure
Tree in data structure
 
Doubly Linked List
Doubly Linked ListDoubly Linked List
Doubly Linked List
 
DATA STRUCTURES
DATA STRUCTURESDATA STRUCTURES
DATA STRUCTURES
 

Viewers also liked

Threaded binarytree&heapsort
Threaded binarytree&heapsortThreaded binarytree&heapsort
Threaded binarytree&heapsortSsankett Negi
 
THREADED BINARY TREE AND BINARY SEARCH TREE
THREADED BINARY TREE AND BINARY SEARCH TREETHREADED BINARY TREE AND BINARY SEARCH TREE
THREADED BINARY TREE AND BINARY SEARCH TREE
Siddhi Shrivas
 
Trees data structure
Trees data structureTrees data structure
Trees data structure
Sumit Gupta
 
(Binary tree)
(Binary tree)(Binary tree)
(Binary tree)
almario1988
 
Binary tree
Binary  treeBinary  tree
Binary tree
Vanitha Chandru
 
Full threded binary tree
Full threded binary treeFull threded binary tree
Full threded binary tree
Soham Kansodaria
 
Representation of binary tree in memory
Representation of binary tree in memoryRepresentation of binary tree in memory
Representation of binary tree in memoryRohini Shinde
 
Queue data structure
Queue data structureQueue data structure
Queue data structure
anooppjoseph
 
358 33 powerpoint-slides_11-efficient-binary-trees_chapter-11
358 33 powerpoint-slides_11-efficient-binary-trees_chapter-11358 33 powerpoint-slides_11-efficient-binary-trees_chapter-11
358 33 powerpoint-slides_11-efficient-binary-trees_chapter-11
sumitbardhan
 
16 Fibonacci Heaps
16 Fibonacci Heaps16 Fibonacci Heaps
16 Fibonacci Heaps
Andres Mendez-Vazquez
 
Rfid
RfidRfid
358 33 powerpoint-slides_12-heaps_chapter-12
358 33 powerpoint-slides_12-heaps_chapter-12358 33 powerpoint-slides_12-heaps_chapter-12
358 33 powerpoint-slides_12-heaps_chapter-12
sumitbardhan
 
data structure, stack, stack data structure
data structure, stack, stack data structuredata structure, stack, stack data structure
data structure, stack, stack data structurepcnmtutorials
 
Array data structure
Array data structureArray data structure
Array data structure
maamir farooq
 
Programming in c++
Programming in c++Programming in c++
Programming in c++
Christalin Nelson
 
data structure(tree operations)
data structure(tree operations)data structure(tree operations)
data structure(tree operations)
Waheed Khalid
 
Set data structure
Set data structure Set data structure
Set data structure Tech_MX
 
Data Structures
Data StructuresData Structures
Data Structures
Nitesh Bichwani
 

Viewers also liked (20)

Threaded binarytree&heapsort
Threaded binarytree&heapsortThreaded binarytree&heapsort
Threaded binarytree&heapsort
 
THREADED BINARY TREE AND BINARY SEARCH TREE
THREADED BINARY TREE AND BINARY SEARCH TREETHREADED BINARY TREE AND BINARY SEARCH TREE
THREADED BINARY TREE AND BINARY SEARCH TREE
 
Trees data structure
Trees data structureTrees data structure
Trees data structure
 
(Binary tree)
(Binary tree)(Binary tree)
(Binary tree)
 
Binary tree
Binary  treeBinary  tree
Binary tree
 
Full threded binary tree
Full threded binary treeFull threded binary tree
Full threded binary tree
 
Representation of binary tree in memory
Representation of binary tree in memoryRepresentation of binary tree in memory
Representation of binary tree in memory
 
Queue data structure
Queue data structureQueue data structure
Queue data structure
 
358 33 powerpoint-slides_11-efficient-binary-trees_chapter-11
358 33 powerpoint-slides_11-efficient-binary-trees_chapter-11358 33 powerpoint-slides_11-efficient-binary-trees_chapter-11
358 33 powerpoint-slides_11-efficient-binary-trees_chapter-11
 
16 Fibonacci Heaps
16 Fibonacci Heaps16 Fibonacci Heaps
16 Fibonacci Heaps
 
Rfid
RfidRfid
Rfid
 
358 33 powerpoint-slides_12-heaps_chapter-12
358 33 powerpoint-slides_12-heaps_chapter-12358 33 powerpoint-slides_12-heaps_chapter-12
358 33 powerpoint-slides_12-heaps_chapter-12
 
Heap tree
Heap treeHeap tree
Heap tree
 
data structure, stack, stack data structure
data structure, stack, stack data structuredata structure, stack, stack data structure
data structure, stack, stack data structure
 
Array data structure
Array data structureArray data structure
Array data structure
 
Programming in c++
Programming in c++Programming in c++
Programming in c++
 
data structure(tree operations)
data structure(tree operations)data structure(tree operations)
data structure(tree operations)
 
Set data structure
Set data structure Set data structure
Set data structure
 
Fibonacci Heap
Fibonacci HeapFibonacci Heap
Fibonacci Heap
 
Data Structures
Data StructuresData Structures
Data Structures
 

Similar to Threaded Binary Tree

Trees unit 3
Trees unit 3Trees unit 3
Trees unit 3
praveena p
 
Tree and Binary Search tree
Tree and Binary Search treeTree and Binary Search tree
Tree and Binary Search tree
Muhazzab Chouhadry
 
Trees in Data Structure
Trees in Data StructureTrees in Data Structure
Trees in Data Structure
Prof Ansari
 
Data Structures and Agorithm: DS 10 Binary Search Tree.pptx
Data Structures and Agorithm: DS 10 Binary Search Tree.pptxData Structures and Agorithm: DS 10 Binary Search Tree.pptx
Data Structures and Agorithm: DS 10 Binary Search Tree.pptx
RashidFaridChishti
 
introduction to_trees
introduction to_treesintroduction to_trees
introduction to_trees
Danish Aakash
 
Basics of Binary Tree and Binary Search Tree.pptx
Basics of Binary Tree and Binary Search Tree.pptxBasics of Binary Tree and Binary Search Tree.pptx
Basics of Binary Tree and Binary Search Tree.pptx
BhagyashriKotame2
 
VCE Unit 05.pptx
VCE Unit 05.pptxVCE Unit 05.pptx
VCE Unit 05.pptx
skilljiolms
 
Trees in data structure
Trees in data structureTrees in data structure
Trees in data structure
Anusruti Mitra
 
Trees in Data Structure
Trees in Data StructureTrees in Data Structure
Trees in Data Structure
Om Prakash
 
Unit 6 tree
Unit   6 treeUnit   6 tree
Unit 6 tree
Dabbal Singh Mahara
 
Chapter 09-Trees
Chapter 09-TreesChapter 09-Trees
Chapter 09-Trees
MuhammadBakri13
 
Binary trees
Binary treesBinary trees
Binary treesAmit Vats
 
Unit 4.1 (tree)
Unit 4.1 (tree)Unit 4.1 (tree)
Unit 4.1 (tree)
DurgaDeviCbit
 
Heap tree
Heap treeHeap tree
Heap tree
JananiJ19
 
The dag representation of basic blocks
The dag representation of basic blocksThe dag representation of basic blocks
The dag representation of basic blocks
Shabeen Taj
 
unit06-3-Trees.pdf
unit06-3-Trees.pdfunit06-3-Trees.pdf
unit06-3-Trees.pdf
AnmolYadav509681
 
trees-and-graphs_computer_science_for_student.pptx
trees-and-graphs_computer_science_for_student.pptxtrees-and-graphs_computer_science_for_student.pptx
trees-and-graphs_computer_science_for_student.pptx
TanvirAhmed166122
 

Similar to Threaded Binary Tree (20)

Trees unit 3
Trees unit 3Trees unit 3
Trees unit 3
 
Tree and Binary Search tree
Tree and Binary Search treeTree and Binary Search tree
Tree and Binary Search tree
 
Unit 3.ppt
Unit 3.pptUnit 3.ppt
Unit 3.ppt
 
Trees in Data Structure
Trees in Data StructureTrees in Data Structure
Trees in Data Structure
 
Data Structures and Agorithm: DS 10 Binary Search Tree.pptx
Data Structures and Agorithm: DS 10 Binary Search Tree.pptxData Structures and Agorithm: DS 10 Binary Search Tree.pptx
Data Structures and Agorithm: DS 10 Binary Search Tree.pptx
 
introduction to_trees
introduction to_treesintroduction to_trees
introduction to_trees
 
Basics of Binary Tree and Binary Search Tree.pptx
Basics of Binary Tree and Binary Search Tree.pptxBasics of Binary Tree and Binary Search Tree.pptx
Basics of Binary Tree and Binary Search Tree.pptx
 
Unit8 C
Unit8 CUnit8 C
Unit8 C
 
VCE Unit 05.pptx
VCE Unit 05.pptxVCE Unit 05.pptx
VCE Unit 05.pptx
 
Trees in data structure
Trees in data structureTrees in data structure
Trees in data structure
 
Trees in Data Structure
Trees in Data StructureTrees in Data Structure
Trees in Data Structure
 
Unit 6 tree
Unit   6 treeUnit   6 tree
Unit 6 tree
 
Chapter 09-Trees
Chapter 09-TreesChapter 09-Trees
Chapter 09-Trees
 
Binary trees
Binary treesBinary trees
Binary trees
 
Unit 4.1 (tree)
Unit 4.1 (tree)Unit 4.1 (tree)
Unit 4.1 (tree)
 
Heap tree
Heap treeHeap tree
Heap tree
 
The dag representation of basic blocks
The dag representation of basic blocksThe dag representation of basic blocks
The dag representation of basic blocks
 
Lec15
Lec15Lec15
Lec15
 
unit06-3-Trees.pdf
unit06-3-Trees.pdfunit06-3-Trees.pdf
unit06-3-Trees.pdf
 
trees-and-graphs_computer_science_for_student.pptx
trees-and-graphs_computer_science_for_student.pptxtrees-and-graphs_computer_science_for_student.pptx
trees-and-graphs_computer_science_for_student.pptx
 

Recently uploaded

SOCRadar Germany 2024 Threat Landscape Report
SOCRadar Germany 2024 Threat Landscape ReportSOCRadar Germany 2024 Threat Landscape Report
SOCRadar Germany 2024 Threat Landscape Report
SOCRadar
 
Algorithmic optimizations for Dynamic Levelwise PageRank (from STICD) : SHORT...
Algorithmic optimizations for Dynamic Levelwise PageRank (from STICD) : SHORT...Algorithmic optimizations for Dynamic Levelwise PageRank (from STICD) : SHORT...
Algorithmic optimizations for Dynamic Levelwise PageRank (from STICD) : SHORT...
Subhajit Sahu
 
Q1’2024 Update: MYCI’s Leap Year Rebound
Q1’2024 Update: MYCI’s Leap Year ReboundQ1’2024 Update: MYCI’s Leap Year Rebound
Q1’2024 Update: MYCI’s Leap Year Rebound
Oppotus
 
Adjusting primitives for graph : SHORT REPORT / NOTES
Adjusting primitives for graph : SHORT REPORT / NOTESAdjusting primitives for graph : SHORT REPORT / NOTES
Adjusting primitives for graph : SHORT REPORT / NOTES
Subhajit Sahu
 
Chatty Kathy - UNC Bootcamp Final Project Presentation - Final Version - 5.23...
Chatty Kathy - UNC Bootcamp Final Project Presentation - Final Version - 5.23...Chatty Kathy - UNC Bootcamp Final Project Presentation - Final Version - 5.23...
Chatty Kathy - UNC Bootcamp Final Project Presentation - Final Version - 5.23...
John Andrews
 
一比一原版(QU毕业证)皇后大学毕业证成绩单
一比一原版(QU毕业证)皇后大学毕业证成绩单一比一原版(QU毕业证)皇后大学毕业证成绩单
一比一原版(QU毕业证)皇后大学毕业证成绩单
enxupq
 
一比一原版(UPenn毕业证)宾夕法尼亚大学毕业证成绩单
一比一原版(UPenn毕业证)宾夕法尼亚大学毕业证成绩单一比一原版(UPenn毕业证)宾夕法尼亚大学毕业证成绩单
一比一原版(UPenn毕业证)宾夕法尼亚大学毕业证成绩单
ewymefz
 
Criminal IP - Threat Hunting Webinar.pdf
Criminal IP - Threat Hunting Webinar.pdfCriminal IP - Threat Hunting Webinar.pdf
Criminal IP - Threat Hunting Webinar.pdf
Criminal IP
 
一比一原版(CBU毕业证)不列颠海角大学毕业证成绩单
一比一原版(CBU毕业证)不列颠海角大学毕业证成绩单一比一原版(CBU毕业证)不列颠海角大学毕业证成绩单
一比一原版(CBU毕业证)不列颠海角大学毕业证成绩单
nscud
 
做(mqu毕业证书)麦考瑞大学毕业证硕士文凭证书学费发票原版一模一样
做(mqu毕业证书)麦考瑞大学毕业证硕士文凭证书学费发票原版一模一样做(mqu毕业证书)麦考瑞大学毕业证硕士文凭证书学费发票原版一模一样
做(mqu毕业证书)麦考瑞大学毕业证硕士文凭证书学费发票原版一模一样
axoqas
 
一比一原版(RUG毕业证)格罗宁根大学毕业证成绩单
一比一原版(RUG毕业证)格罗宁根大学毕业证成绩单一比一原版(RUG毕业证)格罗宁根大学毕业证成绩单
一比一原版(RUG毕业证)格罗宁根大学毕业证成绩单
vcaxypu
 
Empowering Data Analytics Ecosystem.pptx
Empowering Data Analytics Ecosystem.pptxEmpowering Data Analytics Ecosystem.pptx
Empowering Data Analytics Ecosystem.pptx
benishzehra469
 
一比一原版(BU毕业证)波士顿大学毕业证成绩单
一比一原版(BU毕业证)波士顿大学毕业证成绩单一比一原版(BU毕业证)波士顿大学毕业证成绩单
一比一原版(BU毕业证)波士顿大学毕业证成绩单
ewymefz
 
1.Seydhcuxhxyxhccuuxuxyxyxmisolids 2019.pptx
1.Seydhcuxhxyxhccuuxuxyxyxmisolids 2019.pptx1.Seydhcuxhxyxhccuuxuxyxyxmisolids 2019.pptx
1.Seydhcuxhxyxhccuuxuxyxyxmisolids 2019.pptx
Tiktokethiodaily
 
Opendatabay - Open Data Marketplace.pptx
Opendatabay - Open Data Marketplace.pptxOpendatabay - Open Data Marketplace.pptx
Opendatabay - Open Data Marketplace.pptx
Opendatabay
 
Malana- Gimlet Market Analysis (Portfolio 2)
Malana- Gimlet Market Analysis (Portfolio 2)Malana- Gimlet Market Analysis (Portfolio 2)
Malana- Gimlet Market Analysis (Portfolio 2)
TravisMalana
 
哪里卖(usq毕业证书)南昆士兰大学毕业证研究生文凭证书托福证书原版一模一样
哪里卖(usq毕业证书)南昆士兰大学毕业证研究生文凭证书托福证书原版一模一样哪里卖(usq毕业证书)南昆士兰大学毕业证研究生文凭证书托福证书原版一模一样
哪里卖(usq毕业证书)南昆士兰大学毕业证研究生文凭证书托福证书原版一模一样
axoqas
 
Levelwise PageRank with Loop-Based Dead End Handling Strategy : SHORT REPORT ...
Levelwise PageRank with Loop-Based Dead End Handling Strategy : SHORT REPORT ...Levelwise PageRank with Loop-Based Dead End Handling Strategy : SHORT REPORT ...
Levelwise PageRank with Loop-Based Dead End Handling Strategy : SHORT REPORT ...
Subhajit Sahu
 
FP Growth Algorithm and its Applications
FP Growth Algorithm and its ApplicationsFP Growth Algorithm and its Applications
FP Growth Algorithm and its Applications
MaleehaSheikh2
 
一比一原版(UofM毕业证)明尼苏达大学毕业证成绩单
一比一原版(UofM毕业证)明尼苏达大学毕业证成绩单一比一原版(UofM毕业证)明尼苏达大学毕业证成绩单
一比一原版(UofM毕业证)明尼苏达大学毕业证成绩单
ewymefz
 

Recently uploaded (20)

SOCRadar Germany 2024 Threat Landscape Report
SOCRadar Germany 2024 Threat Landscape ReportSOCRadar Germany 2024 Threat Landscape Report
SOCRadar Germany 2024 Threat Landscape Report
 
Algorithmic optimizations for Dynamic Levelwise PageRank (from STICD) : SHORT...
Algorithmic optimizations for Dynamic Levelwise PageRank (from STICD) : SHORT...Algorithmic optimizations for Dynamic Levelwise PageRank (from STICD) : SHORT...
Algorithmic optimizations for Dynamic Levelwise PageRank (from STICD) : SHORT...
 
Q1’2024 Update: MYCI’s Leap Year Rebound
Q1’2024 Update: MYCI’s Leap Year ReboundQ1’2024 Update: MYCI’s Leap Year Rebound
Q1’2024 Update: MYCI’s Leap Year Rebound
 
Adjusting primitives for graph : SHORT REPORT / NOTES
Adjusting primitives for graph : SHORT REPORT / NOTESAdjusting primitives for graph : SHORT REPORT / NOTES
Adjusting primitives for graph : SHORT REPORT / NOTES
 
Chatty Kathy - UNC Bootcamp Final Project Presentation - Final Version - 5.23...
Chatty Kathy - UNC Bootcamp Final Project Presentation - Final Version - 5.23...Chatty Kathy - UNC Bootcamp Final Project Presentation - Final Version - 5.23...
Chatty Kathy - UNC Bootcamp Final Project Presentation - Final Version - 5.23...
 
一比一原版(QU毕业证)皇后大学毕业证成绩单
一比一原版(QU毕业证)皇后大学毕业证成绩单一比一原版(QU毕业证)皇后大学毕业证成绩单
一比一原版(QU毕业证)皇后大学毕业证成绩单
 
一比一原版(UPenn毕业证)宾夕法尼亚大学毕业证成绩单
一比一原版(UPenn毕业证)宾夕法尼亚大学毕业证成绩单一比一原版(UPenn毕业证)宾夕法尼亚大学毕业证成绩单
一比一原版(UPenn毕业证)宾夕法尼亚大学毕业证成绩单
 
Criminal IP - Threat Hunting Webinar.pdf
Criminal IP - Threat Hunting Webinar.pdfCriminal IP - Threat Hunting Webinar.pdf
Criminal IP - Threat Hunting Webinar.pdf
 
一比一原版(CBU毕业证)不列颠海角大学毕业证成绩单
一比一原版(CBU毕业证)不列颠海角大学毕业证成绩单一比一原版(CBU毕业证)不列颠海角大学毕业证成绩单
一比一原版(CBU毕业证)不列颠海角大学毕业证成绩单
 
做(mqu毕业证书)麦考瑞大学毕业证硕士文凭证书学费发票原版一模一样
做(mqu毕业证书)麦考瑞大学毕业证硕士文凭证书学费发票原版一模一样做(mqu毕业证书)麦考瑞大学毕业证硕士文凭证书学费发票原版一模一样
做(mqu毕业证书)麦考瑞大学毕业证硕士文凭证书学费发票原版一模一样
 
一比一原版(RUG毕业证)格罗宁根大学毕业证成绩单
一比一原版(RUG毕业证)格罗宁根大学毕业证成绩单一比一原版(RUG毕业证)格罗宁根大学毕业证成绩单
一比一原版(RUG毕业证)格罗宁根大学毕业证成绩单
 
Empowering Data Analytics Ecosystem.pptx
Empowering Data Analytics Ecosystem.pptxEmpowering Data Analytics Ecosystem.pptx
Empowering Data Analytics Ecosystem.pptx
 
一比一原版(BU毕业证)波士顿大学毕业证成绩单
一比一原版(BU毕业证)波士顿大学毕业证成绩单一比一原版(BU毕业证)波士顿大学毕业证成绩单
一比一原版(BU毕业证)波士顿大学毕业证成绩单
 
1.Seydhcuxhxyxhccuuxuxyxyxmisolids 2019.pptx
1.Seydhcuxhxyxhccuuxuxyxyxmisolids 2019.pptx1.Seydhcuxhxyxhccuuxuxyxyxmisolids 2019.pptx
1.Seydhcuxhxyxhccuuxuxyxyxmisolids 2019.pptx
 
Opendatabay - Open Data Marketplace.pptx
Opendatabay - Open Data Marketplace.pptxOpendatabay - Open Data Marketplace.pptx
Opendatabay - Open Data Marketplace.pptx
 
Malana- Gimlet Market Analysis (Portfolio 2)
Malana- Gimlet Market Analysis (Portfolio 2)Malana- Gimlet Market Analysis (Portfolio 2)
Malana- Gimlet Market Analysis (Portfolio 2)
 
哪里卖(usq毕业证书)南昆士兰大学毕业证研究生文凭证书托福证书原版一模一样
哪里卖(usq毕业证书)南昆士兰大学毕业证研究生文凭证书托福证书原版一模一样哪里卖(usq毕业证书)南昆士兰大学毕业证研究生文凭证书托福证书原版一模一样
哪里卖(usq毕业证书)南昆士兰大学毕业证研究生文凭证书托福证书原版一模一样
 
Levelwise PageRank with Loop-Based Dead End Handling Strategy : SHORT REPORT ...
Levelwise PageRank with Loop-Based Dead End Handling Strategy : SHORT REPORT ...Levelwise PageRank with Loop-Based Dead End Handling Strategy : SHORT REPORT ...
Levelwise PageRank with Loop-Based Dead End Handling Strategy : SHORT REPORT ...
 
FP Growth Algorithm and its Applications
FP Growth Algorithm and its ApplicationsFP Growth Algorithm and its Applications
FP Growth Algorithm and its Applications
 
一比一原版(UofM毕业证)明尼苏达大学毕业证成绩单
一比一原版(UofM毕业证)明尼苏达大学毕业证成绩单一比一原版(UofM毕业证)明尼苏达大学毕业证成绩单
一比一原版(UofM毕业证)明尼苏达大学毕业证成绩单
 

Threaded Binary Tree

  • 1. Presented to: Md. Shamsujjoha  Senior Lecturer of CSE department  East West University Presented by:  Md. Khabbab Hossain Tusher  Date:03/04/2016
  • 3. A binary search tree in which each node uses an otherwise-empty left child link to refer to the node's in-order predecessor and an empty right child link to refer to its in-Order Successor. Definition Slide 1
  • 4. A Simple Binary Tree A B D E C GF Slide 2
  • 5. A B C Null D Null Null E Null Null G NullNull F Null Slide 3 Threaded binary tree
  • 6. Threaded Binary Tree  In above binary tree, there are 8 null pointers & actual 6 pointers.  In all there are 14 pointers.  We can generalize it that for any binary tree with n nodes there will be (n+1) null pointers and 2n total pointers.  The objective here to make effective use of these null pointers.  A. J. perils & C. Thornton jointly proposed idea to make effective use of these null pointers.  According to this idea we are going to replace all the null pointers by the appropriate pointer values called threads. Slide 4
  • 7.  And binary tree with such pointers are called threaded tree.  In the memory representation of a threaded binary tree, it is necessary to distinguish between a normal pointer and a thread. Slide 5
  • 8. Threaded Binary Tree: One-Way  We will use the right thread only in this case.  To implement threads we need to use in-order successor of the tree Slide 6
  • 9. Threaded Binary Tree: One-Way A B C Null D Null E Null G NullNull F Inorder Traversal of The tree: D, B, E, A, F, C, G Slide 7
  • 10. Two way Threaded Tree/Double Threads  Again two-way threading has left pointer of the first node and right pointer of the last node will contain the null value. The header nodes is called two-way threading with header node threaded binary tree. Slide 8
  • 11. A B D Inorder Traversal of The tree: D, B, E, A, F, C, G E C F G Dangling Dangling Slide 9
  • 12. • Dangling can be solved as follows  Introduce a header node.  The left and right pointer of the header node are treated as normal links and are initialized to point to header node itself. Slide 10
  • 13. A B D Inorder Traversal of The tree: D, B, E, A, F, C, G E C F G Head Slide 11
  • 14. Structure of Thread BT Node structure For the purpose of our evaluation algorithm, we assume each node has five fields: LTag Left data Right RTag We define this node structure in C as: Struct Node{ int data; struct Node *Left,*Right; bool Ltag; boolRtag; }; Slide 12
  • 15. L.Tag L.Child head R.child R.Tag 1 A 1 1 1 0 D 0 0 E 0 0 F 0 0 G 0 1 B 1 1 C 1 Inorder Traversal of The tree: D B E A F C G Slide 13
  • 16. Threaded Tree Traversal • We start at the leftmost node in the tree, print it, and follow its right thread • If we follow a thread to the right, we output the node and continue to its right. • If we follow a link to the right, we go to the leftmost node, print it, and continue. Slide 14
  • 17. 8 75 3 1 6 Start at leftmost node, print it Output 1 9 Slide 15
  • 18. 8 75 3 1 6 Follow thread to right, print node Output 1 3 9 Slide 16
  • 19. 8 75 3 1 6 Follow link to right, go to leftmost node and print Output 1 3 5 9 Slide 17
  • 20. 8 75 3 1 6 Follow thread to right, print node Output 1 3 5 6 9 Slide 18
  • 21. 8 75 3 1 6 Follow link to right, go to leftmost node and print Output 1 3 5 6 7 9 Slide 19
  • 22. 8 75 3 1 6 9 Follow thread to right, print node Output 1 3 5 6 7 8 Slide 20
  • 23. 8 75 3 91 6 Follow link to right, go to leftmost node and print Output 1 3 5 6 7 8 9 Slide 21
  • 24. void inOrder(struct Node *root) { struct Node *cur = leftmost(root); while (cur != NULL)  {  printf("%d ", cur->data);   // If this node is a thread node, then go to // inorder successor  if (cur->rightThread)  cur = cur->right;  else // Else go to the leftmost child in right subtree  cur = leftmost(cur->right);  }  } 8 75 3 1 6 9 Slide 22
  • 25. Threaded Binary Trees  In threaded binary trees, The null pointers are used as thread.  We can use the null pointers which is a efficient way to use computers memory.  Traversal is easy. Completed without using stack or reccursive function.  Structure is complex.  Insertion and deletion takes more time. Normal Binary Trees  In a normal binary trees, the null pointers remains null.  We can’t use null pointers so it is a wastage of memory.  Traverse is not easy and not memory efficient.  Less complex than Threaded binary tree.  Less Time consuming than Threaded Binary tree. Comparison of Threaded BT Slide 23
  • 26.  Inserting a node to Threaded Binary Tree: Inserting a node X as the right child of a nodes. 1st Case: - If G has an empty right subtree, then the insertion is simple Slide 24
  • 27. A B D Inserting X as a right child of G E C F G Head X New inorder traversal is: D,B,E,A,F,C,G,X Slide 25
  • 28. 2nd Case: If the right subtree of C is not empty, then this right child is made the right child of X after insertion. Slide 26
  • 29. A B D New Inorder Traversal of The tree: D, B, E, A, F, C, X,G E F G Head x C Slide 27
  • 30. Advantage  1. By doing threading we avoid the recursive method of traversing a Tree , which doesn’t use of stack and consumes a lot of memory and time .  2 . The node can keep record of its root .  3. Backward Traverse is possible.  4. Applicable in most types of the binary tree. Disadvantage  1. This makes the Tree more complex .  2. More prone to errors when both the child are not present & both values of nodes pointer to their ancestors.  3. Lot of time consumes when deletion or insertion is performed. Threaded binary tree Slide 28
  • 31.  Same as any kind of Binary Tree.  Used in search and Traverse based work APPLICATIONS Slide 29
  • 32. Conclusion  Excellent concept in modern computer science.  Saves Time and memory.  Traversal and search are very efficient.  Insertion and deletion are not so efficient. Slide 30
  • 33. References  http://www.geeksforgeeks.org/inorder-tree-traversal-without- recursion-and-without-stack/  http://www.delorie.com/gnu/docs/avl/libavl_183.html  http://www.math- cs.gordon.edu/courses/cs321/lectures/threaded.html  https://prezi.com/1yitau0wnwlg/threaded-binary-tree-in-data- structures/  http://stackoverflow.com/questions/6744770/confusion-with- threaded-binary-tree  Various Text Book for data structure.
  • 34.