Idea is to swap Binary tree's element's with it's left node. Here's the code I came up with:
when I print elements, Elements left to node are swapped but not right....please help in fixing this.Code:
TREE swap_left (TREE T){
element_type tmp;
if(T!=NULL){
if(T->left){
tmp = T->element;
T->element = T->left->element;
T->left->element = tmp;
T = T->left;
}
return (swap_left(T->right)&& swap_left(T->left));
}
return T;
}