Consider the following program. printlist() is a function that takes the head of a linked list and prints all nodes values separated by comma. Node is typedefed singly linked list type struct.
void insert1(Node *head,int data)
{
Node *NewNode= (Node *)malloc(sizeof(Node));
NewNode->value=data;
NewNode->next=head;
head=NewNode;
}
void insert2(Node **head_ref,int data)
{
Node *NewNode= (Node *)malloc(sizeof(Node));
NewNode->value=data;
NewNode->next=*(head_ref);
*(head_ref)=NewNode;
}
int main()
{
/* create a linked list 1->2->3->4->5
and head points to the first node.*/
insert1(head,9);
printlist(head); //Line X
//The list is restored to its initial state
insert2(&head,9);
printlist(head); //Line Y
}
Which of the following is/are true about the above program?
- Line $\text{X}$ prints $9,1,2,3,4,5$
- Line $\text{Y}$ prints $9,1,2,3,4,5$
- Line $\text{X}$ prints $1,2,3,4,5$
- Line $\text{Y}$ prints $1,2,3,4,5$