hashing
Download
Skip this Video
Download Presentation
Hashing

Loading in 2 Seconds...

play fullscreen
1 / 6

Hashing - PowerPoint PPT Presentation


  • 535 Views
  • Uploaded on

Hashing. What is hashing. Simply, generating a numeric key using an algorithm (hash function) Definition: A function that maps keys to integers, usually to get an even distribution on a smaller set of values. The very simplest hash function is to use the modulus operator \%

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'Hashing' - merton


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
what is hashing
What is hashing
  • Simply, generating a numeric key using an algorithm (hash function)
  • Definition: A function that maps keys to integers, usually to get an even distribution on a smaller set of values.
  • The very simplest hash function is to use the modulus operator %
  • Input range % key range
input and key range
Input and key range
  • Example. We want to store 7 digit telephone numbers so that they can be quickly retrieved.
    • Number of expected entries = 100
    • Range of telephone numbers = 0 – 9999999

Simple hashing algorithm

hash = inputNumber % 100

What’s the effect?

applications of hashing
Applications of hashing
  • File management – working out where to store records
  • Comparing complex values
  • Cryptography – creating digital signatures – eg: md5
collisions
Collisions
  • Where the hash value returned for two keys is the same.
  • What to do?
    • Open hashing
    • Closed hashing
    • Deleting
  • The 2/3rds rule
djb hash function
DJB Hash function
  • “An algorithm produced by Professor Daniel J. Bernstein and shown first to the world on the usenet newsgroup comp.lang.c. It is one of the most efficient hash functions ever published. “

def DJBHash(key):

hash = 5381

for i in range(len(key)):

hash = ((hash << 5) + hash) + ord(key[i])

returnhash

ad