title: How do I search a hash table?
body: <p>I've just started learning about hash tables and I understand how to insert but not how to search. These are the algorithms I'll be basing this question off:</p>
  
  <p>Hashing the key</p>
  
  <pre><code>int Hash (int key) {
      return key % 10;  //table has a max size of 10
  }
  </code></pre>
  
  <p>Linear probing for collision resolution.</p>
  
  <p>Suppose I call insert twice with the keys 1, 11, and 21. This would return slot 1 for all 3 keys. After collision resolution the table would have the values 1, 11, and 21 at slots 1, 2, and 3. This is what I assume would happen with my understanding of inserting.</p>
  
  <p>After doing this, how would I get the slots 2 and 3 if I search for the keys 11 and 21? From what I've read searching a hash table should do literally the same thing as inserting except when you arrive at the desired slot, you return the value at that slot instead of inserting something into it.</p>
  
  <p>If I take this literally and apply the same algorithm, if I search for the key 11 I would arrive at slot 4 because it would start at slot 1 and keep probing forward until it finds an empty slot. It wouldn't stop at slot 2 even though it's what I want because it's not empty.</p>
  
  <p>I'm struggling with this even if I use separate chaining. All 3 keys would be stored at slot 1 but using the same algorithm to search would return slot 1, not which node in the linked list.</p>