I am writing a function that takes 2 binary trees (z1 and z2) and generates a ne
ID: 440232 • Letter: I
Question
I am writing a function that takes 2 binary trees (z1 and z2) and generates a new tree that places z2 at the bottom right of z1. z2 is attached to the first node whose right child is empty, even if the node is not a leaf. let rec adjoin_right (z1: 'a tree) (z2: '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
www.proba.jussieu.fr/pageperso/zhan/pdffile/guanajuato.pdf www.cs.princeton.edu/~funk/mobius.pdf
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.