for 1st

use hare and tortoise algo to find the mid point of the linklist ...
and reverse the other end

like

a->b-->c->d->v->u
a->b-->c<-d<-v<-u

pointer 1 will point to a and other pointer will point to u
then it is done ..

u can check..



2nd

for(p = original; p != null; p = p->next->next)
p->next->random = p->random->next;

(i) insert one new node in original list for every node .

(ii) then change "random" links of newly inserted nodes
i.e; for every new node (p->next)
p->next->random = p->random->next


(iii)then split 2 lists

Now Split the Lists

code is


for( q =original->next,r = original->next,p = original; p != null; p =
p->next,q=q->next)
{ p->next = p->next->next;
q->next = q->next->next;
}

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to