Ask a Question

Write a C function to reverse a linked list physically. (That is change the node positions.)

on 2011-05-04 21:20:31   by nilakshi   on MCA  2 answers

Anupam

on 2011-05-11 09:30:00  

void reverse() { struct node *p; p=start;//start holds the address of the first node

Anupam

on 2011-05-11 09:30:00  

void reverse() { struct node *p1,*p2,*p3; p1=start; p2=p1->next; p1->next=NULL; while (p2!=NULL) { p3=p2->next; p1=p2; p2->next=p1; p2=p3; } start=p2; }