I am now having two problems that I cannot fix:
Code:
*T->Right = Insert( X, *T->Right );
Crashes the program. When I change it to
Code:
T->Right = Insert( X, T->Right );
Program works correctly but:
1. Compiler generates warning:
"passing argument 2 of insert from incompatible pointer type" and
"assignment from incompatible pointer type"
2. Program crashes in this part of the code:
Code:
if( Height( T->Right ) - Height( T->Left ) == 2 ) //Compiler gives above warning
{
printf("Performing Right Rebalancing\n");
if( X > ( (*T->Right)->Element) ) //Program crashes here.
T = SingleRotateWithRight( T );
...
If I change that line to
Code:
if (X > (T->Right)->Element);
I am back at square one with the original problem I had.
Is there a better way to structure this as to avoid the problems with the pointers?, or can this be fixed to work properly? Thanks.