问答题 如下为拓扑排序的C程序。 (1)列出对右图执行该程序后的输出结果。 (2)在程序空白处填上适当语句。 void topsort(hdnodes graph[],int n) {int i,J,k,top;node pointer ptr; top=-1; for(i=0; i link) {k=ptr->vertex;graph[k].count一一; if(③){graph[k].count=top;top=k;) } } } 【浙江大学2000六(15分)】 [*]
【正确答案】正确答案:(1)V1 V4 V3 V6 V2 V5(尽管图以邻接表为存储结构,但因没规定邻接点的排列,所以结果是不唯一的。本答案是按邻接点升序排列给出的。)(2)①top==一1 ②top=graph[j].count ③graph[k].count==0
【答案解析】