Re: [algogeeks] Re: Problems on Linked List

2011-08-13 Thread aditya kumar
@mohit : +1 On Sat, Aug 13, 2011 at 9:20 AM, Raghavan its...@gmail.com wrote: First question: - .Read the data from the first list and put it in a stack - Traverse the next list and compare by reading elements from the stack - This would solve it Second question: - Take an

Re: [algogeeks] Re: Problems on Linked List

2011-08-13 Thread *$*
folks .. for second problem .. the mentioned algo doesn't work for last node.. I mean copying data of next node and aalso making nxt-nxt as nxt node.. and deleting the next node.. in case of last node.. how can we delete the last node being on that node? even though if we use free (node) ... the

Re: [algogeeks] Re: Problems on Linked List

2011-08-13 Thread siddharam suresh
yes you are right Thank you, Siddharam On Thu, Aug 11, 2011 at 10:21 AM, Abhishek gupta mailatabhishekgu...@gmail.com wrote: Q2). i think for second question it will be enough to just swap the data of current node to next node, and delete the next node. it will be like, //for swap int

[algogeeks] Re: Problems on Linked List

2011-08-12 Thread Abhishek gupta
Q2). i think for second question it will be enough to just swap the data of current node to next node, and delete the next node. it will be like, //for swap int temp=current-data; current-data=current-next-data; current-next-data=temp; //for delete struct node *temp; temp=current-next;

Re: [algogeeks] Re: Problems on Linked List

2011-08-12 Thread Raghavan
First question: - .Read the data from the first list and put it in a stack - Traverse the next list and compare by reading elements from the stack - This would solve it Second question: - Take an list like 1-2--3-4 - If you are given with 2, juz copy the value and reference of

Re: [algogeeks] Re: Problems on Linked List

2011-08-11 Thread mohit verma
hey guys , can't it be like this without reversing list- int rec_iterate(Node head1,Node *head2) { if(head1 ==NULL ) return 1; if(rec_iterate(head1-n,head2) == 0) return 0; if (head1-value == (*head2)-value) { *head2=(*head2)-next; return 1; } else

[algogeeks] Re: Problems on Linked List

2011-08-10 Thread Don
Q1: The function below reverses a linked list in place. Call it on one of the lists, compare the resulting list to the other list. Then call it again to put the list back in its original order. list Reverse(list head) { list T, prv, nxt; prv = head; for(T = head-next; T; T = nxt) {