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