18.04.2013 Views

The.Algorithm.Design.Manual.Springer-Verlag.1998

The.Algorithm.Design.Manual.Springer-Verlag.1998

The.Algorithm.Design.Manual.Springer-Verlag.1998

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Lecture 7 - elementary data structures<br />

LIST-INSERT'(L, x)<br />

LIST-DELETE'(L, x)<br />

Listen To Part 7-13<br />

return x<br />

next[x] = next[nil[L]]<br />

prev[next[nil[L]]] = x<br />

next[nil[L]] = x<br />

prev[x] = NIL[L]<br />

next[prev[x]] next[x]<br />

next[prev[x]] = prev[x]<br />

Hash Tables<br />

Hash tables are a very practical way to maintain a dictionary. As with bucket sort, it assumes we know that the<br />

distribution of keys is fairly well-behaved.<br />

<strong>The</strong> idea is simply that looking an item up in an array is once you have its index. A hash function is a<br />

mathematical function which maps keys to integers.<br />

In bucket sort, our hash function mapped the key to a bucket based on the first letters of the key. ``Collisions'' were<br />

the set of keys mapped to the same bucket.<br />

file:///E|/LEC/LECTUR17/NODE7.HTM (9 of 13) [19/1/2003 1:34:42]

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!