## Are you sure?

This action might not be possible to undo. Are you sure you want to continue?

Concept of Hashing

a hash table, or a hash map, is a data structure that associates keys (names) with values (attributes).

.Example A small phone book as a hash table.

value) Each pair has a unique key.Dictionaries Collection of pairs. (key. .

Just An Idea Hash table : Collection of pairs. Lookup function (Hash function) .

A hash table is partitioned into many buckets. Each bucket has many slots. A hash function f(x) transforms the identifier (key) into an address in the hash table .Hashing Key-value pairs are stored in a fixed size table called a hash table. Each slot holds one record.

. . . . b-1 . . . . .Hash table s slots 0 0 1 1 s-1 . . b buckets . . . . .

Each position of this array is a bucket. . Every dictionary pair (key. A bucket can normally hold only one dictionary pair. b-1]. Uses a hash function f that converts each key k into an index in the range [0. element) is stored in its home bucket table[f[key]].Ideal Hashing Uses an array table[0:b-1].

f) Hash table is ht[0:7].(85.c).a).f) (22.e).c) (85.(3. b = 8 (where b is the number of positions in the hash table) Hash function f is key % b = key % 8 Where are the pairs stored? [0] [1] [2] [3] (3.e) (33.d) [4] [5] [6] [7] (72.(72.a) [0] [1] [2] [3] [4] [5] [6] [7] 9 .Ideal Hashing Example Pairs are: (22.(33.d).

d) (85.Collision (72.g) go? The home bucket for (25.f) (22.c) (3.What Can Go Wrong? .c) This situation is called collision Keys that have the same home bucket are called synonyms 25 and 33 are synonyms with respect to the hash function that is in use 10 .g) is already occupied by (33.a) [0] [1] [2] [3] [4] [5] [6] [7] Where does (25.e) (33.

e) (33.What Can Go Wrong? Overflow (72.a) [0] [1] [2] [3] [4] [5] [6] [7] A collision occurs when the home bucket for a new pair is occupied by a pair with different key An overflow occurs when there is no space in the home bucket for the new pair When a bucket can hold only one pair. collisions and overflows occur together Need a method to handle overflows 11 .c) (3.f) (22.d) (85.

To avoid collision (two different pairs are in the same the same bucket. Overflow: there is no space in the bucket for the new pair.) Size (number of buckets) of hash table.Some Issues Choice of hash function. Overflow handling method. .

.Choice of Hash Function Requirements easy to compute minimal number of collisions A good hashing function distributes the key values uniformly throughout the range.

Of Address = 100( 0 -99) Let m =97 H(3205) = 3205 mod 97 . The Hash function H is defined by H(k) = K(mod m) E. 7148.Some hash functions Division: Choose a number m(PRIME number) larger than the number n of keys in K. K=3205. 2345 & No.g.

20. +kr e.112.241...203.g. partition k into 123. then return the address H(k)=123+203+241+112+20=699 . x=12320324111220.Some hash functions Folding: Partition the key k into several parts. and add the parts together to obtain the hash address H(k) = k1+k2+ ..

Then the Hsh function H is defined byH(k) = l Where l is obtained by deleting digits from both ends of k2 e. E. 2345 .Some hash functions Mid Square: The key k is squared. k2 = 10 272 025 H(k) = 72 7148.g. K= 3205.g.

Overflow Handling An overflow occurs when the home bucket for a new pair (key. Rehashing Eliminate overflows by permitting each bucket to keep a list of all pairs for which it is the home bucket. Array linear list. Quadratic probing. Linear probing (linear open addressing). . Chain. element) is full. We may handle overflows by: Search the hash table in some systematic fashion for a bucket that is not full.

thus it attempts to resolve collisions using various methods. Linear Probing resolves collisions by placing the data into the next open slot in the table.Linear probing (linear open addressing) Open addressing ensures that all elements are stored directly into the hash table. .

29. 34. 11. 12. 28.Linear Probing – Get And Insert divisor = b (number of buckets) = 17. 33. 7. 23. 45 . 30. 0. 4 6 8 23 7 12 16 28 12 29 11 30 33 0 34 0 45 • Insert pairs whose keys are 6. Home bucket = key % 17.

hash_value. element ht[]){ int i.Linear Probing (program 8. i = hash_value = hash(item.key. while(strlen(ht[i].3) void linear_insert(element item. } } ht[i] = item. exit(1). “Duplicate entry\n”). if (i == hash_value) { fprintf(stderr. } i = (i+1)%TABLE_SIZE.key)) { if (!strcmp(ht[i].key). item. exit(1). } . “The table is full\n”).key)) { fprintf(stderr.

Problem of Linear Probing Identifiers tend to cluster together Increase the search time .

e.. h+ i2 .Quadratic Probing Quadratic probing uses a quadratic function of i as the increment (H(x)+i2)%b for H(K) = h For i = 0. h... h+4 .... h+1.1.... 2 -----i.

i) = (H1(k) + i H2(k) ) % m .Rehashing Rehashing: Try H1. H2. Here Hi is a hash function. Double hashing is one of the best methods for dealing with collisions. then a second hash function is calculated and combined with the first hash function. Hm in sequence if collision occurs. If the slot is full. …. H(k.

Data Structure for Chaining The idea of Chaining is to combine the linked list and hash table to solve the overflow problem. .

The chain may or may not be sorted by key 25 .Hashing with Chains Hash table can handle overflows using chaining Each bucket keeps a chain of all pairs for which it is the home bucket.

29.0.45 Home bucket = key % 17. 26 .34.7.11.23.30. 33. 28.Hash Table with Sorted Chains Put in pairs whose keys are 6.12.

- Chapter 08 Part iAnonymous f29iAz
- Digsilent Dpl TutorialAsimenia Korompili
- MC0067 Fall Drive Assignment 2011Nabarupam Deb
- Oracle Collections & RecordsVijayant Yadav
- Hash Tablesfofoa16
- C13.Hashingihtnasakirah918
- Collusion Avoidance in Fingerprinting Outsourced Relational Databases With Knowledge PreservationEditor IJRITCC
- Framework of Java Important Aimadinesh
- Trial9 Ora 7172 Inform View Comments.trcmohapatramanoj87
- CursorVasu Devan
- PLSQL Project Semester 2 Studentssmile
- arietta_cga11Lakshmi Bangalore
- Java Collection Detailspukhrajsharma
- 137.pdfSDIWC
- sqlpippone75
- hartigan_1979_kmeans.pdfHacen Spy
- COEN 3054 - Lab Exercise No. 2 - Arrays With FunctionsAbby Orioque II
- Quick Sort ExplanationTrishool Narayanasetty
- mesh2DFilterjenniferhsu
- A Quick and Dirty Real.docxRodrigo Espinoza Cors
- Additive outliers in INAR(1) models: identification and estimationimmsilvam
- ProSort Editorialssiteid123
- Tut2Q8SolAnonymous m4WbBJs9
- 10.1.1.21.4806tsst
- Implementationsapi-3792621
- AIChE 2013 Abstract1 May 08Rashedul Islam
- Efficient Similarity Search over Encrypted DataIRJET Journal
- Decision Tree Architecture 34jatinder1980
- Histogram reportPhạm Ngọc Hải
- Using A* algorithm to find shortest path in Indoor positioning systemIRJET Journal

- Hashing Algorithm: MD5International Journal for Scientific Research and Development
- UT Dallas Syllabus for opre7313.001.08f taught by Milind Dawande (milind)UT Dallas Provost's Technology Group
- Voice Recognition System using Template MatchingWhite Globe Publications (IJORCS)
- A Survey on Gesture RecognitionInternational Journal for Scientific Research and Development
- tmpDF60.tmpFrontiers
- As 2805.5.1-1992 Electronic Funds Transfer - Requirements for Interfaces Ciphers - Data Encipherment AlgorithSAI Global - APAC
- Clustering on Uncertain DataInternational Journal for Scientific Research and Development
- Analysis & Design Algorithm MCQ'SGuruKPO
- Cluster Analysis Techniques in Data Mining: A ReviewInternational Journal for Scientific Research and Development
- tmpCB3F.tmpFrontiers
- Appraisal of PSO Algorithm over Genetic Algorithm in WSN Using NS2International Journal for Scientific Research and Development
- Comparison of different Sub-Band Adaptive Noise Canceller with LMS and RLSInternational Journal for Scientific Research and Development
- Comparative Analysis of Optimization Algorithms Based on Hybrid Soft Computing AlgorithmInternational Journal for Scientific Research and Development
- The Optimizing Multiple Travelling Salesman Problem Using Genetic AlgorithmInternational Journal for Scientific Research and Development
- Simulation of Single and Multilayer of Artificial Neural Network using VerilogInternational Journal for Scientific Research and Development
- UT Dallas Syllabus for cs4349.501 06f taught by Ramaswamy Chandrasekaran (chandra)UT Dallas Provost's Technology Group
- Public Cloud Partition Using Load Status Evaluation and Cloud Division RulesInternational Journal for Scientific Research and Development
- Scheduling Resources In a Hetero-Gene Cloud Using Genetic AlgorithmInternational Journal for Scientific Research and Development
- Content-Based Image Retrieval Using Features Extracted From Block Truncation CodingInternational Journal for Scientific Research and Development
- UT Dallas Syllabus for cs2305.002 05f taught by Timothy Farage (tfarage)UT Dallas Provost's Technology Group
- tmp5056.tmpFrontiers
- UT Dallas Syllabus for se3345.502.07f taught by Ivor Page (ivor)UT Dallas Provost's Technology Group
- UT Dallas Syllabus for cs3345.501 05s taught by Greg Ozbirn (ozbirn)UT Dallas Provost's Technology Group
- Adoption of Parallel Genetic Algorithms for the Solution of System of EquationsWhite Globe Publications (IJORCS)
- Determining the shortest path for Travelling Salesman Problem using Nearest Neighbor AlgorithmInternational Journal for Scientific Research and Development
- UT Dallas Syllabus for cs6363.002.08s taught by Balaji Raghavachari (rbk)UT Dallas Provost's Technology Group
- UT Dallas Syllabus for cs3333.001.11s taught by Jeyakesavan Veerasamy (veerasam)UT Dallas Provost's Technology Group
- Introduction to Multi-Objective Clustering EnsembleInternational Journal for Scientific Research and Development
- tmpC0CF.tmpFrontiers
- tmp8BC6Frontiers

Sign up to vote on this title

UsefulNot usefulRead Free for 30 Days

Cancel anytime.

Close Dialog## Are you sure?

This action might not be possible to undo. Are you sure you want to continue?

Loading