The V2 version is non-healthy and obviously no more front-end insertion.
INT SLL_INSERT_V2 (Node *current, int value) { node *prev; Node *newNode; while (current != null & & current->value >= value) { prev = current; current = current->next; } newnode = malloc (sizeof (Node)); if (newnode == null) { return false; } newnode->value = value; if (prev == null) { newnode->next = current->next; current->next = Newnode; } else { newnode->next = current; prev->next = newnode; } return true;}
The V3 version implements the Insert function, but it is clear that all inserts are:
The new node is chained to the next node of the current node
Current node chain to new node
So with the third version, all we need is a pointer to the current node and link to the current node.
Int sll_insert_v3 (Node **rootp, int value) { node *newnode; Node *current; Node *prev; current = *rootp; while (current != null && Current->value >= value) { prev = current; current= current->next; } newnode = malloc (sizeof (Node)); newnode->value = value; newnode->next = current; if (prev == null)  {        *ROOTP = newNode; } else { prev->next = nEwnode; } return true;}
V4 Version: Current version, ROOTP as a pointer to link to the current node
int sll_insert_v4 (node **rootp, int value) {node *newnode; Node *current; while (current = *ROOTP) = NULL && current->value >= value) {ROOTP = ¤t->next; } NewNode = malloc (sizeof (Node)); Newnode->value = value; Newnode->next = current->next; *ROOTP = NewNode; return TRUE;}
C-language linked list operations