[algogeeks] Re: Two Pointers Missing

2011-08-31 Thread Chris
You would only be able to re-link node1 to node 4, but node 2 and node 3 would be orphaned and inaccessible. If no pointers lead to those nodes, you cannot access them to fix their links. On Aug 31, 11:49 am, Dheeraj Sharma wrote: > head -> node1 <-> node2 <- node3 <-> node4 -> node5 <-> node6 <-

Re: [algogeeks] Re: Two Pointers Missing

2011-08-31 Thread Dheeraj Sharma
head -> node1 <-> node2 <- node3 <-> node4 -> node5 <-> node6 <-> ^ missing right ^missing left node7 <- tail now head and tail are given..is there any way to fix the pointers again? On Wed, Aug 31, 2011 at 11:07 PM, Chris wrote: > Being a doubly linked

[algogeeks] Re: Two Pointers Missing

2011-08-31 Thread Chris
Being a doubly linked list you should have a head and tail (kinda the reason why you'd use a doubly linked list in the first place). If you don't then I'm not sure how you'd fix that as the rest of the list after the first missing right pointer would essentially be orphaned in memory with no valid

[algogeeks] Re: Two Pointers Missing

2011-08-31 Thread Chris
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 =

Re: [algogeeks] Re: Two Pointers Missing

2011-08-31 Thread Dheeraj Sharma
i get more clear to my quest.. 1.Doubly Linked List 2.Firstly some right pointer is missingand lately..some left pointer is missing 3.Head of pointer is given. 4.Repair the list.. On Wed, Aug 31, 2011 at 10:12 PM, Sanjay Rajpal wrote: > Chris : he said first, right pointer is missing, how c

Re: [algogeeks] Re: Two Pointers Missing

2011-08-31 Thread Sanjay Rajpal
Chris : he said first, right pointer is missing, how can u repair that left pointer first as you can't go forward ? Sanju :) On Wed, Aug 31, 2011 at 9:39 AM, Chris wrote: > When you say missing, I assume the left or right pointer is null. If > that's the case, this could be a possible soluti