Complete the code to declare a pointer to the next node in a linked list node structure.
struct Node {
int data;
struct Node* [1];
};The pointer to the next node in a linked list is commonly named next.
Complete the code to create a new node dynamically in a linked list.
struct Node* newNode = (struct Node*) malloc(sizeof([1]));We allocate memory for a Node structure, so sizeof(Node) is correct.
Fix the error in the code to properly link a new node to the existing linked list.
newNode->[1] = head;The new node's next pointer should point to the current head to insert at the front.
Fill both blanks to complete the function that inserts a new node at the beginning of the linked list.
void insertAtFront(struct Node** head_ref, int new_data) {
struct Node* newNode = (struct Node*) malloc(sizeof([1]));
newNode->data = new_data;
newNode->[2] = *head_ref;
*head_ref = newNode;
}Memory is allocated for a Node, and the new node's next pointer is set to the current head.
Fill all three blanks to complete the function that prints all elements of a linked list.
void printList(struct Node* [1]) { struct Node* [2] = [3]; while (temp != NULL) { printf("%d -> ", temp->data); temp = temp->next; } printf("NULL\n"); }
The function takes a pointer named head. A temporary pointer temp is set to head to traverse the list.
