




Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
The concept of open addressing in hashing, probing strategies, uniform hashing, analysis, and cryptographic hashing. It explains the difference between open addressing and chaining, and the desirable properties of cryptographic hash functions. The document also provides examples of applications of cryptographic hash functions. a lecture note from a course on algorithms and data structures.
Typology: Slides
1 / 8
This page cannot be seen from the preview
Don't miss anything!





CLRS Chapter 11.4 (and 11.3.3 and 11.5 if interested)
Another approach to collisions:
item (^2)
item (^1) item (^3)
Figure 1: Open Addressing Table
h : U × { 0 , 1 ,... , m − 1 } → { 0 , 1 ,... , m − 1 }
universe of keys trial count slot in table
〈h(k, 0), h(k, 1),... , h(k, m − 1)〉
is a permutation of 0, 1 ,... , m − 1. i.e. if I keep trying h(k, i) for increasing i, I will eventually hit all slots of the table.
Ø 1
m -
Figure 2: Order of Probes
Insert(k,v) : Keep probing until an empty slot is found. Insert item into that slot.
for i in xrange(m): if T [h(k, i)] is None: ] empty slot T [h(k, i)] = (k, v) ] store item return raise ‘full’
Example: Insert k = 496 Search(k): As long as the slots you encounter by probing are occupied by keys = k, keep probing until you either encounter k or find an empty slot—return success or failure respectively.
for i in xrange(m): if T [h(k, i)] is None: ] empty slot? return None ] end of “chain” elif T [h(k, i)][∅] == k: ] matching key return T [h(k, i)] ] return item return None ˙ ] exhausted table
Ø 1
m -
cluster
if h ( k ,0) is any of these, the cluster will get bigger
Figure 4: Primary Clustering
h 1 (k) + i · h 2 (k) mod m = h 1 (k) + j · h 2 (k) mod m ⇒ m divides (i − j)
Each key is equally likely to have any one of the m! permutations as its probe sequence
Suppose we have used open addressing to insert n items into table of size m. Under 1 the uniform hashing assumption the next operation has expected cost of ≤ , 1 = n/m(< 1).
− α where α Example: α = 90% =⇒ 10 expected probes
Proof:
Suppose we want to insert an item with key k. Suppose that the item is not in the table.
⇒ Every trial, success with probability at least p. Expected Number of trials for success?
1 1 =. p 1 − α
With a little thought it follows that search, delete take time O(1/(1 − α)). Ditto if we attempt to insert an item that is already there.
Open Addressing: better cache performance (better memory usage, no pointers needed)
Chaining: less sensitive to hash functions (OA requires extra care to avoid clustering) and the load factor α (OA degrades past 70% or so and in any event cannot support values larger than 1)
A cryptographic hash function is a deterministic procedure that takes an arbitrary block of data and returns a fixed-size bit string, the (cryptographic) hash value, such that an accidental or intentional change to the data will change the hash value. The data to be encoded is often called the message, and the hash value is sometimes called the message digest or simply digest.
require is CR. We don’t want an adversary to ask Alice to sign x and then claim that she signed x′, where h(x) = h(x′).
There have been many proposals for hash functions which are OW, CR and TCR. Some of these have been broken. MD-5, for example, has been shown to not be CR. There is a competition underway to determine SHA-3, which would be a Secure Hash Algorithm certified by NIST. Cryptographic hash functions are significantly more complex than those used in hash tables. You can think of a cryptographic hash as running a regular hash function many, many times with pseudo-random permutations interspersed.
MIT OpenCourseWare http://ocw.mit.edu
6.00 6 Introduction to Algorithms Fall 2011
For information about citing these materials or our Terms of Use, visit: http://ocw.mit.edu/terms.