1 / 8

Lab 6

Lab 6. Hash Function. Signature function f ( x ) Uniqueness Brevity Efficiency Order-preservation String x  Digest f ( x ) Shorter. Hash Applications. Authentication Digital Signatures Efficient Storage Hash Table. Hash Table. Database structure Searchable by equality.

yasuo
Download Presentation

Lab 6

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. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Lab 6

  2. Hash Function • Signature function f(x) • Uniqueness • Brevity • Efficiency • Order-preservation • String x Digestf(x) • Shorter

  3. Hash Applications • Authentication • Digital Signatures • Efficient Storage • Hash Table

  4. Hash Table • Database structure • Searchable by equality. • Suppose you have a hash function h that produces |H|-bit hashes. • Make a size 2|H| array. • Add(x): data[h(x)] = x • Find(x): if data[h(x)] == x return x • Else return null.

  5. Hash Table • But… • |X| > |H| • h(a) = h(b) • Rare! • 1000 random strings • Only 1 or 2 are likely to be someone’s name. • Maybe you actually store these in a linked list • Add(x): data[h(x)].add(x) • Find(x): if data[h(x)].contains(x) return x • Else return null.

  6. Key/Value Pair • Don’t actually store x… • void Add(key,value): data[h(key)].add(value) • value Find(key): if data[h(key)].contains(key) • return data[h(key)].find(key) • else return null

  7. Hash Function • “Division method” • h(x) = x mod m • “Multiplication method” • h(x) = m(xA mod l)

  8. Trie • Method of storing data in a tree based on its hash value. • Path from the root to leaf x is some prefix of h(x) • (Left = 0, Right = 1)

More Related