[理工] DS 101台大

看板Grad-ProbAsk作者 (yang)時間10年前 (2014/02/19 15:18), 編輯推噓3(304)
留言7則, 4人參與, 最新討論串1/2 (看更多)
1. Assume that the elements are pairwise distinct. Answer the following questions on sorting algorithms. (2)A single comparison between two elements can distinguish up to 2 permutations. How many permutations can be distinguished using k comparisons? 我的答案:(k+1)! 不知道這題的意思是什麼,我的假設是在k+1個數之下做 k comparisons,如果有3個數做2 comparisons 應該可以有 3!個組合,因為每種組合似乎都可以用最多兩次交換就可以得到。 這題之前有人討論過,看完還是不解,不知道大家的想法如何。感謝! -- Sent from my iPhone -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 42.71.126.67

02/19 16:28, , 1F
我覺得是2^k種,我是用decision tree的leaf想的,他說都
02/19 16:28, 1F

02/19 16:28, , 2F
不一樣是說明決策樹是2元而不是三元。
02/19 16:28, 2F

02/19 16:59, , 3F
想法跟原PO一樣,k個comparisons 可以排序k+1個數
02/19 16:59, 3F

02/19 17:00, , 4F
k+1個數總共有 (k+1)!個permutations
02/19 17:00, 4F

02/19 17:04, , 5F
NO 我說錯了 別理我XD
02/19 17:04, 5F

02/19 18:53, , 6F
X覺得蠻有可能是2^k的
02/19 18:53, 6F

02/20 01:38, , 7F
我也覺得是2^k
02/20 01:38, 7F
文章代碼(AID): #1J15hI1p (Grad-ProbAsk)
討論串 (同標題文章)
文章代碼(AID): #1J15hI1p (Grad-ProbAsk)