Complete the code to create a new node in a linked list.
Node newNode = new Node([1]);The new node must be created with a value, so we pass value to the constructor.
Complete the code to add a new node at the beginning of the linked list.
newNode.[1] = head;
head = newNode;We set the next pointer of the new node to the current head to link it properly.
Fix the error in the code that tries to traverse the linked list.
Node current = head; while (current != [1]) { Console.WriteLine(current.value); current = current.next; }
The loop should continue until current is null, which means the end of the list.
Fill both blanks to complete the code that inserts a node after a given node.
newNode.[1] = prevNode.[2]; prevNode.next = newNode;
The new node's next should point to the previous node's next, then the previous node's next is updated to the new node.
Fill all three blanks to complete the code that removes the first node from the linked list.
if (head != [1]) { Node temp = head; head = head.[2]; temp.[3] = null; }
We check if head is not null, then move head to the next node, and finally disconnect the removed node by setting its next to null.
