in reply to Why are hashes so much faster?
One particular algorithm that's much faster using hashes is doing a lookup to see if a particular item is in a list. If you use an (unsorted) array, you need to look through each item in the array to determine if you have the item in your list. So it's a O(n) algorithm, using an array. Using a hash, it's a O(1)--constant--algorithm. A hashing algorithm translates a string into an address; the hashing function should always give the same address when using the same string, so looking up a string in a hash is extremely fast and simple.
|
|---|