title: Implementing a direct address table
body: <p>I was given as homework the <a href="https://en.wikipedia.org/wiki/Introduction_to_Algorithms" rel="nofollow noreferrer">Introduction to Algorithms</a> exercise <code>11.1-3</code> which goes as follows:</p>
  
  <blockquote>
    <p>Suggest how to implement a direct-access table in which the keys of stored elements do not need to be distinct and the elements can have satellite data. All three dictionary operations (Insert, Delete and Search) should run in O(1) time. Don't forget that Delete takes as an argument a pointer to an object to be deleted, not a key.</p>
  </blockquote>
  
  <p>Well, Insert is no problem, as it simply means creating a linked list at the appropriate place in the table (if it doesn't already exist) and adding the element to it. Search, which is given a key, can return any of the elements that match the key, so it simply means we need to return the head of the matching list in the table.</p>
  
  <p>My problem is with Delete operation. If I modify the object to add to it a pointer to its node in the linked list, then I can delete in <strong>O(1)</strong>, but I'm not sure I'm allowed to change the object. Is there a way for doing this without changing the given object?</p>