what is the space complexity for deleting a linked list

what is the space complexity for deleting a linked list

1 year ago 53
Nature

The space complexity for deleting a linked list is O(1) . This is because deleting a node in a singly linked list only requires breaking and creating links in constant time. In order to delete a node, you need to break the link between that node and the one pointing to it. If you have a pointer to the node you want to remove, the time complexity is O(1) . However, if you want to delete a specific element and need to traverse the list to find it, the time complexity is O(n) .

Read Entire Article