第31860题 单选题
在非空双向链表中,将新结点插入到指定结点p的后方,以下操作序列正确的是?

已知双向链表的结点结构定义为:

typedef struct DNode {
    int data;
    struct DNode *prior; // 前驱指针
    struct DNode *next;  // 后继指针
} DNode;

现有非空双向链表,指针p指向链表中某个非尾结点,指针q指向待插入的新结点,要求将q插入到p所指结点的后面。

A

q->prior = p; q->next = p->next; p->next->prior = q; p->next = q;

B

p->next = q; q->prior = p; q->next = p->next; p->next->prior = q;

C

q->next = p->next; p->next = q; q->prior = p; p->next->prior = q;

D

q->prior = p; p->next = q; q->next = p->next; p->next->prior = q;

程序运行统计
暂无判题统计
提交0次 正确率0.00%
答案解析