I just wrote a code which would work for any given size K. I tested it with K = 1 till 7. [ in the question asked above K=2] Also, tested for corner cases..
If you guys are interested, then have a look at the code.. I have added few helper functions so that you can directly run the code and use it for testing purposes as well.. Code is in the attached file.. On Jan 23, 11:34 pm, Dhaval Patel <[email protected]> wrote: > struct node* revll(struct node* root) > { > return reverse(root,NULL); > > } > > struct node* reverse(struct node* head,struct node* prev) > { > struct node* temp1; > if(head->next==NULL) > { > head->next=prev; > return head;} > > else > { > temp1=reverse(head->next,head); > head->next=prev; > return temp1; > > > > > > > > } > } -- 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?hl=en.
