{
  "id": 1586202,
  "title": "# The Part About Linked Lists Being O(1) That Confused Me",
  "url": "https://urgent.news/2026/08/17/the-part-about-linked-lists-being-o-1-that-confused-me",
  "topic": "tech",
  "section": "Tech",
  "published": "2026-08-17T22:46:01.000Z",
  "source": {
    "name": "Dev.to",
    "slug": "dev-to",
    "url": "https://dev.to/sylvia_uwa/-the-part-about-linked-lists-being-o1-that-confused-me-1d39"
  },
  "original_language": "en",
  "account": "The subject of linked lists and their O(1) insertion time has confused many, including the author of this account. The confusion stems from a single sentence: \"Insertion is O(1) because you only need to change the pointers.\" While this is true if you already have a reference to the node, the real confusion arises when trying to locate the node in the first place.\n\nImagine a simple list: A → B → C → D. If you have a direct reference to node C, inserting a new node X after it is indeed a constant time operation. You would simply adjust the pointers: C.next = X and X.next = D. This operation is O(1), meaning it takes the same amount of time regardless of the size of the list.\n\nHowever, if all you know is that there's a node containing the value C, you must first traverse the list to find it. In the worst-case scenario, you'd have to visit every node, which is an O(n) operation. This is the part that initially didn't click for the author.\n\nThe key distinction here is that finding the node is a separate operation from inserting a node. Linked lists do not inherently speed up finding things; they only make rearranging the structure cheap once you already have the node or reference. Therefore, when we say linked list insertion is O(1), there's often an unstated assumption: \"Given a reference to the node.\"\n\nThis simple phrase changes the entire picture. Many Big-O explanations may not be entirely wrong; they just fail to mention the context. It's easy to overlook the importance of having a reference to the node you want to insert. This realization highlights how a lot of Big-O explanations can be misleading if they don't specify the context in which the O(1) time complexity applies.",
  "summary": "I spent way too much time being confused by one sentence about linked lists: “Insertion is O(1) because you only need to change the pointers.” Okay… but how did I get to the node in the first place? 😂 If I have: A → B → C → D and I already have a reference to node C, then yes: C.next = X X.next = D That's O(1). But what if all I know is: “Find the node containing C and insert X after it.” Now I…",
  "key_points": [],
  "editors_take": null,
  "illustration": null,
  "coverage": {
    "outlets": 1,
    "also_reported_by": []
  },
  "ai_generated": true,
  "disclaimer": "Summaries, key points and the editor’s take are written by software from other outlets’ reporting and may contain errors — always check the linked original."
}