Explanation :
struct tree* convert(struct tree *root)
{
struct tree *alist,*blist;
if(!root)
return NULL;
alist=convert(root->left);
blist=convert(root->right);
root->left=root->right=root;
alist=append(alist,root);
alist=append(alist,blist);
return alist;
}
struct tree* append(struct tree *a, struct tree *b)
{
struct tree *alast,*blast;
if(a==NULL)
return b;
if(b==NULL)
return a;
alast=a->left;
blast=b->left;
alast->right=b;
b->left=alast;
a->left=blast;
blast->right=a;
return a;
}