SlideShare a Scribd company logo
Hash Table
• A hash table, or a hash map, is a data structure that associates
keys with values.
• The primary operation it supports efficiently is a lookup: given
a key (e.g. a person's name), find the corresponding value
(e.g. that person's telephone number).
• It works by transforming the key using a hash function into a
hash, a number that is used as an index in an array to locate
the desired location ("bucket") where the values should be.
• It’s possible that the hash function will return the same hash
for two different keys. If that happens there will be more
than one set of data in a given bucket.
Hash Table
• Unique hash values...
Hash Table
• Duplicate hash values...
Hash Table
• How storing a value works (basically)
– I have a key and value I want to store
key = “Kurtz”
value = “ajkurtz@iuk.edu”
– Compute the hash value
hash = function(key)
– Store the key and the value
bucket[hash].add(key, value)
Hash Table
• How retrieving a value works (basically)
– I have a key and I want to get the value
key = “Kurtz”
– Compute the hash value
hash = function(key)
– Get the value
bucket[hash].get(key)
• If there is only one key/value pair in the bucket, return them.
• If there is more than one key/value pair look at each key in the bucket to find
the one that matches our search key and return that pair.

More Related Content

PPTX
Power shell basics day 5
PPTX
Linked list - Data structure
PPTX
Hashing and separate chain
PPTX
How to Create an Array & types in PHP
PPTX
Array in c
PDF
Dotnet Programming concepts difference faqs-1
PDF
PHP Basic & Arrays
PDF
Overview of Indexing In Object Oriented Database
Power shell basics day 5
Linked list - Data structure
Hashing and separate chain
How to Create an Array & types in PHP
Array in c
Dotnet Programming concepts difference faqs-1
PHP Basic & Arrays
Overview of Indexing In Object Oriented Database

Similar to 5 data structures-hashtable (20)

PPTX
Hashing Introduction , hash functions and techniques
PPTX
hashing in data strutures advanced in languae java
PPTX
Data structures and algorithms lab11
PPT
DS Lecture - 6 (Hashing) introduction.ppt
PPTX
Hashing algorithms and its uses
PDF
Hash pre
PPT
11_hashtable-1.ppt. Data structure algorithm
PPTX
hashing in data structure for Btech .pptx
PPTX
hashing in data structure for engineering.pptx
PPTX
hashing in data structure for Btech.pptx
PPTX
Hashing
PPTX
Presentation.pptx
PPT
Java Collection slide ppt presentation..
PPTX
Hashing And Hashing Tables
PPTX
hashing in data structures and its applications
PPTX
Hashing and Collision Advanced data structure and algorithm
PPT
Hashing In Data Structure Download PPT i
PPT
18 hashing
PPTX
GRAPHS, BREADTH FIRST TRAVERSAL AND DEPTH FIRST TRAVERSAL
PPTX
Hashing
Hashing Introduction , hash functions and techniques
hashing in data strutures advanced in languae java
Data structures and algorithms lab11
DS Lecture - 6 (Hashing) introduction.ppt
Hashing algorithms and its uses
Hash pre
11_hashtable-1.ppt. Data structure algorithm
hashing in data structure for Btech .pptx
hashing in data structure for engineering.pptx
hashing in data structure for Btech.pptx
Hashing
Presentation.pptx
Java Collection slide ppt presentation..
Hashing And Hashing Tables
hashing in data structures and its applications
Hashing and Collision Advanced data structure and algorithm
Hashing In Data Structure Download PPT i
18 hashing
GRAPHS, BREADTH FIRST TRAVERSAL AND DEPTH FIRST TRAVERSAL
Hashing
Ad

More from irdginfo (20)

PPTX
Quicksort Presentation
PPTX
10 merge sort
PPTX
9 big o-notation
PPTX
8 elementary sorts-bubble
PPTX
8 elementary sorts-shell
PPTX
8 elementary sorts-insertion
PPTX
8 elementary sorts-selection
PPTX
7 searching injava-binary
PPTX
6 arrays injava
PPTX
5 data structures-tree
PPTX
5 data structures-stack
PPTX
5 data structures-arraysandlinkedlist
PPTX
4 character encoding-unicode
PPTX
4 character encoding-ascii
PPTX
4 character encoding
PPTX
3 number systems-floatingpoint
PPTX
2 number systems-scientificnotation
PPTX
1 number systems-hex
PPTX
1 number systems-unsignedsignedintegers
PPTX
1 number systems-octal
Quicksort Presentation
10 merge sort
9 big o-notation
8 elementary sorts-bubble
8 elementary sorts-shell
8 elementary sorts-insertion
8 elementary sorts-selection
7 searching injava-binary
6 arrays injava
5 data structures-tree
5 data structures-stack
5 data structures-arraysandlinkedlist
4 character encoding-unicode
4 character encoding-ascii
4 character encoding
3 number systems-floatingpoint
2 number systems-scientificnotation
1 number systems-hex
1 number systems-unsignedsignedintegers
1 number systems-octal
Ad

5 data structures-hashtable

  • 1. Hash Table • A hash table, or a hash map, is a data structure that associates keys with values. • The primary operation it supports efficiently is a lookup: given a key (e.g. a person's name), find the corresponding value (e.g. that person's telephone number). • It works by transforming the key using a hash function into a hash, a number that is used as an index in an array to locate the desired location ("bucket") where the values should be. • It’s possible that the hash function will return the same hash for two different keys. If that happens there will be more than one set of data in a given bucket.
  • 2. Hash Table • Unique hash values...
  • 3. Hash Table • Duplicate hash values...
  • 4. Hash Table • How storing a value works (basically) – I have a key and value I want to store key = “Kurtz” value = “ajkurtz@iuk.edu” – Compute the hash value hash = function(key) – Store the key and the value bucket[hash].add(key, value)
  • 5. Hash Table • How retrieving a value works (basically) – I have a key and I want to get the value key = “Kurtz” – Compute the hash value hash = function(key) – Get the value bucket[hash].get(key) • If there is only one key/value pair in the bucket, return them. • If there is more than one key/value pair look at each key in the bucket to find the one that matches our search key and return that pair.