Laboratory Walkthrough 8

# Laboratory Walkthrough 8 - Ex8 Hash Functions Data...

• CaptainStrawCrow5189
• 5

This preview shows page 1 - 3 out of 5 pages.

Ex8: Hash Functions & Data Structures Submission deadline - Thursday, 26.12.2013, 20:55 Objectives This purpose of this exercise is to practice the use and implementation of dynamic data structures - simulating hash functions and playing with linked lists. Exercise Description Part 1 - hash functions In this part you will run simulations of insertion of data to a hash table using different hash functions. Here is a description of the stages in the simulations (see simulations.py ): 1. Construct a list with N elements: We supply you with the function id_generator that generates a list of random string sequences. You are also expected to generate a random list of integers. 2. Insert the elements to a hash table one by one (see the function simulation and hash_table.py ). Define the hash table size (M). Try using a non-prime M and a prime M (using the next prime function). Do you see any difference? Use a user defined hash function (F) to determine the index of the hash table where an item is inserted. Repeat the simulation at least ten times to estimate the average case behavior of the hash function. 3. simulation returns a pair of values: A tuple with the following values: The expected maximum number of collisions in the hash table (the number of items that were mapped to the most loaded index). The expected average number of collisions in the hash table. The expected standard deviation of collisions in the hash table. The expected normalized variance of collisions in the hash table (when the total weight of the table load is 1, allows comparison between different simulations). The expected time in seconds it takes to insert the whole list of items to the hash table. We supply you with 10 different hash functions, some were learned in class, some were not (see hash_functions.py ). Some are very simple and naive, some are a bit more complicated. Your task is to run simulations with the simulation function code, with various hash functions and values of M, N. Try different sizes of N and different ratios between M and N (M>>N, M<<N, M=N), each with one of the eight hash functions.

Subscribe to view the full document.

To assist you with your simulations the simulations.py file can be executed with the following parameters: usage: simulations.py [-h] [--repeats REPEATS] [--minhashsize MINHASHSIZE] [--idlistsize IDLISTSIZE] [--toprime] [--function FUNCTION] [--sourcefile SOURCEFILE] [--csvoutput] -r: number of repeats -m: minimal hash table size (M) -n: list size (N) -p: if assigned M will be the smallest prime number that is bigger than the given M -f: number of hash function to use
• Spring '14
• Avraham

{[ snackBarMessage ]}

###### "Before using Course Hero my grade was at 78%. By the end of the semester my grade was at 90%. I could not have done it without all the class material I found."
— Christopher R., University of Rhode Island '15, Course Hero Intern

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern