[問題] 演算法

看板Programming作者 (ted)時間17年前 (2007/01/13 11:16), 編輯推噓4(400)
留言4則, 1人參與, 最新討論串1/6 (看更多)
以下是一所國外研究所的考試題目,是否能用程式跟圖解來解答這個問題? I have a computer file containing 1,000,000 non-negative integers, in no particular order. Imagine that they are the membership numbers of people who are enrolled in my internet club. A new person wants to join the club, and we need to find an unused number to allocate to them. How would you find, in a reasonable time, a number that was not already in the file? -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 220.140.56.26

01/13 11:58, , 1F
全部加起來一定沒問題 XD
01/13 11:58, 1F

01/13 11:59, , 2F
如果只需要一次的話.
01/13 11:59, 2F

01/13 11:59, , 3F
不然長遠來看, 用些資料結構來放會比較賺
01/13 11:59, 3F

01/13 12:07, , 4F
喔, 為了避免 0 的問題, sum 完後再加1
01/13 12:07, 4F
yaote:轉錄至看板 C_and_CPP 01/13 18:59
文章代碼(AID): #15g4xxxo (Programming)
討論串 (同標題文章)
文章代碼(AID): #15g4xxxo (Programming)