We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Node*Reverse(Node*head){// Complete this function// Do not write the main method. if(head==NULL){returnhead;}elseif(head->next==NULL){head->next=head->prev;head->prev=NULL;returnhead;}Node*prevPtr=head->prev;Node*nextPtr=head->next;head->next=prevPtr;head->prev=nextPtr;returnReverse(nextPtr);}
Reverse a doubly linked list
You are viewing a single comment's thread. Return to all comments →
how does every node's prev gets changed here ?
my C++ recursive solution