Question: Problem1 (a) Using the SML system to define a datatype for labeled 3-branch trees, the trees with possible zero, one, two, or three branches. Label
Problem1 (a) Using the SML system to define a datatype for labeled 3-branch trees, the trees with possible zero, one, two, or three branches. Label the nodes of the trees by integers. No polymorphic definition for this problem. (b) Draw a concrete 3-branch tree of at least 12 nodes but no more than 15 nodes, and the integers labeling the nodes range from 20 to 40. Represent this tree by using your 3-branch tree datatype definition. Your representation has to be accepted by SML as an instance of the datatype 3-branch trees you define. (c) Using the SML system to define a function in SML that sums of the squares of all integer (d) Apply this function to your concrete tree to get the correct result. Problem 2 (a) Using SML to define datatypes for the syntax (abstract syntax) of the following small and nodes of any integer 3-branch trees. simplified expression language defined in BNF, and submit a hardcopy of your SML definition. (Hint: Since are constants or terminals, they do not have to show up in your datatype definitions. Non-terminal "expression" and "term" indicate whether the structure is for addition or for multiplication.) expression>-
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
