Re: [理工] [資結]-交大96-資訊

看板Grad-ProbAsk作者 (cansister)時間16年前 (2010/01/05 23:29), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串2/3 (看更多)
※ 引述《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
文章代碼(AID): #1BGrhTW2 (Grad-ProbAsk)
文章代碼(AID): #1BGrhTW2 (Grad-ProbAsk)