[理工] 104 成大電通 資結

作者: ooxx5626 (楊霖村)   2018-01-24 15:13:52
1.When n (n>2) data items are sorted using bubble sort algorithm and the number of key comparison is k, if the number of data item exchanges is 1, then k<=2*(n-1)
這邊不太懂他的key comparison 是什麼意思
下面這裡 不懂他題目中的兩個key是在幹嘛的@@
像第一題找適合的sort into non-decreasing order based on key1 就不知道這個key1是什麼了…
http://i.imgur.com/vuXtkHw.jpg
順便問一下non-decreasing order是指說不在worst case嗎? 寫題目常常看到
作者: nova06091   2018-01-24 16:05:00
key comparison 就是比較次數,exchange 1次表示bubblesort只做2回合,所以比較次數是(n-1)+(n-2) < 2*(n-1), ture
作者: aggress5566 (哩賀)   2018-01-24 16:07:00
他題目就跟你說明key是什麼了 然後nondecreasing order就是 >=的排序 這丟google都有答案 為什麼要上來問
作者: nova06091   2018-01-24 16:08:00
non decreasing order就是ascended order
作者: ooxx5626 (楊霖村)   2018-01-24 21:45:00
謝謝n大跟a大 我原本是想說這個 key comparison跟一般的比較是差在哪里,不過看來應該沒差說想多了@@non-decreasing 我知道是>=但是想說是不是還有其他意思就上來問問看了

Links booklink

Contact Us: admin [ a t ] ucptt.com