GRR implement a BST as an array (C++)

Vadatajs

Diamond Member
Aug 28, 2001
3,475
0
0
This is more of a rant than anything else, but I'm more than open to suggestions. Well, I have to do this(phase 2), and I'm pretty much finished, it's just calculating the imbalances (right, left, size) is giving me some problems (they don't seem to add up). Phase 3 is going to be really fun if I don't get this finished. At least phase 1 was really easy (I already had a bst class, I just had to make it use templates).
 

HJB417

Senior member
Dec 31, 2000
763
0
0
I don't know if this answers your problems but what if you make 2 counters, leftCounter and rightCounter and increment leftCounter whenever an objected is added to the left of the root node and incrememnt rightCounter whenever an object is added to the right of the root node. The imbalance would be the difference of the two counters.