Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

( a ) [ 5 pts ] How do we go about picking a good hash function and hash structure? Provide some general guidelines about

(a)[5 pts] How do we go about picking a good hash function and hash structure? Provide some general guidelines about what a hash designer needs to think about.
(b)15 pts] What is the worst case runtime of insertion into a hash table using chaining (linked list)? Please explain.
(c)(5 pts] What is the worst case runtime of (successful) insertion into a hash table using linear probing (a form of open addressing)? Please explain
(d)(5 pts] There are two hash functions that take in strings as input shown below. Each returns an integer in between 0 and 1,000,002.(Note: 1,000,003 is a prime number.) Which of these two is a better hash function?
Explain the weakness in the other function.
int f1(char* str){
int i =0, res =0;
while (str [i]!=
\O ) s
res =(256* res +(int)(str [i]))%1000003;
i+;
}
return res:
}
int f2(char* str){
int i =0, res =0;
while (str [i]!=
) S
res =(res +(int)(str (i]))%1000003;
4+:
}
return res;

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_2

Step: 3

blur-text-image_3

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

Essentials of Database Management

Authors: Jeffrey A. Hoffer, Heikki Topi, Ramesh Venkataraman

1st edition

133405680, 9780133547702 , 978-0133405682

More Books

Students also viewed these Databases questions