Posted by Jared Anderson on July 25, 1999 at 02:30:23:
In Reply to: Re: Homework 9 posted by zhimei Ding on July 24, 1999 at 15:08:34:
: Can't we have root 2 with child 0 and child 1?
The problem says that when two trees are of the same size, we are to make the root with the greater value be the child of the root with the lesser value.
So for step one, since the tree with root 0 (which is just 0) and the tree with root 2 (which is just 2) are of the same size, we have to make 2 the child of 0!! Then, with (1,2), we already know 2 ~ 0, so we can just tack 1 on to the tree. Since 1's tree is smaller, we have to attach it to the root of the larger, which is 0. So 0 winds up with children 1 and 2.
LOL ... did that make sense? ... Been a long night LOL