From 9225582340de1679222ae5ce7aae49d8e7440e79 Mon Sep 17 00:00:00 2001 From: zleyyij <75810274+zleyyij@users.noreply.github.com> Date: Tue, 19 Nov 2024 21:54:36 -0700 Subject: [PATCH] vault backup: 2024-11-19 21:54:36 --- .../ECE1400/Chapter 17 Exercises.md | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/education/software development/ECE1400/Chapter 17 Exercises.md b/education/software development/ECE1400/Chapter 17 Exercises.md index 53868b1..78e449d 100644 --- a/education/software development/ECE1400/Chapter 17 Exercises.md +++ b/education/software development/ECE1400/Chapter 17 Exercises.md @@ -63,7 +63,22 @@ while (p != NULL) { 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; + } + prev->next = new_node; + new_node->next = cur; + return list; +} +``` + + +```c +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; } prev->next = new_node; new_node->next = cur;