Re: 演算法?
> ==> donggun (【U.K.】) 的文章中提到:
> 幫我解答一下這提吧 = =
> 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?
>
這題看來是沒有好的解
時間複雜度(2n),big O
while(!EOF){
ansArray[lineData]←1;
}
for(i←0;i<1,000,000;i++){
if(!ansArray[i]){
return i;
}
}
--
* Origin: 中山大學-美麗之島BBS * From: 59.120.191.181
Programming 近期熱門文章
PTT數位生活區 即時熱門文章