作者cansister (cansister)
看板Grad-ProbAsk
标题Re: [理工] [资结]-交大96-资讯
时间Tue Jan 5 23:29:30 2010
※ 引述《b76516 (阿聪)》之铭言:
: 请问一下96年交大资讯资结第5题
: http://www2.lib.nctu.edu.tw/n_exam/exam96/cslz/cslz1001.pdf
: 请问他给的程式码
: Procedure Mystery(x)
: {
: if(x is not equal to parent[x])
: then parent[x] <- Mystery(parent[x]);
: return parent[x];
: }
: parent[x] <- Mystery(parent[x])
: 请问这行程式码的意思是
: Mystery(parent[x])的回传值 指向 parent[x]
: 还是 parent[x]=Mystery(parent[x])的回传值
: 谢谢
Consider the following input what will be the output and the rooted after
executing Mystery(Y).Draw the tree.
Root
○
↗ ↗ ↑ ↖ ↖
A○ ○F ○Y ○C ○B
↖ ↗
D○ E○
↖ ↖
G○ X○
如果Y为Mystery()的input时,最後结果图形会变成上图,
而Y→F→C→A→Root这条path上的node都会指向Root。
不知道你说的所有的点,是指整个图形的点还是这条path上的点
所以我就画图这个图来(有点丑XD)
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 220.134.129.184