Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I\'d appreciate some help. Thanks! 1- What nodes would P and C be referencing af

ID: 3827020 • Letter: I

Question

I'd appreciate some help. Thanks!

1- What nodes would P and C be referencing after the method findNode was invoked to locate: a The node with key 4 in the tree on the right? b) The node with key 5 in the tree on the right? c) The root node in the tree on the right? 2- After returning from findNode(key, p, c), give the code to: (note: don't consider the TreeNodeWrapper class) a Fetch a deep copy of the node with key 4. b) Insert the node with key field 5. c) Delete the node with key field 6. d) Delete the node with key field 8.

Explanation / Answer

1)

a)

Before solving the question let's just see that how the given binary search tree will be stored in an array

So the tree will be stored in an array in this fashion where left child will be at 2*i position and right child will be at 2*i+1. and if no child is present the node value will be NULL.

So findNode(4) will return 2.

When the element 4 is found in the then it's index will be returned by the findNode function.

b)

findNode(5) will return -1.

If elemnt is not found in the tree the findNode fucntion will return -1.

c)

Root node is 7, whose index is 1.

Node 7 4 8 2 6 Null 9 Index 1 2 3 4 5 6 7
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote