Skip to content

Instantly share code, notes, and snippets.

@PhDP
Created February 8, 2012 14:50
Show Gist options
  • Save PhDP/1770203 to your computer and use it in GitHub Desktop.
Save PhDP/1770203 to your computer and use it in GitHub Desktop.
int isll_rm_tail(isll *l)
// Slow -> O(n). Return 1 if a node was removed, 0 otherwise. Untested :P
int isll_rm_tail(isll *l)
{
if (l->head == NULL)
{
return 0;
}
if (l->head == l->tail)
{
return isll_rm_next(l, NULL);
}
isllnode *node = l->head;
while (node->next != l->tail)
{
node = node->next;
}
return isll_rm_next(l, node);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment