Question: Please help in writing this in OCaml functional programming language asap !!! Write a function called which inserts an into an AA tree. Here is


Please help in writing this in OCaml functional programming language asap!!!
Write a function called which inserts an into an AA tree. Here is a skeleton of the function: let rec insert item t= match t with | Leaf | Node (lvl,v,l,r). is an and is an AA tree, of course. Note that here means "level", means "value", and and refer to the left and right subtrees of a . Here is the algorithm you should use: - If the tree is a , return a with level 1 containing the item; the subtrees should both be - If the tree is a and the value is the same as the to be inserted, return the original tree. Nothing needs to be done. (This can be a separate case.) - Otherwise, compare to and add the node to the left or right subtree recursively. The resulting tree can be unbalanced, so do first a skew and then a split operation on that tree, and return the resulting tree. Make sure you do the skew before the split, or it won't work correctly. (The figures shown previously explain why.) Examples \#
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
