Question: in ocaml language Library functions: You can use any library functions in the List module for this assignment (please do not use library functions in

in ocaml language
in ocaml language Library functions: You can use any library functions in
the List module for this assignment (please do not use library functions

Library functions: You can use any library functions in the List module for this assignment (please do not use library functions in any other modules). You may find the following functions particularly useful, e.g., List.mapi, List.mem_assoc, and List.assoc. Datatypes: Problems 1-3 are about manipulating tree data structures. In OCaml, you can define a tree data structure using datatype: type 'a tree = Leaf Node of 'a tree * 'a * 'a tree We will assume binary search trees in this assignment and can define a bineary search tree insertion function as the following: let rec insert tree x match tree with Leaf -> Node (Leaf, x, Leaf) Node(1, y, r) -> if x = y then tree else if x insert acc x) Leaf 1 Problem 2 Given a binary tree, return the level order traversal of its nodes' values. (i.e., from left to right, level by level). levelOrder: 'a tree -> 'a list list Example: Given a tree t: 50 the returned result of levelorder t should be a nested list [[41];[20;65); [11;29;50;91); [32; 72;99]]. The i th elment of the nested list is a list of tree elements at the i th level of the tree t from left to right. You may need to define a recursive auxiliary function. In (): let levelOrder t - (" YOUR CODE HERE)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!