title: Why is inserting in the middle of a linked list O(1)?
body: <p>According to the <a href="http://en.wikipedia.org/wiki/Linked_list#Linked_lists_vs._arrays" rel="noreferrer">Wikipedia article on linked lists</a>, inserting in the middle of a linked list is considered O(1).  I would think it would be O(n).  Wouldn't you need to locate the node which could be near the end of the list?  </p>
  
  <p>Does this analysis not account for the finding of the node operation (though it is required) and just the insertion itself?</p>
  
  <p><strong>EDIT</strong>: </p>
  
  <blockquote>
    <p>Linked lists have several advantages over arrays. Insertion of an element at a specific point of a list is a constant-time operation, whereas insertion in an array may require moving half of the elements, or more.</p>
  </blockquote>
  
  <p>The above statement is a little misleading to me.  Correct me if I'm wrong, but I think the conclusion should be:</p>
  
  <p><strong>Arrays:</strong> </p>
  
  <ul>
  <li>Finding the point of insertion/deletion O(1)</li>
  <li>Performing the insertion/deletion O(n)</li>
  </ul>
  
  <p><strong>Linked Lists:</strong></p>
  
  <ul>
  <li>Finding the point of insertion/deletion O(n)</li>
  <li>Performing the insertion/deletion O(1)</li>
  </ul>
  
  <p>I think the only time you wouldn't have to find the position is if you kept some sort of pointer to it (as with the head and the tail in some cases).  So we can't flatly say that linked lists always beat arrays for insert/delete options.</p>