3. Given the following code snippet for inserting at the end of a circular linked list, what will be the printed list after insertion?
struct Node {
int data;
struct Node* next;
};
void printList(struct Node* head) {
struct Node* temp = head;
if (head != NULL) {
do {
printf("%d -> ", temp->data);
temp = temp->next;
} while (temp != head);
}
printf("NULL\n");
}
int main() {
struct Node* head = (struct Node*)malloc(sizeof(struct Node));
struct Node* second = (struct Node*)malloc(sizeof(struct Node));
struct Node* third = (struct Node*)malloc(sizeof(struct Node));
head->data = 1; head->next = second;
second->data = 2; second->next = third;
third->data = 3; third->next = head;
// Insert new node with data 4 at end
struct Node* newNode = (struct Node*)malloc(sizeof(struct Node));
newNode->data = 4;
newNode->next = head;
third->next = newNode;
printList(head);
return 0;
}