Question
Data Structures Hash tables allow multiple values to be stored using a single variable name. A value can be accessed by its name instead of
Data Structures
Hash tables allow multiple values to be stored using a single variable name. A value can be accessed by its name instead of by its position in the array. Hash Tables are very useful when we want to look up items from a list.
The problem of a hash table creation is examined. The 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.
The program (IN PERL) must work with menu (i:insert, r: remove , d: display the hash table , q: for quit). The user must insert the words after having picking up the i (insert).
A hash function converts keys into array indices. The hash function can calculate the number of the basket. Find first, the total of ASCI values of all the letters and second finds the remainder using the number of buckets (find the module). Create a hash table for a number of baskets. The number of buckets (or the M array indices) is equal to ten.
The second component of a hashing algorithm is collision resolution: a strategy for handling the case when two or more keys to be inserted hash to the same index. A straightforward approach to collision resolution is to build, for each of the M array indices, a list of the key-value pairs whose keys hash to that index.
To enable efficient search through a two-step process is performed: hash to find the list that could contain the key, then sequentially search through that list for the key.
After the end of the insert, you have to display the data for each basket. Finally you test the remove operation. The hash with chaining technique is needed.
For the implementation it is preferable to use package with subroutines for the operations.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started