Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Exereise: Your task is to write a program that creates a hash table of various sizes and various numbers of keys and collect statistics on

image text in transcribed

Exereise: Your task is to write a program that creates a hash table of various sizes and various numbers of keys and collect statistics on the load factor, number of collisions and the longest list length. Follow these steps. 1. Get the user to enter the table size. 2. Declare an arraylist of linked lists of that size. Assume that the linked list store integer objects. 3. Get the user to enter the number of keys to be hashed. Generate that many random keys in the range 1 to 10000. You don't need to check for duplicate keys. 4. For each key generated, determine where it should be mapped (pos-key%table_size). 5. Go to the arraylist index pos and add the key into the linked list in that position. 6. After all the keys have been added, enumerate all the linked lists, find the number of collisions and the longest list length. 7. Run the program a number of times, experimenting with different number of keys (10, 20, 30, 40, ..., 100) Keep the table size as 10. Create a table showing your experimental values: Table size 10 10 10 etc Number of kevs Load factor Number of collisions est list length 20 30 A sample run of the program will be as follows: Enter the size of the hash table: 10 Enter the number of keys to be hashed: 20 Hash Table created: -->8180-->6490 >empty >3802-->3272 >9563-->9493 >324-->3004-->3714 >2375-->635-->2595--4655-->2045 --> 876 >497-->3427 -->2258 --> 5293419 Statistics: Table size: 10 Number of keys: 20 Load factor: 2 Number of collisions: 11 Longest list: 5

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

Practical Database Programming With Visual C# .NET

Authors: Ying Bai

1st Edition

0470467274, 978-0470467275

More Books

Students also viewed these Databases questions

Question

How do Data Types perform data validation?

Answered: 1 week ago

Question

How does Referential Integrity work?

Answered: 1 week ago