Dark Mode

301 views

3 votes

A doubly linked list is declared as:

struct Node { int Value; struct Node *prev; struct Node *next; };

Which of the following segment of code deletes the node pointed to by $\text{X}$ from the doubly linked list, if it is assumed that $\text{X}$ points to neither the first nor the last node of the list?

- $\text{X} \rightarrow$ prev $\rightarrow $ next $= \text{X} \rightarrow$ next $; \text{X} \rightarrow$ next $\rightarrow$ prev $= \text{X} \rightarrow$ prev; free(X);
- $\text{X} \rightarrow$ prev.next $ = \text{X} \rightarrow$ next $; X.$ next $\rightarrow$ prev $ = \text{X} \rightarrow$ prev; free(X);
- $\text{X} \rightarrow.$ prev $\rightarrow$ next $= \text{X}.$prev $; \text{X} \rightarrow$ next.prev $= \text{X}.$prev; free(X);
- $\text{X} \rightarrow$ prev $\rightarrow$ next $= \text{X} \rightarrow$ prev $; \text{X} \rightarrow$ next $\rightarrow$ prev $= \text{X} \rightarrow$ next; free(X);