Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In this part, you will implement a hash table containing integers. The hash table has 10,000 buckets. An important part of a hash table is

image text in transcribedIn this part, you will implement a hash table containing integers. The hash table has 10,000 buckets. An important part of a hash table is collision resolution. In this assignment, we want you to use chaining with a linked list to handle a collision. This means that if there is a collision at a particular bucket then you will maintain a linked list of all values stored at that bucket. For more information about chaining

PLEASE USE C. Thanks

Third: Hash table (20 points) In this part, you will implement a hash table containing integers. The hash table has 10,000 buckets. An important part of a hash table is collision resolution. In this assignment, we want you to use chaining with a linked list to handle a collision. This means that if there is a collision at a particular bucket then you will maintain a linked list of all values stored at that bucket. For more information about chaining, see http://research.cs.vt.edu/AVresearch/hashing/openhash.php. A hash table can be implemented in many ways in C. You must find a simple way to implement a hash table structure where you have easy access to the buckets through the hash function. As a reminder, a hash table is a structure that has a number of buckets for elements to "hash" into. You will determine where the element falls in the table using the hash function You must not do a linear search of the 10,000 element array. We will not award any credit for O(n) time implementation of searches or insertions in the common case. For this problem, you have to use following hash function: key modulo the number of buckets. Input format: Th contains successive lines of input. Each line contains a character, either or 's', followed by a tab and then an integer. For each line that starts with i, your program should insert that number in the hash table if it is not present. If the line starts with a , your progran should search the hash table for that value is program takes a file name as argument from the command line. The file Output format: Your program my print two counts1) the number of insertions where collision occurred, and (2) the number of successful searches. In the first line your program should print the number of collisions, .e. during insertion if the bucket already had some data (may not be the same value) then you need to count that as one collision. In the next line, your program should print the number of searches where the value was present in the hash table. You can assume that the program inputs will have proper structure Example Execution: Lets assume we have a text file with the following contents: file2.txt: i 10 i 12 s 10 i 10010 s 10010 The the results will be: $./third file2.txt 2

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases Organizing Information Digital And Information Literacy

Authors: Greg Roza

1st Edition

1448805929, 978-1448805921

More Books

Students also viewed these Databases questions

Question

=+nk so that p( B(k)) Answered: 1 week ago

Answered: 1 week ago

Question

Ensure continued excellence in people management.

Answered: 1 week ago

Question

Enhance the international team by recruiting the best people.

Answered: 1 week ago