₦airaland Forum

Welcome, Guest: RegisterLoginWith GoogleTrendingRecentNew

Stats: 3,330,531 members, 8,445,899 topics. Date: Wednesday, 15 July 2026 at 06:00 PM

Toggle theme

Another Programming Challenge - Programming (2) - Nairaland

Nairaland ForumScience/TechnologyProgrammingAnother Programming Challenge (2359 Views)

1 2 Reply (Go Down)

Re: Another Programming Challenge by mkwayisi: 5:32pm On Sep 29, 2012
@lordZouga: Once will never be enough unless you're coming up with a breakthrough algorithm. Let me ask, have you tried implementing what you're thinking? If not try it!
Re: Another Programming Challenge by ektbear(op): 7:30pm On Sep 29, 2012
[quote author=₱®ÌИСΞ]Hahaha lol...thnx for dat...I imagined the possibility of dat occuring in a HUGE file was near impossible so I guess my mind didn't go there...lemme fix it[/quote]Indeed, if N is big, and K relatively small, then this is pretty unlikely to happen. This was the subtle issue I alluded to in my first post. But it is pretty easy to fix (just reject a random number it is already in your list).
Re: Another Programming Challenge by ektbear(op): 7:31pm On Sep 29, 2012
lordZOUGA: it will take O(N)... This would be nice but your algorithm suggested doing it twice when in my opinion, once would be enough.
Yea most languages has internal buffer... C++ has the internal buffer object stream_buf that is created for every I/O operation
If you don't know N, I think that it is impossible to do it in one pass.

You have to know N to generate the K random row #s correctly. And the only way to know N is to pass through the file once.
Re: Another Programming Challenge by uzoexcel(m): 5:22pm On Jul 18, 2014
OFDM? grin grin grin
1 2 Reply

Programming Challenge For Beginners Competition Two N20000 -SEASON 2-Programming Challenge For Beginners N20000Facebook Programming Challenge Question234

Opera Single Column View Overwriting Site ResponsivenessBest School Management SoftwareWhere Can I Download Website Templates?