Open In App
Related Articles

Data Structures | Linked List | Question 15

Improve Article
Improve
Save Article
Save
Like Article
Like

Given pointer to a node X in a singly linked list. Only one pointer is given, pointer to head node is not given, can we delete the node X from given linked list?

(A)

Possible if X is not last node. Use following two steps (a) Copy the data of next of X to X. (b)Update the pointer of node X to the node after the next node. Delete next of X.

(B)

Possible if size of linked list is even.

(C)

Possible if size of linked list is odd

(D)

Possible if X is not first node. Use following two steps (a) Copy the data of next of X to X. (b) Delete next of X.


Answer: (A)

Explanation:

Following are simple steps.

    struct node *temp  = X->next;
    X->data  = temp->data;
    X->next  = temp->next;
    free(temp); 


Quiz of this Question
Please comment below if you find anything wrong in the above post

Feeling lost in the world of random DSA topics, wasting time without progress? It's time for a change! Join our DSA course, where we'll guide you on an exciting journey to master DSA efficiently and on schedule.
Ready to dive in? Explore our Free Demo Content and join our DSA course, trusted by over 100,000 geeks!

Last Updated : 28 Jun, 2021
Like Article
Save Article
Previous
Next
Similar Reads
Complete Tutorials