3. What will be the output of the following code snippet after inserting a node with value 10 at the beginning of the doubly linked list?
typedef struct Node {
int data;
struct Node* prev;
struct Node* next;
} Node;
Node* head = NULL;
void insertAtBeginning(int val) {
Node* new_node = (Node*)malloc(sizeof(Node));
new_node->data = val;
new_node->prev = NULL;
new_node->next = head;
if (head != NULL) {
head->prev = new_node;
}
head = new_node;
}
int main() {
insertAtBeginning(20);
insertAtBeginning(10);
Node* temp = head;
while (temp != NULL) {
printf("%d ", temp->data);
temp = temp->next;
}
return 0;
}