单选题
11.
下面的算法实现的是带附加头结点的单链表数据结点逆序连接,空缺处应当填入( )。
void reverse(pointer h){ //h为附加头结点指针
pointer p,q;
P=h一>next;h一>next=NULL;
while(P!=null){
q=P;
P=P一>next:
q一>next=h一>next;
h一>next(________);
}
}
A、
h
B、
P
C、
q
D、
q->next
【正确答案】
C
【答案解析】
h一>next=q;表示将当前结点作为头结点后的第一元素结点插入。
提交答案
关闭