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

I am writing a function that takes 2 binary trees (t1 and t2) and generates a ne

ID: 440231 • Letter: I

Question

I am writing a function that takes 2 binary trees (t1 and t2) and generates a new tree that places t2 at the bottom right of t1. t2 is attached to the first node whose right child is empty, even if the node is not a leaf. let rec adjoin_right (t1: 'a tree) (t2: 'a tree) : 'a tree test case: let test () : bool = adjoin_right (Node (Empty, 1, Empty)) (Node (Empty, 2, Empty)) = Node(Empty, 1, Node (Empty, 2, Empty)) ;; run_test "adjoin_right leaf" test Can somebody steer me in the right direction for this problem? I know that I'll probably have to write a helper function.

Explanation / Answer

void left_insert() { if(temp1->datadata) Insert Left Side of Tree { if(temp2->left==NULL) { temp2->left = temp1; } else { temp2 = temp2->left; left_insert(); } } else { right_insert(); } } Insert Right Side of Tree void right_insert() { if(temp1->data > temp2->data) { if(temp2->right==NULL) { temp2->right=temp1; } else { temp2=temp2->right; right_insert(); } } else { left_insert(); } }
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