in reply to need for speed - how fast is a hash
Hash insertion and lookup operations are performed in O(1) time. By contrast, reading through your file once through is O(n) assuming you're not sub-looping within. What this means in layman terms is that it takes an amount of time proportional to the number of elements (or lines) in your file to read through it. But inserting into a hash, or doing a hash lookup takes an amount of time that remains practically constant regardless of how many elements the hash contains. Putting it another way, reading the file takes longer the bigger the file is. Inserting and looking up hash entries does not slow down from a practical standpoint as you add more and more elements.
Dave
|
|---|