@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 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;
>   if (pCurr->data <pRest->data)
>   {
>     if (pPrev) { pPrev->next = pRest; };
>     free(pCurr);
>   }
>  else
>  {
>    pCurr->next = pRest;
>  }
>    return pCurr;
> }
>
>
> Best Regards
> Ashish Goel
> "Think positive and find fuel in failure"
> +919985813081
> +919966006652
>
> --
> 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 unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>

-- 
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 unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to