dense[n] == sparse[i], just through random chance? Though what are the odds of that? I suppose it depends on the size of the integers being stored in the array positions. 1/[integer size] * 1/[integer size], at least. Which means it wouldn't happen often, granted. But when it does happen -- KAZAM! It'll erase your TiVo.dense[n] == sparse[i], just through random chance?"[use] language's hash tableYeah, well, my first code example did exactly that and they were not impressed. I gave an alternate solution using a sparse array (but not a dense one, too) and I think they were similarly unimpressed. They were serious bit twiddlers: they considered the initialization time of a 256 character array worth eliminating. A solution that ran in constant time and used uninitialized stack space would have impressed them.
« Older Nerve-tapping neckband used in 'telepathic' chat... | 20 Biggest Record Company Scre... Newer »
This thread has been archived and is closed to new comments
So generally, before a program uses memory, it should "initialize" that memory, setting it to some known value. Usually, that's not a problem.
But if the memory is going to be used to record values over time, the values to set will not be known at initialization time. If the amount of memory used to record those value is very large, it can be time-expensive to set all those values to, say, zero.
The article addresses a special case where not only is the memory area large, but also most of the values will never be set to something other than zero. An example might be to note which people out of 100,000 are left-handed red head Zoroastrian midget lion-tamers. (Or which Mefites find this article interesting?)
The article shows a clever way to avoid setting 100000 "NOT a left-handed red head Zoroastrian midget lion-tamer" flags, while still noting correctly the few people who are left-handed red head Zoroastrian midget lion-tamers.
posted by orthogonality at 8:11 PM on March 15, 2008