0% found this document useful (0 votes)
15 views4 pages

Thread Representation of A Binary Tree: Inorder Listing: Head, C, B, A, E, F, D, G, Head

Uploaded by

uttam
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)
15 views4 pages

Thread Representation of A Binary Tree: Inorder Listing: Head, C, B, A, E, F, D, G, Head

Uploaded by

uttam
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/ 4

Thread Representation of a Binary Tree

Inorder Listing: Head, C, B, A, E, F, D, G, Head


Searching the address of inorder successor of a node
with address X
e
P-RPTR(X)|

Function INS(X)

1. P:= RPTR(X)
If RPTR(X) < 0 then
Return(P)

2. Repeat while LPTR(P) > 0


P:= LPTR(P)

3. Return(P)
Searching the address of inorder predecessor of a node
with address X
Function INP(X)

1. P:= LPTR(X)
If LPTR(X) < 0 then
Return(P)

2. Repeat while RPTR(P) > 0


P:= RPTR(P)

3. Return(P)

Inorder Traversal of a Threaded Binary Tree

1. P:= HEAD

2. Repeat while True


P:= INS(P)
If P=HEAD then
Exit
Else Write (INFO(P))

Inorder Listing: Head, C, B, A, E, F, D, G, Head


Insertion into a Threaded Binary Tree

Case 1: LEFT(X) = Null Case 2: Insert between X and LEFT(X)


INS-LEFT(X, ITEM)
1. P:=NEW
INFO(P):=ITEM
2. LPTR(P):=LPTR(X)
LPTR(X):= P
RPTR(P):= - X
3. If LPTR(P) > 0 then
RPTR(INP(P)):= -P
Return

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy