Output of a C function

Given the following structure of Node of the Linked List: struct Node{ int data; Node *link; }; What is the purpose of the below function void myFun(Node* head) { if(NULL == head){ return; } printf(“%d “, head->data); if(head->link != NULL ) myFun(head->link->link); printf(“%d “, head->data); }

Delete a linked list

Write a function to delete a linked list. The function should take a pointer to the head of the list and should delete all the nodes in the linked list. Signature of the function should be like void deleteList(Node** head); This function is accepting Node ** and not Node* because it need to change the […]

Insert in a sorted linked list

Given a linked list, with all the nodes in sorted order. Write a function that inserts a new integer in the sorted manner. i.e If the list is as given below: 3 -> 6 -> 9 -> 10 -> 15 And if you want to insert 8 in this list, it should be inserted as […]

Check if a linked list is palindrome

Write a function to check if a Singly linked list is a palindrome or not. For example, the linked list 2 -> 3 -> 4 -> 5 -> 4 -> 3 -> 2 is a palindrome M -> A -> L -> A-> Y -> A -> L -> A -> M is a palindrome […]

Delete alternate node of the linked list

Given a linked list. Write code to delete alternate nodes from the list. For example: If the list given is 2 -> 3 -> 5 -> 1 -> 4 -> 8 The result should be 2 -> 5 -> 4