lec12 - Click to edit Master subtitle style 2/7/11 Sundar...

Info iconThis preview shows pages 1–6. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Click to edit Master subtitle style 2/7/11 Sundar B. CS C341 / I S C361 Data Structures & Algorithms Dictionary Data Structures - Hashing Open Addressing- Analysis- Probing- Unsuccessful Find- Successful Find Bloom Filters 11 2/7/11 Sundar B. 2/7/11 Sundar B. Terminology The technique of chaining elements that hash into the same slots if referred to by different names: Separate Chaining for obvious reasons Open Hashing because number of elements is not limited by table size Closed Address Hashing because the location of the bucket (i.e. the address) of an element is fixed 2/7/11 22 Sundar B. 2/7/11 Sundar B. Open Addressing (a.k.a. closed hashing) Fixed Space Table size m and each element can contain only one element Addressing by Hashing Probing (for a vacant location) in case of collision add(Element e, Hashtable T) // Generic procedure // e.key is key; h is hash function a = h(k); if T[a] is empty then T[a]=e 2/7/11 33 Sundar B. 2/7/11 Sundar B. Open Addressing Probing Schemes // m denotes table size; typically m is chosen to be prime Linear Probing: getNextAddr(a,k) { static int j=0; return (a+j) mod m; } Quadratic Probing getNextAddr(a,k) { static int j=0; j++; return (a+j 2 ) mod m; } Exponential Probing getNextAddr(a,k) { static int j=0; j++; return (a+2 j ) mod m; } 2/7/11 44 Sundar B. 2/7/11 Sundar B. Open Addressing Implementation Caveat: add as defined may not terminate! Must check whether all m locations have been probed Alternatively, may use a count of non-empty locations. Define find. Similar to add: hash and then probe until element found or empty slot....
View Full Document

This note was uploaded on 02/07/2011 for the course CS 123 taught by Professor Murali during the Spring '11 term at Birla Institute of Technology & Science, Pilani - Hyderabad.

Page1 / 19

lec12 - Click to edit Master subtitle style 2/7/11 Sundar...

This preview shows document pages 1 - 6. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online