Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

write a c program for following question 4. Open addressing is a method for handling collisions in hashing. The three different methods for open addressing

write a c program for following question

image text in transcribed

4. Open addressing is a method for handling collisions in hashing. The three different methods for open addressing are linear probing, quadratic probing, and double hashing. A brief description of the three methods is given below: In linear probing, the function used to calculate the next location during collision is: h(k)= (h(k)+i)modm,i=1,2. In quadratic probing, the function used to calculate the next location during collision is: h(k)= (h(k)+i2)modm,i=1,2 In double hashing scheme, the primary hash function is, h1(k)=kmodN, where N is the table size. The secondary hash function is, h2(k)=R(keymodR) where R is the maximum prime number less than the table size. Double hashing can be done using: (h1( key )+ih2(key)) modN,i=0,1,2. Given a set of keys and the table size, write a program to print the locations at which the keys are stored using the above-mentioned three methods and also print the total number of collisions that occur during mapping for each of the three methods. Input format: - First line of the input contains an integer, the table size. - Second line contains space-separated(single space) integer numbers, the keys to be inserted. Output format: - First line of the output contains space-separated (single space) integers, the locations obtained using linear probing. - Second line contains an integer, the total number of collisions that occurred during linear probing. - Third line of the output contains space-separated (single space) integers, the locations obtained using quadratic probing. - Fourth line contains an integer, the total number of collisions that occurred during quadratic probing. - Fifth line of the output contains space-separated (single space) integers, the locations obtained using double hashing. - Sixth line contains an integer, the total number of collisions that occurred during double hashing

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 And Information Systems 1 International Baltic Conference Dbandis 2020 Tallinn Estonia June 19 2020 Proceedings

Authors: Tarmo Robal ,Hele-Mai Haav ,Jaan Penjam ,Raimundas Matulevicius

1st Edition

303057671X, 978-3030576714

More Books

Students also viewed these Databases questions

Question

Describe the preparatory steps for writing a formal report.

Answered: 1 week ago