{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

notes46

# notes46 - index.html Sho Kazahaya CS251 Notes...

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

// index.html // Sho Kazahaya // CS251 Notes - Feb12.14.16 (2007) /* If some parts of these notes don't make sense, ask your neighbor for a better copy. I have terrible handwriting, so I'm pretty sure that I've copied some sections incorrectly. Also, I forgot to mark in my notes where 2/16 ended and 2/19 began. I apologize if there's anything overlapping.*/ -------------------------------------------------- #~ February 12, 2007 ~# Hashing Wrap-Up HASHING We have seen so far that entries with the same key are stored in the same list. ___ |___| ----- ----- ----- |___+-|k1,d1|--|k2,d2|--|k3,d3|--| |___| ----- ----- ----- --- |___| - | | ~~~ fig.1 ( hash(k1) == hash(k2) == hash(k3) ) This is not the only way to handle collisions. Another way is to store the values in the hash array itself and use the hash number as the index of where the data has to be stored. _____ |k1,d1| |-----| |k3,d3| |-----| | | |-----| i |k2,d2| (i=k2) |-----| ~~~~~ fig.2 If a collision occurs:

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

View Full Document
- Use the next available entry (also called linear probing ) - Use a second hash function to the amount of entries that have to be skipped ( double hashing ) LINEAR PROBING // Start pseudo code insert (k,d){ if table is full return error index = hash(k) while(entry at index is used) index = (index+1)%N
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