![donaldpartee1](/avatars/40167.jpg)
donaldpartee1
20.02.2020 •
Computers and Technology
A good hash function h(x) behaves in practice very close to the simple uniform hashing assumption analyzed in class, but is a deterministic function. Designing good hash functions is hard, and a bad hash function can cause a hash table to quickly exit the sparse loading regime by overloading some buckets and under-loading others. Good hash functions often rely on beautiful and complicated insights from number theory, and have deep connections to pseudorandom number generators and cryptographic functions. In practice, most hash functions are moderate to poor approximations of uniform hashing. Consider the following two hash functions. Let U be the universe of strings composed of the characters from the alphabet Σ = [A, . . . ,Z], and let the function f(xi) return the index of a letter xi ∈ Σ, e.g., f(A) = 1 and f(Z) = 26. Let x be a string of length m.
(1) The first hash function we consider is h1(x) = [Pm i=1 f(xi)] mod `, where ` is the number of buckets in the hash table.
(2) For the second hash function, first—globally, external to the hash function— choose uniformly random integers ai (one for each xi ∈ Σ) from {0, . . . ,10,000}, and then define h2(x) = [Pm i=1 ai · f(xi)] mod `. List your values of ai here: (and please use consistent values of ai throughout this question)
(a) There is a txt file on Canvas that contains US Census derived last names. Using these names as input strings, first choose a uniformly random 50% of these name strings. Let ` = 5851 be the number of buckets. For each of the two hash functions (separately), produce a histogram showing the distribution of hash locations for the names you chose. Label the axes of your figures. Give a brief description of what the figure shows about h1(x) and h2(x); justify your results in terms of the behavior of these hash functions. Hint: the raw file includes information other than the name strings, which will need to be removed; and, think about how you can count hash locations without building or using a real hash table.
(b) State at least 4 reasons why h1(x) is a bad hash function relative to the ideal behavior of uniform hashing
(c) Produce two plots—one for each hash function h1, h2—showing the length of the longest chain (were we to use chaining for resolving collisions) as a function of the number n of these strings that we hash into a table with ` = 5851 buckets. That is, you may use the 50% of names from part (a), and as you hash them one by one, show how the length of the longest chain is growing
(d) Produce another pair of plots—one for each of h1, h2—showing the number of collisions as a function of `. Comment on how collisions decrease as ` increases. Aside from size, do you notice any particular kinds of values for ` that seem better than others? (e.g. odd/even, prime, etc.) Discuss briefly.
Solved
Show answers
More tips
- F Food and Cooking How to Make Mayonnaise at Home? Secrets of Homemade Mayonnaise...
- C Computers and Internet Which Phone is Best for Internet Surfing?...
- F Food and Cooking Everything You Need to Know About Pasta...
- C Computers and Internet How to Choose a Monitor?...
- H Horoscopes, Magic, Divination Where Did Tarot Cards Come From?...
- S Style and Beauty How to Make Your Lips Fuller? Ideas and Tips for Beautiful Lips...
- C Computers and Internet How to Learn to Type Fast?...
- A Art and Culture Who Said The Less We Love a Woman, the More She Likes Us ?...
Answers on questions: Computers and Technology
- C Computers and Technology How does urgency play into security user interface? (choose one) security is important, use modal dialogs to ensure its not skipped let the person make the decision late (avoiding...
- C Computers and Technology a user reports that nothing happens when he or she attempts to print from the computer at his desk. this points to a possible problem with what? a) multitaskingb) disk accessc) device...
- C Computers and Technology Use the drop-down menus to match each description to the correct term.Has records and fields: Has columns and rows:Enables a user to interact with a database without working directly...
- C Computers and Technology n this assignment, you will implement two classes. Point: A Point in a two dimensional plane has an integer x coordinate value and an integer y coordinate value. Rectangle: A Rectangle...
- C Computers and Technology PLEASE HELP ILL MARK...
- M Mathematics What is the square root of 24 rounded to the nearest tenth?...
- H History Who was protected by maryland’s 1649 act of toleration?...
- B Biology How does the carbon atom complete its octet? a. it forms ionic bonds by sharing electrons. b. it forms covalent bonds by donating electrons. c. it forms covalent bonds by sharing electrons....
- M Mathematics The sum of two numbers is 30 the difference of the two numbers is 4 what is the lesser number?...
- B Biology Which of the following pairs with uracil in rna? adenine thymine guanine cytosine rna is single stranded and found mainly in the nucleus. true false which of the following is not true?...
Ответ:
While traditional faxing often uses unsecured phone lines, electronic faxes are encrypted using a secure and reliable system to protect your data. Electronic faxing is not susceptible to the time-wasting spam and malicious malware that can be common with other internet-based communication methods.
Explanation: