TIP: Click on subject to list as thread! ANSI
echo: c_echo
to: Neil Heller
from: Pascal Schmidt
date: 2004-05-18 14:46:08
subject: A question

Hi Neil! :-)

 NH> It seems to me that the ideal would be some sort of a hash involving 
 NH> a second array, as long in bits as there are integer numbers. Each 
 NH> integer would set a bit.  If that bit had been previously set, bingo, 
 NH> a duplicate.
You know, for our good old 32 bit unsigned int, you'd need 4G bits, meaning
512 MB for the hash table alone. On a real system, this would seriously
trash the data cache in the CPU.

 NH> It seems to me as though the big-O for that function is 1.  Is that 
 NH> correct?
Lookup in the hash would be O(1) for one number, but you'd need to run
through all the numbers in your original array, so O(n). The most primitive
algorithm for this problem (compare each with each) would be O(n^2).

Ciao
Pascal

--- Msged/LNX 6.1.1
* Origin: Linux FAQ - http://www.tzi.de/~pharao90/faq/ (1:153/401.2)
SEEN-BY: 633/267 270
@PATH: 153/401 307 140/1 106/2000 633/267

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.