This document discusses hash tables and hashing algorithms. It describes how hash tables use a hashing function to map keys to indexes in an array, which allows for fast search, insertion and retrieval of data. There are several techniques discussed for handling collisions when two keys hash to the same index, including separate chaining, linear probing and double hashing. The basic operations of a hash table are searching, inserting and deleting elements.
2. • Description: The main aim of this project is to implement a hashing algorithm to create a list
• of inventory parts and their quantities sold. There are three modules in this project
• Construction of hash table: HASH tables are widely used to quickly search and
• retrieve information from enormous amounts of data. In this for spare part code its
• code is taken and generates hash code and spare part record to search retrieve.
• Search for an inventory item: In this the user has enter spare part code, it generates
• respective hash code to access respective spare part record and prints that record
• indicates its quantity sold
• Reports: In this module it has to generate a complete report of spare parts and their
• quantity sold.
• Requirements: To implement this project student should have knowledge on
• Indexing
• Hash tables
• Hashing functions
3. • Description: The main aim of this project is to implement a hashing algorithm to create a list of
• inventory parts and their quantities sold. There are three modules in this project
• Construction of hash table: HASH tables are widely used to quickly search and retrieve
• information from enormous amounts of data. In this for spare part code its code is taken and
• generates hash code and spare part record to search retrieve.
• Search for an inventory item: In this the user has enter spare part code, it generates
• hash codrespectivee to access respective spare part record and prints that record indicates its quantity sold
• Reports: In this module it has to generate a complete report of spare parts and their quantity
• sold.
• Requirements: To implement this project student should have knowledge on
• Indexing
• Hash tables
• Hashing functions
4. • Hashing: hashing is generating a value or values from a string of text using a
mathematical function.
• Hashing is one way to enable security during the process of message transmission
when the message is intended for a particular recipient only. A formula generates
the hash, which helps to protect the security of the transmission against
• Hashing is also a method of sorting key values in a database table in an efficient
manner.
5. • Separate Chaining:
The idea is to make each cell of hash table point to a linked list of records that
same hash function value.
6. • Linear probing is a scheme in computer programming for
resolving collisions in hash tables, data structures for maintaining a collection
of key–value pairsand looking up the value associated with a given key
7. • Quadratic probing is an open addressing scheme in computer programming for
resolving collisions in hash tables—when an incoming data's hash value indicates it
should be stored in an already-occupied slot or bucket.
8. • Double hashing is a computer programming technique used in hash tables to
resolve hash collisions, in cases when two different values to be searched for
produce the same hashkey. It is a popular collision-resolution technique in open-
addressed hash tables. Double hashing is implemented in many popular libraries.
9. • Hash Table is a data structure which stores data in an associative manner. In a hash table, data is stored
in an array format, where each data value has its own unique index value. Access of data becomes very
fast if we know the index of the desired data.
• Thus, it becomes a data structure in which insertion and search operations are very fast irrespective of
the size of the data. Hash Table uses an array as a storage medium and uses hash technique to
generate an index where an element is to be inserted or is to be located from.
• HASHING:
• Hashing is a technique to convert a range of key values into a range of indexes of an array. We're going
to use modulo operator to get a range of key values.
• Consider an example of hash table of size 20, and the following items are to be stored. Item are in the
(key,value) format.
10. • Basic Operations
• Following are the basic primary operations of a hash table.
• Search − Searches an element in a hash table.
• Insert − inserts an element in a hash table.
• delete − Deletes an element from a hash table.
• Search Operation
• Whenever an element is to be searched, compute the hash code of the key passed
and locate the element using that hash code as index in the array. Use linear
probing to get the element ahead if the element is not found at the computed hash
code.
• Insersion operation
• Whenever an element is to be inserted, compute the hash code of the key passed
and locate the index using that hash code as an index in the array. Use linear
probing for empty location, if an element is found at the computed hash code.
11. • Delete Operation
• Whenever an element is to be deleted, compute the hash code of the key passed
and locate the index using that hash code as an index in the array. Use linear
probing to get the element ahead if an element is not found at the computed hash
code. When found, store a dummy item there to keep the performance of the hash
table intact.
• Colission : Since a hash function gets us a small number for a key which is a big
integer or string, there is possibility that two keys result in same value. The situation
where a newly inserted key maps to an already occupied slot in hash table is
called collision and must be handled using some collision handling technique.
12. • Advantages:
1) Simple to implement.
2) Hash table never fills up, we can always add more elements to chain.
3) Less sensitive to the hash function or load factors.
4) It is mostly used when it is unknown how many and how frequently keys may be inserted
or deleted.
• Disadvantages:
1) Cache performance of chaining is not good as keys are stored using linked list. Open
addressing provides better cache performance as everything is stored in same table.
2) Wastage of Space (Some Parts of hash table are never used)
3) If the chain becomes long, then search time can become O(n) in worst case.
4) Uses extra space for links.