Re: [algogeeks] MS Question: Delete a node in single linked list if it is less than any of the successor nodes

2012-06-04 Thread Amol Sharma
here is the question ans solution with proper explanation http://www.geeksforgeeks.org/archives/11604 -- Amol Sharma Third Year Student Computer Science and Engineering MNNIT Allahabad http://gplus.to/amolsharma99

Re: [algogeeks] MS Question: Delete a node in single linked list if it is less than any of the successor nodes

2012-06-04 Thread atul anand
whats problem with the approch provided by navin http://k2code.blogspot.in/2011/09/deleting-node-in-singly-linked-list-if.html it seems much simpler ...is there any test case for which it wont work ?? On Mon, Jun 4, 2012 at 3:25 PM, Amol Sharma amolsharm...@gmail.com wrote: here is the

Re: [algogeeks] MS Question: Delete a node in single linked list if it is less than any of the successor nodes

2012-06-01 Thread Hassan Monfared
1- read all elements of list into stack 2- max = stak.pop() 3- if stack.empty() goto 7 4- next=stack.pop() 5- if next max then max=next else delete next from list 6- repeat from 3 7- end! Regards, On Thu, May 31, 2012 at 9:45 PM, atul anand atul.87fri...@gmail.com wrote: @navin : +1 On

[algogeeks] MS Question: Delete a node in single linked list if it is less than any of the successor nodes

2012-05-31 Thread Ashish Goel
the LL is unsorted, is there any better solution that this? struct node* deleteNodes(struct node *pHead, struct node *pPrev) { struct node *pLL = *pHead; if (!pLL) return NULL; struct node *pCurr = pLL; struct node *pRest = deleteNodes(pCurr-next, pCurr); if (!pRest) return pCurr;

Re: [algogeeks] MS Question: Delete a node in single linked list if it is less than any of the successor nodes

2012-05-31 Thread atul anand
@Ashish : please clarify this ques... delete a node in SLL if it is less than *any* of the succesor node .. 1 2 8 10 3 4 7 12 delete 1,2,8,10,3,4,7 ouput will be single node i.e 12 dats what question asks? On Thu, May 31, 2012 at 2:16 PM, Ashish Goel ashg...@gmail.com wrote: the LL is

Re: [algogeeks] MS Question: Delete a node in single linked list if it is less than any of the successor nodes

2012-05-31 Thread Ashish Goel
yes Best Regards Ashish Goel Think positive and find fuel in failure +919985813081 +919966006652 On Thu, May 31, 2012 at 2:34 PM, atul anand atul.87fri...@gmail.com wrote: @Ashish : please clarify this ques... delete a node in SLL if it is less than *any* of the succesor node .. 1 2 8 10

Re: [algogeeks] MS Question: Delete a node in single linked list if it is less than any of the successor nodes

2012-05-31 Thread atul anand
then i guess ...it can be done using stack..with O(n) complexity.. it is similar to finding next greater element http://www.geeksforgeeks.org/archives/8405 element in the stack at the end of the algo...are the element which will remain in the linked list . if stack is not empty then keep

Re: [algogeeks] MS Question: Delete a node in single linked list if it is less than any of the successor nodes

2012-05-31 Thread Ashish Goel
that is what i have done by using recursion=stack. my code has problem, after free(pCurr);, i should have return pRest; Best Regards Ashish Goel Think positive and find fuel in failure +919985813081 +919966006652 On Thu, May 31, 2012 at 4:37 PM, atul anand atul.87fri...@gmail.com wrote: then

Re: [algogeeks] MS Question: Delete a node in single linked list if it is less than any of the successor nodes

2012-05-31 Thread Navin Kumar
I think the easiest method to do this problem is this: http://k2code.blogspot.in/2011/09/deleting-node-in-singly-linked-list-if.html On Thu, May 31, 2012 at 5:58 PM, Ashish Goel ashg...@gmail.com wrote: that is what i have done by using recursion=stack. my code has problem, after

Re: [algogeeks] MS Question: Delete a node in single linked list if it is less than any of the successor nodes

2012-05-31 Thread Nishant Pandey
if i am getting this questions correctly then we have to delete the element till its next is not null ?? please comment if i am wrong ? On Thu, May 31, 2012 at 5:58 PM, Ashish Goel ashg...@gmail.com wrote: that is what i have done by using recursion=stack. my code has problem, after

Re: [algogeeks] MS Question: Delete a node in single linked list if it is less than any of the successor nodes

2012-05-31 Thread atul anand
@navin : +1 On 5/31/12, Navin Kumar algorithm.i...@gmail.com wrote: I think the easiest method to do this problem is this: http://k2code.blogspot.in/2011/09/deleting-node-in-singly-linked-list-if.html On Thu, May 31, 2012 at 5:58 PM, Ashish Goel ashg...@gmail.com wrote: that is what i have