You are on page 1of 12

Analysis of algorithms

Dr. Hajira Jabeen


Hashing
• Hashing , a ubiquitous information retrieval strategy
for providing efficient access to information based on
a key
• Information can usually be accessed in constant time
Direct Address Table
Hash Function
Collision
Division Method
The Multiplication Method
• Two step process
• Step 1:Multiply the key k by a constant 0< A <1 and extract the fraction
part of kA.Step
• Step 2:Multiply kA by m and take the floor of the result.
• Advantage of this method is that the value of m is not critical and can be
implemented on most computers.
• A reasonable value of constant A is» (sqrt5 - 1) /2
Collisions
• This is possible that two key values hash into
the same table entry.
• This is termed as Collision.
• Two variants
– Universal Hashing
– Perfect Hashing

You might also like