I have this problem that states that: LL be a doubly linked list that has 2 headers L and R. Each record has: llink, data, and rlink as field.
So llink is the prev pointer and rlink is the next pointer. Here is the code to reverse the list, but I am confused with how to change the code so that "LL be a doubly linked list that has 2 headers L and R", how do I make this?
Node *revDD(Node *LL)
{
Node* start_prt = LL;
Node *tmp1, *tmp2;
Node* rlink= LL->next;
Node* llink= LL->prev;
while(start_prt && rlink)
{
tmp2 = rlink->next;
tmp2 = rlink;
rlink->next = start_prt;
start_prt->prev = rlink;
rlink = tmp1;
start_prt = tmp2;
}
start_prt->prev = NULL;
start_prt = LL;
while(llink && start_prt)
{
tmp1 = llink->prev;
tmp2 = llink;
llink->prev = start_prt;
start_prt->next = llink;
llink= tmp1;
start_prt = tmp2;
}
start_prt->next = NULL;
return LL;
}