<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: sylvia uwa</title>
    <description>The latest articles on DEV Community by sylvia uwa (@sylvia_uwa).</description>
    <link>https://dev.to/sylvia_uwa</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F2206214%2F259b2027-4ff4-41dc-afe2-caf6f2ae6b07.jpg</url>
      <title>DEV Community: sylvia uwa</title>
      <link>https://dev.to/sylvia_uwa</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/sylvia_uwa"/>
    <language>en</language>
    <item>
      <title># The Part About Linked Lists Being O(1) That Confused Me</title>
      <dc:creator>sylvia uwa</dc:creator>
      <pubDate>Mon, 17 Aug 2026 22:46:01 +0000</pubDate>
      <link>https://dev.to/sylvia_uwa/-the-part-about-linked-lists-being-o1-that-confused-me-1d39</link>
      <guid>https://dev.to/sylvia_uwa/-the-part-about-linked-lists-being-o1-that-confused-me-1d39</guid>
      <description>&lt;p&gt;I spent way too much time being confused by one sentence about linked lists:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;“Insertion is O(1) because you only need to change the pointers.”&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Okay… but &lt;em&gt;how did I get to the node in the first place?&lt;/em&gt; 😂&lt;/p&gt;

&lt;p&gt;If I have:&lt;/p&gt;

&lt;p&gt;A → B → C → D&lt;/p&gt;

&lt;p&gt;and I already have a reference to node C, then yes:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;C.next = X
X.next = D
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That's O(1).&lt;/p&gt;

&lt;p&gt;But what if all I know is:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;“Find the node containing C and insert X after it.”&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Now I have to traverse the list to find C.&lt;/p&gt;

&lt;p&gt;That's O(n).&lt;/p&gt;

&lt;p&gt;And this was the part that wasn't clicking for me.&lt;/p&gt;

&lt;p&gt;I realized the important distinction is:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Finding the node ≠ inserting the node.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Linked lists don't magically make finding things faster.&lt;/p&gt;

&lt;p&gt;They make &lt;strong&gt;rearranging the structure cheap once you already have the node/reference.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;So when we say linked list insertion is O(1), there's often a hidden assumption:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;“Given a reference to the node…”&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;And honestly, that little phrase changes everything.&lt;/p&gt;

&lt;p&gt;I'm starting to realize that a lot of Big-O explanations aren't necessarily wrong they just leave out the context of &lt;em&gt;what you already have&lt;/em&gt;.😅&lt;/p&gt;

</description>
      <category>algorithms</category>
      <category>computerscience</category>
      <category>datastructures</category>
      <category>programming</category>
    </item>
  </channel>
</rss>
