I want to reverse every three values of my linked list but it it gives me a SIGSEGV error.Can someone tell me what is wrong with the code? Thanks in advance.
(eg. for input : 1->2->3->4->5->6->7->8 , output should be 3->2->1->6->5->4->7>8 )
Here is the link to my code: http://ideone.com/C1C1qy
What’s with this
head->i=10 ???
a->nxt=t;
u->nxt=t->nxt;
t->nxt=s;
s->nxt=u;
a->nxt=t;
a=u;
There seems to be a flaw in your swapping logic.This works.
Link to rectified code-http://ideone.com/8eg04W
Plus next time try to find the bug on ur own.Dry running the logic in ur head will help u find bugs and lead to a better understanding of linked list.If the Seg error appears in an exam there will be no forum to help u.