diff --git a/education/software development/ECE1400/Chapter 17 Exercises.md b/education/software development/ECE1400/Chapter 17 Exercises.md index 67adf53..6f3d402 100644 --- a/education/software development/ECE1400/Chapter 17 Exercises.md +++ b/education/software development/ECE1400/Chapter 17 Exercises.md @@ -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 *cur = list, *prev = NULL; while (cur->value <= new_node->value) { + prev = cur; + cur = cur->next; if (cur->next == NULL) { break; } - prev = cur; - cur = cur->next; } prev->next = new_node; new_node->next = cur;