Math, asked by sairajsawant26112002, 3 months ago

Suppose the following list of letter is inserted in to an empty binary search tree
J,R,D,G,W,E,M,H,PA,F,Q
Find the final binary search tree.

Answers

Answered by shraddha974096
1

Answer:

inorder: HDIBEAJFCG

preorder: ABEHIECFJG

postorder: HIDEBJFGCA

Step-by-step explanation:

Threaded Trees

• Traversals:

- Require extra memory, and

- Must be started from the root

• Use NULL pointers to store

in-order predecessors and

successors.

• Extra bit associated with

each pointer marks whether

it is a thread.

E

G

D

E

B

A

H

G

Threaded Trees

E

G

D

E

B

A

H

G

void inorder_succ(BinNode *T)

{

BinNode * next = T->right();

if(!next) return NULL;

if(!is_thread(T->right))

{

while(next->left() &&

is_thread(next->left)

) next = next->left();

}

return next;

}

r1 r2

r

In general, in order

successor = leftmost

item in right subtree

Using Threads for Preorder

E

G

D

E

B

A

H

G

void preorder_succ(BinNode *T)

{

if(T->left() &&

!is_thread(T->left) return T->left();

for(BinNode* next = T->right();

is_thread(next->right);

next = next->right()) {}

return RC(P)

Answered by guptaankita5252
6

Answer:

W is the answer......................

Similar questions