1. Think of a binary tree to represent basic arithmetic operations. In such a tree, the leaf nodes will be of a numeric type while the internal non-leaf nodes will hold the arithmetic operations of...


Please solve question number 2 in OCAML


1. Think of a binary tree to represent basic arithmetic operations. In such a tree, the leaf nodes will<br>be of a numeric type while the internal non-leaf nodes will hold the arithmetic operations of<br>addition, subtraction, multiplication, and division. This means, we need to define a binary tree<br>data type over two distinct data types. Define such a binary tree in OCaml.<br>2.. Next, write down a function that takes a binary tree of the type you defined, and returns a tuple<br>with its first element being a list of operators, and its second element being a list of the numeric<br>values in the nodes. That is, the function's type should be<br>val function name : ('a, 'b) tree -> 'b list 'a list - <fun><br>where 'a is the operator's type and 'b is the numeric type.<br>

Extracted text: 1. Think of a binary tree to represent basic arithmetic operations. In such a tree, the leaf nodes will be of a numeric type while the internal non-leaf nodes will hold the arithmetic operations of addition, subtraction, multiplication, and division. This means, we need to define a binary tree data type over two distinct data types. Define such a binary tree in OCaml. 2.. Next, write down a function that takes a binary tree of the type you defined, and returns a tuple with its first element being a list of operators, and its second element being a list of the numeric values in the nodes. That is, the function's type should be val function name : ('a, 'b) tree -> 'b list 'a list - where 'a is the operator's type and 'b is the numeric type.

Jun 08, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here