From: Rahul on
Hi Everyone,

I was trying out the following problem in recursive approach

10
4 12
6
7

So the link should be 10->4->6->7->12

I developed the following code, for this,

void single(struct node * root, struct node * parent)
{
if(root == NULL) return;
root->link = NULL;
if(parent != NULL) parent->link = root;
single(root->lptr,root);
if(root->lptr != NULL)
{
struct node * temp = root->lptr;
while(temp->rptr!= NULL) temp = temp->rptr;
single(root->rptr,temp);
}
else single(root->rptr,root);
}

But i felt this to be a bit clumsy although logic seems fine... is
there any scope to improve the logic?