Question: Consider the following code for inserting a node at the front of a singly linked list: Node * tmp = ( Node * ) malloc

Consider the following code for inserting a node at the front of a singly linked list:
Node *tmp =(Node *)malloc(sizeof(Node));
tmp->data =10;
tmp->next = head;
head = tmp;
What is the role of the line tmp->next = head;?
Question 92 options:
To initialize the new node's next pointer to NULL.
To make the new node point to the first node in the list.
To set the head pointer to the new node.
To delete the old head node.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!