recategorized by
28,635 views
3 votes
3 votes

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 segment 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?

  1. X$\rightarrow$Bwd$\rightarrow$Fwd = X$\rightarrow$Fwd; X$\rightarrow$Fwd$\rightarrow$Bwd = X$\rightarrow$Bwd;
  2. X$\rightarrow$Bwd.Fwd = X$\rightarrow$Fwd; X.Fwd$\rightarrow$Bwd = X$\rightarrow$Bwd;
  3. X.Bwd$\rightarrow$Fwd = X.Bwd; x$\rightarrow$Fwd.Bwd = X.Bwd;
  4. X$\rightarrow$Bwd$\rightarrow$Fwd = X$\rightarrow$Bwd; X$\rightarrow$Fwd$\rightarrow$Bwd = X$\rightarrow$Fwd;
recategorized by

2 Answers

Best answer
7 votes
7 votes

X $\rightarrow$ Bwd $\rightarrow$ Fwd = X $\rightarrow$ Fwd
X → Fwd → Bwd = X → Bwd

Option A is correct. 

selected by
Answer:

Related questions

5 votes
5 votes
2 answers
2
Arjun asked Apr 22, 2018
15,117 views
Given a binary-max heap. The elements are stored in an arrays as $25, 14, 16, 13, 10, 8, 12$. What is the content of the array after two delete operations?$14,13,8,12,10$...
2 votes
2 votes
4 answers
3
Arjun asked Apr 22, 2018
6,417 views
If $\text{Tree-1}$ and $\text{Tree-2}$ are the trees indicated below:Which traversals of $\text{Tree-1}$ and $\text{Tree-2}$, respectively, will produce the same sequence...