From 3805cd828053229058f68268994eec1a3ad83f11 Mon Sep 17 00:00:00 2001 From: Daniel Kao Date: Sat, 24 Feb 2024 14:53:59 -0800 Subject: [PATCH] fix explanation for q4 --- src/pages/Exercise6.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/Exercise6.tsx b/src/pages/Exercise6.tsx index dd0782a1..59b47a15 100644 --- a/src/pages/Exercise6.tsx +++ b/src/pages/Exercise6.tsx @@ -114,7 +114,7 @@ const question4 = [ 'Not quite, if we just take the first two iterations, we delete the head node, then we dereference the head pointer to the head node to get the next pointer and then delete that. This is a problem because we access the deleted head node, which is undefined behavior.', ], [ - 'delete head;\n\nfor(Node* ptr = head->next; ptr != nullptr; ptr = ptr->next)\n{\n delete ptr;\n}', + 'delete head;\nfor(Node* ptr = head->next; ptr != nullptr; ptr = ptr->next)\n{\n delete ptr;\n}', 'Not quite, since we deleted the head node already, referencing head->next dereferences the head pointer to the head node and is undefined behavior.', ], [