MCQs
Following are simple steps.
struct node *temp = X->next;
X->data = temp->data;
X->next = temp->next;
free(temp);
You need a temp variable to keep track of current node, hence the space complexity is O(1).
All are applications of stack.
Trying to access an element beyond the limits of an array gives ArrayIndexOutOfBoundsException.
Traverse till the end of the list with a pointer 'temp' and another 'cur' which is trailing behind temp, make 'cur' point to trail, this removes all reference for 'temp'.
In the worst case, the position to be inserted maybe at the end of the list, hence you have to traverse through the entire list to get to the correct position, hence O(n).
It is in fact an advantage, interrupts should be given more priority than the task at hand so that the interrupt can be serviced.
If the list is empty make the new node as 'head', otherwise traverse the list to the end and make its 'next' pointer point to the new node, set the new node's next point to the current head and make the new node as the head.