Re: 算法問題 (從N個set選m個包含最少的元素)
※ 引述《Lordaeron (Terry)》之銘言:
: init :S0={0}, S1={1}, S2={2},S3={3}, S4={1,2}, S5={1,2}, S6={2,3}, S7={1,3}
: 1.S0={0}, S1={}, S2={2},S3={3}, S4={,2}, S5={,2}, S6={2,3}, S7={,3}
: 2.S0={0}, S1={}, S2={},S3={3}, S4={,}, S5={,}, S6={,3}, S7={,3}
: 3.S0={0}, S1={}, S2={},S3={}, S4={,}, S5={,}, S6={,}, S7={,}
: so, S4={,}, S5={,}, S6={,}, S7={,} 為所選,因為被刪的element count 最大的
這種解釋方法太恐怖. 你可能認為會,發生重覆而刪掉的位置,代表那些集合合併之後
增加總共元素的數目的機會會減低,所以最後你要挑刪掉的元素項目較多的集合,但是,
顯然是忽略了其他沒有重覆元素存在,然而並不會增加合併元素數目的集合.
例如:
S0={0}, S1={1], S2={2}, S3={3}, S4={1,2}, S5={1,2}, S6={2,3}, S7={3,4}
1.因為1有重覆所以刪掉全部的1:
S0={0}, S1={], S2={2}, S3={3}, S4={,2}, S5={,2}, S6={2,3}, S7={3,4}
2.因為2有重覆所以刪掉全部的2:
S0={0}, S1={], S2={}, S3={3}, S4={,}, S5={,}, S6={,3}, S7={3,4}
3.因為3有重覆所以刪掉全部的3:
S0={0}, S1={], S2={}, S3={}, S4={,}, S5={,}, S6={,}, S7={,4}
4.已經沒有重覆了所以依照被刪掉的元素數目,由大到小排序:
S4={,}, S5={,}, S6={,}, S7={,4}, S1={], S2={}, S3={}, S0={0}
5.因為指定要的M sets, M數目為4,所以取前四個sets:
S4 U S5 U S6 U S7 = {1,2,3,4}
S4 U S5 U S6 U S7 是你所提刪除方式的結果,雖然它是原po所言 "數目越少越好"
的潛在解之一, 但是這個情況,是 S1 U S2 U S4 U S5 = {1,2} 答案比較好.
而且你的方法所找出來的解,不但品質差,而且相當差.
實作上很難實作,答案是否適當也要看情況,而且也沒有相當的道理讓人相信
這演算法是對的.
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 59.112.227.2
※ 編輯: yauhh 來自: 59.112.227.2 (06/10 06:53)
→
06/10 06:56, , 1F
06/10 06:56, 1F
→
06/10 06:57, , 2F
06/10 06:57, 2F
→
06/10 06:57, , 3F
06/10 06:57, 3F
→
06/10 06:57, , 4F
06/10 06:57, 4F
→
06/10 07:04, , 5F
06/10 07:04, 5F
→
06/10 07:05, , 6F
06/10 07:05, 6F
→
06/10 07:05, , 7F
06/10 07:05, 7F
→
06/10 07:05, , 8F
06/10 07:05, 8F
→
06/10 07:06, , 9F
06/10 07:06, 9F
→
06/10 07:07, , 10F
06/10 07:07, 10F
→
06/10 07:07, , 11F
06/10 07:07, 11F
→
06/10 07:07, , 12F
06/10 07:07, 12F
→
06/10 07:07, , 13F
06/10 07:07, 13F
→
06/10 07:08, , 14F
06/10 07:08, 14F
→
06/10 07:15, , 15F
06/10 07:15, 15F
→
06/10 07:15, , 16F
06/10 07:15, 16F
→
06/10 07:16, , 17F
06/10 07:16, 17F
→
06/10 07:17, , 18F
06/10 07:17, 18F
→
06/10 07:17, , 19F
06/10 07:17, 19F
→
06/10 07:18, , 20F
06/10 07:18, 20F
→
06/10 07:18, , 21F
06/10 07:18, 21F
→
06/10 07:18, , 22F
06/10 07:18, 22F
→
06/10 07:18, , 23F
06/10 07:18, 23F
→
06/10 07:19, , 24F
06/10 07:19, 24F
→
06/10 07:19, , 25F
06/10 07:19, 25F
→
06/10 07:20, , 26F
06/10 07:20, 26F
→
06/10 07:20, , 27F
06/10 07:20, 27F
→
06/10 07:20, , 28F
06/10 07:20, 28F
→
06/10 07:20, , 29F
06/10 07:20, 29F
→
06/10 07:20, , 30F
06/10 07:20, 30F
→
06/10 07:21, , 31F
06/10 07:21, 31F
→
06/10 07:21, , 32F
06/10 07:21, 32F
→
06/10 07:21, , 33F
06/10 07:21, 33F
你在講什麼? 你說你的推文重要到值得看嗎?
抱歉,我只看原po的問題. 至於你自己製造的問題,請自己收拾.
→
06/10 07:21, , 34F
06/10 07:21, 34F
→
06/10 07:22, , 35F
06/10 07:22, 35F
→
06/10 07:22, , 36F
06/10 07:22, 36F
※ 編輯: yauhh 來自: 59.112.227.2 (06/10 07:23)
→
06/10 07:22, , 37F
06/10 07:22, 37F
→
06/10 07:23, , 38F
06/10 07:23, 38F
→
06/10 07:23, , 39F
06/10 07:23, 39F
→
06/10 07:23, , 40F
06/10 07:23, 40F
→
06/10 07:24, , 41F
06/10 07:24, 41F
→
06/10 07:24, , 42F
06/10 07:24, 42F
→
06/10 07:24, , 43F
06/10 07:24, 43F
→
06/10 07:25, , 44F
06/10 07:25, 44F
→
06/10 07:25, , 45F
06/10 07:25, 45F
→
06/10 07:26, , 46F
06/10 07:26, 46F
→
06/10 07:26, , 47F
06/10 07:26, 47F
→
06/10 07:26, , 48F
06/10 07:26, 48F
→
06/10 07:27, , 49F
06/10 07:27, 49F
→
06/10 07:27, , 50F
06/10 07:27, 50F
→
06/10 07:27, , 51F
06/10 07:27, 51F
→
06/10 07:27, , 52F
06/10 07:27, 52F
→
06/10 07:28, , 53F
06/10 07:28, 53F
→
06/10 07:28, , 54F
06/10 07:28, 54F
→
06/10 07:28, , 55F
06/10 07:28, 55F
→
06/10 07:28, , 56F
06/10 07:28, 56F
→
06/10 07:28, , 57F
06/10 07:28, 57F
→
06/10 07:29, , 58F
06/10 07:29, 58F
→
06/10 07:29, , 59F
06/10 07:29, 59F
→
06/10 07:29, , 60F
06/10 07:29, 60F
→
06/10 07:30, , 61F
06/10 07:30, 61F
→
06/10 07:30, , 62F
06/10 07:30, 62F
→
06/10 07:30, , 63F
06/10 07:30, 63F
→
06/10 07:30, , 64F
06/10 07:30, 64F
→
06/10 07:31, , 65F
06/10 07:31, 65F
→
06/10 07:33, , 66F
06/10 07:33, 66F
→
06/10 07:33, , 67F
06/10 07:33, 67F
→
06/10 07:33, , 68F
06/10 07:33, 68F
→
06/10 07:34, , 69F
06/10 07:34, 69F
不好意思,不屑分享. 因為到此我感覺你很沒有誠意.
→
06/10 07:34, , 70F
06/10 07:34, 70F
→
06/10 07:34, , 71F
06/10 07:34, 71F
※ 編輯: yauhh 來自: 59.112.227.2 (06/10 07:35)
→
06/10 07:36, , 72F
06/10 07:36, 72F
→
06/10 07:36, , 73F
06/10 07:36, 73F
→
06/10 07:37, , 74F
06/10 07:37, 74F
→
06/10 07:38, , 75F
06/10 07:38, 75F
→
06/10 07:40, , 76F
06/10 07:40, 76F
→
06/10 07:41, , 77F
06/10 07:41, 77F
→
06/10 07:42, , 78F
06/10 07:42, 78F
推
06/11 15:21, , 79F
06/11 15:21, 79F
→
06/11 16:21, , 80F
06/11 16:21, 80F
→
06/11 16:21, , 81F
06/11 16:21, 81F
→
07/01 19:43, , 82F
07/01 19:43, 82F
→
07/01 19:44, , 83F
07/01 19:44, 83F
→
07/01 19:44, , 84F
07/01 19:44, 84F
討論串 (同標題文章)
本文引述了以下文章的的內容:
完整討論串 (本文為第 7 之 8 篇):
Programming 近期熱門文章
PTT數位生活區 即時熱門文章