0

I need to create ever possible binary tree and then count the comparisons

an example is if I had a binary tree with 1 and 2

then there are 4 possible binary trees...

root = 1

LChild = 2

root = 1

RChild = 2

root = 2

LChild = 1

root = 2

RChild = 1

Next I would compare, so if I inserted a 3rd item. the 3rd item would compare with the first tree 2 times at the root and 2 times with the LChild and so forth till the last one. I would then have 16 total comparisons (8*2)

My problem is I am having alot of trouble creating every possible tree without wanting to hardcode it... also I did some math to figure out if I had 3 elements my comparisons would be 180.

*Edited 4 Years Ago by jigglymig*: n/a