Skip to main content

Practice ยท 1 of 2

List Surgery

Implement the singly list core. The boilerplate declares: ``c typedef struct SNode { int value; struct SNode *next; } SNode; /* all take/return the caller's head pointer by address */ int s_push(SNode **head, int v); /* 0 ok, -1 oom */ int s_pop(SNode **head, int *out); /* 0 ok, -1 empty */ int s_remove(SNode **head, int v); /* 1 removed, 0 absent */ size_t s_len(const SNode *head); int s_sum(const SNode *head); void s_clear(SNode **head); /* frees all, head becomes NULL */ /* insert keeping ascending order; 0 ok, -1 oom */ int s_insert_sorted(SNode **head, int v); ``

Difficulty: intermediate

Back to lesson: Practice: Singly List Gym