看板 Grad-ProbAsk 關於我們 聯絡資訊
Suppose that we have file in which each record has three-component key (k1, k2, k3). To sort these into lexicographic order, so we decide to sort the entire file by k3, then sort the entire file by k2, and finally sort the entire by k1. For this to work correctly, which sorts must be done by stable sorting algorithm? A.The sort by k3. B.The sort by k2. C.The sort by k1. D.Both A and B E.Both B and C 還有請問甚麼是lexicographic order?? 這題有點困惑.... 有請高手解答.... 鋼溫!! -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 223.140.237.117
yyc1217:字典順序 11/07 00:45
kiwidoit:答案是不是E @@? 11/07 07:02
kiwidoit:感覺除了sort k1可以不用stable之外 後面兩個都會影響前 11/07 07:03
kiwidoit:的正確性 11/07 07:03
kiwidoit:打錯 k3 11/07 07:04
jim055006:對!!是E... 11/07 23:01
jim055006:為什麼呢??....我還是不懂XD 11/07 23:01
※ 編輯: jim055006 來自: 223.140.132.49 (11/08 21:48)
kiwidoit:stable就是兩個相同鍵值得element在排序前後順序不變 11/09 02:19
kiwidoit:所以除了第一個sort的不用管是不是stable 後面的就一定要 11/09 02:19
kiwidoit:stable,不然會影響前面sort好的資料 11/09 02:20
kiwidoit:這一題應該只是單純考你知不知道stable sort而以= =... 11/09 02:22
jim055006:感謝K大....我在好好想想.... 11/09 22:34
sneak: 所以除了第一個sort https://daxiv.com 09/11 14:35