1.#include #include struct Node { int data; struct Node* next; }; void insertAfter(struct Node* prev_node, int new_data) { if (prev_node == NULL) { printf("The given previous node cannot be NULL"); return; } struct Node* new_node = (struct Node*)malloc(sizeof(struct Node)); new_node->data = new_data; new_node->next = prev_node->next; prev_node->next = new_node; } void push(struct Node** head_ref, int new_data) { struct Node* new_node = (struct Node*)malloc(sizeof(struct Node)); new_node->data = new_data; new_node->next = (*head_ref); (*head_ref) = new_node; } void printList(struct Node* node) { while (node != NULL) { printf(" %d", node->data); node = node->next; } printf("\n"); } int main() { struct Node* head = NULL; push(&head, 6); push(&head, 5); push(&head, 4); push(&head, 3); push(&head, 2); printf("Created Linked list is: "); printList(head); insertAfter(head, 1); printf("After inserting 1 after 2: "); printList(head); return 0; } 2.#include #include struct Node { int data; struct Node* next; }; void insertAtHead(struct Node** head, int newData) { struct Node* newNode = (struct Node*)malloc(sizeof(struct Node)); if (newNode == NULL) { fprintf(stderr, "Memory allocation failed.\n"); exit(1); // Exit the program if memory allocation fails } newNode->data = newData; newNode->next = *head; *head = newNode; } int main() { struct Node* head = NULL; insertAtHead(&head, 3); insertAtHead(&head, 2); insertAtHead(&head, 1); struct Node* current = head; while (current != NULL) { printf("%d -> ", current->data); current = current->next; } printf("NULL\n"); return 0; }