0

The tree datatype is :

datatype mobile = Object of int | Wire of mobile * mobile

To check if it's balanced I figured out I have to first make a weight function to calculate the weight of the values of each node and then compare left sub tree and right tree. However I have trouble putting this in ml language.

Code so far:

fun balanced  Object = true
if(weight(Wire(x,t1)) - weight(Wire(y,t1))) = 0)
   then true
else false
bahrep
  • 29,961
  • 12
  • 103
  • 150
  • 1
    It is kind of sad, that you didn't even bothered to look for the answer, as one already exists here at SO :S. It must be getting close to hand in time? – Jesper.Reenberg Jan 18 '13 at 00:58
  • 2
    possible duplicate of [Beginner SML Syntax](http://stackoverflow.com/questions/14365537/beginner-sml-syntax) – Gian Jan 19 '13 at 19:29

0 Answers0