how to deside the order of the parts..
I got this solution to the tree2list function.
The 3rd part of this solution is going to the tail of the linked list.
The 4th part is the linking part.
I think its odd to go threw the list and then do the linking.
I think we need to do the linking first (in order to have a list) and then go to the last member of the list.
Code:
node* tree2list(node*root) {
node *head,*temp;
if (!root) return NULL;
head=tree2list(root->left);
if (!head) return root;
for(temp=head;temp->next;temp=temp->next){ //3rd part
}
temp->next=root; //4th part
root->next=tree2list(root->right);
return head;
}