vault backup: 2024-11-19 22:10:22

This commit is contained in:
zleyyij 2024-11-19 22:10:22 -07:00
parent 56b77cc8ff
commit 1911f9cfef

View File

@ -77,11 +77,11 @@ In the above code, if the new item needs to be inserted at the *end* of the list
struct node *insert_into_ordered_list(struct node *list, struct node *new_node) { struct node *insert_into_ordered_list(struct node *list, struct node *new_node) {
struct node *cur = list, *prev = NULL; struct node *cur = list, *prev = NULL;
while (cur->value <= new_node->value) { while (cur->value <= new_node->value) {
prev = cur;
cur = cur->next;
if (cur->next == NULL) { if (cur->next == NULL) {
break; break;
} }
prev = cur;
cur = cur->next;
} }
prev->next = new_node; prev->next = new_node;
new_node->next = cur; new_node->next = cur;