Complete the code to declare a node pointer named 'head' initialized to nullptr.
Node* [1] = nullptr;The pointer 'head' is commonly used to mark the start of a linked list. Initializing it to nullptr means the list is empty.
Complete the code to create a new node dynamically using 'new'.
Node* newNode = [1] Node();In C++, 'new' is used to allocate memory dynamically for objects like nodes.
Fix the error in the code to link the new node to the existing list by setting 'next' pointer.
newNode->next = [1];To insert a new node at the beginning, its 'next' pointer should point to the current head of the list.
Fill both blanks to complete the insertion of newNode at the beginning of the list.
newNode->next = [1]; [2] = newNode;
First, the new node's 'next' points to the current head. Then, 'head' is updated to the new node.
Fill all three blanks to create a simple linked list with two nodes and link them correctly.
Node* first = [1] Node(); Node* second = [2] Node(); first->next = [3];
Both nodes are created with 'new'. The first node's 'next' points to the second node to link them.
