Re: [algogeeks] Re: MS Question -Reverse a Linked List in size of 2

2012-01-24 Thread Ashish Goel
struct node { int data; struct node *link; }; node* CreateNode(int val) { node* root = (node*)malloc(sizeof(struct node)); root-data = val; root-link = NULL; return root; } node* createList(int *arr, int n) { node * root =

Re: [algogeeks] Re: MS Question -Reverse a Linked List in size of 2

2012-01-24 Thread atul anand
@Ashish : seems exactly similar to Lucifer code or you modified something in his code ?? ... On Tue, Jan 24, 2012 at 2:02 PM, Ashish Goel ashg...@gmail.com wrote: struct node { int data; struct node *link; }; node* CreateNode(int val) { node* root =

Re: [algogeeks] Re: MS Question -Reverse a Linked List in size of 2

2012-01-24 Thread Ashish Goel
oh, a possible mistake from my side, ignore my mail please... Best Regards Ashish Goel Think positive and find fuel in failure +919985813081 +919966006652 On Tue, Jan 24, 2012 at 3:08 PM, atul anand atul.87fri...@gmail.com wrote: @Ashish : seems exactly similar to Lucifer code or you

Re: [algogeeks] Re: MS Question -Reverse a Linked List in size of 2

2012-01-24 Thread praveen raj
Steps: 1)Reverse the list ... 2)Now do the swap two nodes... consecutively... PRAVEEN RAJ DELHI COLLEGE OF ENGINEERING -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To

[algogeeks] Re: MS Question -Reverse a Linked List in size of 2

2012-01-23 Thread Lucifer
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

[algogeeks] Re: MS Question -Reverse a Linked List in size of 2

2012-01-23 Thread Lucifer
@above attaching the file.. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view this discussion on the web visit https://groups.google.com/d/msg/algogeeks/-/YW_phbT3me4J. To post to this group, send email to algogeeks@googlegroups.com.