Data Str & Algorithm HW Solutions 63

Data Str & Algorithm HW Solutions 63 - be treated...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
63 // Insert e into hash table HT template <class Key, class Elem, class KEComp, class EEComp> bool hashdict<Key, Elem, KEComp, EEComp>:: int home; // Home position for e int pos = home = h(getkey(e)); // Init probe sequence !(EEComp::eq(TOMBSTONE, HT[pos]))); i++) { pos = (home + p(getkey(e),i)) % M; // Follow probes if (EEComp::eq(e, HT[pos])) return false; // Dup } HT[pos] = e; // Insert e return true; } The search function need not be changed at all, since tombstone slots should
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: be treated as though they are full. 9.18 This “random” probe sequence yields identical results to using linear probing with a constant skip factor of 2. In other words, if an element has its home slot at position 2, it will follow the same probe sequence as an element whose home slot is at position 0 and probed one time to slot 2. Thus, we must be careful that the random permutation does not have properties of regular behavior as shown by this series....
View Full Document

This note was uploaded on 12/27/2011 for the course MAP 2302 taught by Professor Bell,d during the Fall '08 term at UNF.

Ask a homework question - tutors are online