D
Daniel
I need to reverse the doubly linked list with dummy node. I think the
solution is to exchange each node pointers' next and previous address.
But what's wrong in my function?
Thanks
void reverse_list(NodePtr p)
{ NodePtr next, q=p, head=p->prev;
while (q != head)
{ next = q->next;
q->next = q->prev;
q->prev = next;
q = next;
}
}
solution is to exchange each node pointers' next and previous address.
But what's wrong in my function?
Thanks
void reverse_list(NodePtr p)
{ NodePtr next, q=p, head=p->prev;
while (q != head)
{ next = q->next;
q->next = q->prev;
q->prev = next;
q = next;
}
}