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 [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.