Ok, so far I've got all the rotation functions written and tested. Took me a couple hours of debugging though. I added a height member to my nodes. Next I would like to modify my insertion function so that it will update the heights. After that, I can worry about checking balances and how to call the right rotations.
Code:
void BSTree_add(struct Tree *pTree, int value)
{
if (Tree_isempty(pTree))
{
Tree_setrootvalue(pTree, value);
}
else
{
if (value <= Tree_getrootvalue(pTree))
{
BSTree_add(Tree_getlefttree(pTree), value);
}
else
{
BSTree_add(Tree_getrighttree(pTree), value);
}
}
}
Where/how to set height member?