Back to course home
0% completed
Vote For New Content
O(1) to insert after given node
k.kromer
Jul 3, 2024
After a Given Node - O(n): Traverse the list to the desired node and insert the new node after it.
As reflected in the code example, the time complexity for this operation is O(1) since you don't need to traverse the list. You set the next reference of the provided node to the newly created node which in turn points the previous next.
1
0
Comments
Comments