When you say missing, I assume the left or right pointer is null. If
that's the case, this could be a possible solution:
// this fixes the missing left pointers traversing from the head
node* curr = head;
while (curr->right != null ) {
if (curr->right->left == null) {
curr->right->left = curr;
}
curr = curr->right;
}
// reverse the logic to fix pointers in the other direction starting
at the end of the list
node* curr = tail;
while (curr->left != null) {
if (curr->left->right == null) {
curr->left->right = curr;
}
curr = curr->left;
}
On Aug 31, 10:23 am, Dheeraj Sharma <[email protected]>
wrote:
> A doubly linked list has one Left pointer missing and at some point..one
> Right pointer missing..how to repair the doubly linked list?
> ?
>
> --
> *Dheeraj Sharma*
> Comp Engg.
> NIT Kurukshetra
> +91 8950264227
--
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/algogeeks?hl=en.