Re: [理工] [資結]-交大96-資訊
※ 引述《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
討論串 (同標題文章)
本文引述了以下文章的的內容:
完整討論串 (本文為第 2 之 3 篇):