From 26013e337dca16ceadb201e6349864b440dc1b14 Mon Sep 17 00:00:00 2001 From: Aadit Kamat Date: Sun, 30 Aug 2020 18:18:21 +0800 Subject: [PATCH] Update linked list insertion and deletion --- contents/algorithms/linked-list.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contents/algorithms/linked-list.md b/contents/algorithms/linked-list.md index 64974ef6..ab3f58e8 100644 --- a/contents/algorithms/linked-list.md +++ b/contents/algorithms/linked-list.md @@ -5,7 +5,7 @@ title: Linked List ## Notes -Like arrays, linked lists are used to represent sequential data. The benefit of linked lists is that insertion and deletion from anywhere in the list is O(1) whereas in arrays the following elements will have to be shifted. +Like arrays, linked lists are used to represent sequential data. The benefit of linked lists is that insertion and deletion of a node in the list (given its location) is O(1) whereas in arrays the following elements will have to be shifted. Adding a dummy node at the head and/or tail might help to handle many edge cases where operations have to be performed at the head or the tail. The presence of dummy nodes essentially ensures that operations will never have be done on the head or the tail, thereby removing a lot of headache in writing conditional checks to dealing with null pointers. Be sure to remember to remove them at the end of the operation.