Open In App
Related Articles

ISRO | ISRO CS 2018 | Question 19

Improve Article
Save Article
Like Article

A doubly linked list is declared as

struct Node {
       int Value;
       struct Node *Fwd;
       struct Node *Bwd;

Where Fwd and Bwd represent forward and backward link to the adjacent elements of the list. Which of the following segments of code deletes the node pointed to by X from the doubly linked list, if it is assumed that X points to neither the first nor the last node of the list?


X->Bwd->Fwd = X->Fwd; X->Fwd->Bwd = X->Bwd ;


X->Bwd.Fwd = X->Fwd ; X.Fwd->Bwd = X->Bwd ;


X.Bwd->Fwd = X.Bwd ; X->Fwd.Bwd = X.Bwd ;


X->Bwd->Fwd = X->Bwd ; X->Fwd->Bwd = X->Fwd;

Answer: (A)


To delete a node from a doubly linked list, we need to update the links of the previous and next nodes to point to each other, effectively removing the node to be deleted from the list.

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

Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out - check it out now!

Last Updated : 02 Jul, 2018
Like Article
Save Article
Similar Reads