I am now having two problems that I cannot fix:
Crashes the program. When I change it to
*T->Right = Insert( X, *T->Right );
Program works correctly but:
T->Right = Insert( X, T->Right );
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:
If I change that line to
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 );
I am back at square one with the original problem I had.
if (X > (T->Right)->Element);
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.