Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

You need to wite two hatsh functions (bath retuming integers). - h1(k)=kmodm - h22(k)=mfrack(kA),A=( sqrt(s) -1)/2 frac(kA)=(kAint(kA)) Aso define a rehash function as below: rehash

image text in transcribed
You need to wite two hatsh functions (bath retuming integers). - h1(k)=kmodm - h22(k)=mfrack(kA),A=( sqrt(s) -1)/2 frac(kA)=(kAint(kA)) Aso define a rehash function as below: rehash (int h, int k, int If return (h+jgk,j))modm The g function is defined as: Bint k, int in if option =1, return 1 else if option =2, return c1+c2Bj else if option =3, return (p(k anod p)},p is an user input Program should create a hash table as explained in the class. Declare as global variables: - m (size of Hash Table) - option (will allow you to choose one of the three collision resohing technique). - hash_method (1 for using division method and 2 for multiplication method) - p (int) - c1,c2 (int) In main, dedare n (integer) and alpha fas float), alpha =n/m Both n and alpha are user inputs Also, option and hash_method are user inputs. Get inputs for C1,C2 and p Compute m=(n/ alpha ) Check is m is a prime number, call isprime function If not, If not a prime, call GetPrime to get the value of next higher prime value. if \{lsPrime(m)\} display m,m is a prime no. else m= GetPrime(m); display m Create an array dynamically for hashTable with size m initialize all the values of this array to 0 (assuming no key will be 0 )

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

Database Concepts

Authors: David Kroenke

4th Edition

0136086535, 9780136086536

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