i have a program where i have to sort a double linked list using merge sort. i am having problem with changing the pointers of the list, like the previous and the next pointers of a node. i am unable to understand how can i change those. i tried something but that is not working. please help me as soon as possible as i have a deadline. here is a sample :
Expand|Select|Wrap|Line Numbers
- int merge(low,mid,high)
- {
- int i,j,k;
- i=low;
- j=mid+1;
- list *temp,*temp1;
- while(i<=mid && j<=high)
- {
- if(current->n <= current->next->n)
- {
- current=current->next;
- i++;
- }
- else
- {
- temp->prev=current->prev;
- temp->next=current->next;
- current->prev=current->next->prev;
- current->next=current->next->next;
- temp1->prev=temp->prev;
- temp1->next=temp->next;
- j++;
- }
- }
this is a kind of implementation i tried. please tell me how should i change the pointers in the list. plese help me, its urgent.
thanx in advance.