Your case #1 and #3- D case has problems
A
/ \
B C
\
D
try to delete A and see what will happen?
Type: Posts; User: vart
Your case #1 and #3- D case has problems
A
/ \
B C
\
D
try to delete A and see what will happen?
if prevPtr->leftTree == currPtr
it means you are on the LEFT side of the parent
if prevPtr->rightTree == currPtr
it means you are on the RIGHT side of the parent
so? it means...
what will be the value of A->leftTree pointer?
why do you think parent will have 1 child?
A
/ \
B C
/ \
D E
if I want to delete B - parent has 2 childs, settign both pointers to NULL will leak CDE
if your node is not present in the tree - your function will crash
when you deleting leaf - why do you set to NULL both pointers of the father? you delete only one child - second is leaked
also...
no, adresses are per process
pure luck
How do you know it?
memory does not belongs to your program - it is returned to the memory pool...
if this free just returned the last chunk of the memory in some page - the whole page could be...