mockers
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Copy alink list:Vinisha Ma'am

2 posters

Go down

Copy alink list:Vinisha Ma'am Empty Copy alink list:Vinisha Ma'am

Post  ballu Sun Feb 01, 2009 10:27 pm

U have a link list,
it has one conventional next pointer
and it has another random pinter where it can point anywhere in the list

Copy this list??


Last edited by ballu on Mon Feb 02, 2009 1:58 am; edited 1 time in total
ballu
ballu

Posts : 58
Join date : 2009-02-01

Back to top Go down

Copy alink list:Vinisha Ma'am Empty Re: Copy alink list:Vinisha Ma'am

Post  tirth Mon Feb 02, 2009 1:22 am

suppose we have A the link list given
and A' the new link list we will make.

struct node
{
int a;
strcut node *next; //the conventional pointer pointing to next node in link list
struct node *next_ransom; //this is the pointer which can point to any node in link list

i am writing sum sort of pseudo code
first for conventional linking...create a new link list the normal way(say A') which has just 1 pointer pointing to the next node in a link list

then for connecting the other pointer...say next_ransom;

void function(node *root1,node *root2) //root1 is the head of given link list and root2 is head of new link list
{
node *temp1,*temp2;
temp1=root2;temp2=root2;
while(temp1->next!=NULL) // make adjustments such that conventional pointer of given link list starts pointing to the corresponding node in the new link list

{
previous=temp1;
temp1=temp1->next;
previous->next=temp2;
temp2=temp2->next;
}
node *ptr1,*ptr2;

ptr1=root1;ptr2=root2;
while(ptr1->next!=NULL) //then use this line for connecting ransom pointer
{
ptr2->next_ransom= ptr1->next_ransom->next;
}

tirth

Posts : 3
Join date : 2009-01-30

Back to top Go down

Copy alink list:Vinisha Ma'am Empty Re: Copy alink list:Vinisha Ma'am

Post  tirth Mon Feb 02, 2009 2:27 am

http://discuss.joelonsoftware.com/default.asp?interview.11.359006.3

check it this maybe of help..although i havnt gone through it..bt its the same question i guess

tirth

Posts : 3
Join date : 2009-01-30

Back to top Go down

Copy alink list:Vinisha Ma'am Empty Re: Copy alink list:Vinisha Ma'am

Post  Sponsored content


Sponsored content


Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum