[ACCEPTED]-What's the purpose in hashing information?-hash

Accepted answer
Score: 25

Hashing can be used for many purposes:

  1. It 29 can be used to compare large amounts of 28 data. You create the hashes for the data, store 27 the hashes and later if you want to compare 26 the data, you just compare the hashes.

  2. Hashes 25 can be used to index data. They can be used 24 in hash tables to point to the correct row. If 23 you want to quickly find a record, you calculate 22 the hash of the data and directly go to 21 the record where the corresponding hash 20 record is pointing to. (This assumes that 19 you have a sorted list of hashes that point 18 to the actual records)

  3. They can be used in 17 cryptographic applications like digital 16 signatures.

  4. Hashing can be used to generate 15 seemingly random strings.

Here are the applications 14 of hash functions that wikipedia lists:

  1. Finding duplicate records
  2. Finding similar records
  3. Finding similar substrings
  4. Geometric hashing

Now 13 regarding hash table, here are some points to note:

If 12 you are using a hash table, the hashes in 11 the table should be in a sorted manner. If 10 not, you will have to create an index on 9 the hash column. Some implementations store 8 the hash separately in a sorted manner and 7 point to the original record.

If somebody 6 is storing hashes in a semi-random order, it 5 must be either because of the above reasons 4 or because they just want to store the message 3 digest of the information for comparing, finding 2 duplicates etc. and not as an index to the 1 data.

Score: 12

alt text

One of the major uses of the hash tables 15 you created in class is when you need fast 14 O(1) lookup times. You'll have have two 13 components, keys and the values.

The hash function transforms 12 the key into a hash. That hash is a number, and 11 specifically, it is the index of the data 10 in the array.

So, when you need to look up 9 Agscala's reputation up in a hash table 8 and you have used your username as the key, it 7 takes almost no time to locate and find 6 the relevant value. It simply re-hashes 5 your username and viola, there is the index 4 of the data you were looking for. You didn't 3 have to iterate over the entire array looking 2 for that specific value.

For some reference 1 the Wikipedia page on Hash tables is pretty good.

Score: 1

There are a couple of typical reasons to 14 hash data. In the example you reference, you 13 would hash the data and use that as a key 12 to extract the actual value of the hashed 11 item. The hashed data is often referred 10 to as a key and it references a bucket where 9 the actual, non-hashed value can be found.

The 8 other typical reason is to create a signature 7 of the hashed value so that you can check 6 if the value has been changed by someone 5 else. Since it's usually rare, depending 4 on the algorithm used, to have two items 3 hash to the same value, you can rehash a 2 value and compare it to the saved hash value 1 to check if the item is still the same.

Score: 1

Hashing is a technique useful for fast key 3 lookup. It allows one to more efficiently 2 find a value rather than scanning a list 1 from beginning to end.

Score: 1

Have you ever used a dictionary or a set? They're 3 typically implemented in terms of a hashtable 2 because the value associated with a key 1 can be found quickly.

{
'WA': 'Washington',
'WV': 'West Virginia',
'WY': 'Wyoming'
}

More Related questions