# lab2 - COMPSCI 342-001 Data Structure and Algorithms(Fall...

This preview shows pages 1–2. Sign up to view the full content.

COMPSCI 342-001 Data Structure and Algorithms (Fall 2011) Lab Assignment #2, Due on 10/17/2011, Monday (11PM) Introduction: Suppose we are inserting n keys into a hash table of size m . Then the load factor α is defined to be n/m . For open addressing n m , which implies that 0 α 1. In this assignment we will study how the load factor affects the average number of probes required by open addressing while using linear probing and double hashing. Design: Set up the hash table to be an array of HashObject. A HashObject contains a generic object and a frequency count. The HashObject needs to implement Comparable inter- face, it should override the toString method and should also have a getKey method. Also we will use linear probing as well as double hashing. So design the HashTable class by passing in an indicator via constructor so that the appropriate kind of probing will be performed. Choose a value of the table size m to be a prime in the range [95500 . . . 96000]. A good value is to use a prime that is 2 away from another prime. That is, both m and m - 2 are primes. Vary the load factor α as 0.5, 0.6, 0.7, 0.8, 0.9, 0.95, 0.98, 0.99 by setting the value of n appropriately, that is, n = αm . Keep track of the average number of

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### 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