<?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: Amar Gul</title>
    <description>The latest articles on DEV Community by Amar Gul (@amargul).</description>
    <link>https://dev.to/amargul</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.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3922263%2F2747df38-001d-4983-848f-164fd2ef7749.jpg</url>
      <title>DEV Community: Amar Gul</title>
      <link>https://dev.to/amargul</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/amargul"/>
    <language>en</language>
    <item>
      <title>Linked Lists Finally Simple — Why Insert is O(1) When Arrays Are O(n)Uses This Algorithm for .sort()</title>
      <dc:creator>Amar Gul</dc:creator>
      <pubDate>Sat, 23 May 2026 20:44:08 +0000</pubDate>
      <link>https://dev.to/amargul/linked-lists-finally-simple-why-insert-is-o1-when-arrays-are-onuses-this-algorithm-for-46l2</link>
      <guid>https://dev.to/amargul/linked-lists-finally-simple-why-insert-is-o1-when-arrays-are-onuses-this-algorithm-for-46l2</guid>
      <description>&lt;p&gt;Most developers understand arrays intuitively.&lt;br&gt;
But Linked Lists feel abstract until you &lt;br&gt;
see them visually.&lt;/p&gt;
&lt;h2&gt;
  
  
  The Core Problem with Arrays
&lt;/h2&gt;

&lt;p&gt;When you insert in the middle of an array,&lt;br&gt;
every element after the insertion point &lt;br&gt;
must shift one position right.&lt;/p&gt;

&lt;p&gt;With 1000 elements that means 999 shifts.&lt;br&gt;
That's O(n) time.&lt;/p&gt;
&lt;h2&gt;
  
  
  How Linked Lists Solve This
&lt;/h2&gt;

&lt;p&gt;A Linked List node contains two things:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The actual data value&lt;/li&gt;
&lt;li&gt;A pointer to the next node&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Insertion only updates 2 pointers:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;\&lt;/code&gt;`javascript&lt;br&gt;
// Point previous node to new node&lt;br&gt;
prevNode.next = newNode;&lt;/p&gt;

&lt;p&gt;// Point new node to next node&lt;br&gt;&lt;br&gt;
newNode.next = nextNode;&lt;br&gt;
`&lt;code&gt;\&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;That's it. O(1) time regardless of &lt;br&gt;
list size.&lt;/p&gt;
&lt;h2&gt;
  
  
  The Trade Off
&lt;/h2&gt;

&lt;p&gt;Fast insertion. Slow access.&lt;/p&gt;

&lt;p&gt;Arrays: O(1) access by index&lt;br&gt;
Linked Lists: O(n) access — must traverse&lt;/p&gt;

&lt;p&gt;Choose based on your use case:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Frequent insertion/deletion → Linked List&lt;/li&gt;
&lt;li&gt;Frequent access by index → Array&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  Built in React
&lt;/h2&gt;

&lt;p&gt;Three operations animated:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Traverse — walks HEAD to TAIL&lt;/li&gt;
&lt;li&gt;Insert — shows 2 pointer updates&lt;/li&gt;
&lt;li&gt;Delete — shows pointer reconnection&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;\&lt;/code&gt;`javascript&lt;br&gt;
async function insertMiddle() {&lt;br&gt;
  const insertPos = Math.floor(nodes.length / 2);&lt;/p&gt;

&lt;p&gt;// Traverse to position&lt;br&gt;
  for (let i = 0; i &amp;lt;= insertPos; i++) {&lt;br&gt;
    setTraversing(i);&lt;br&gt;
    await addDelay(SPEED);&lt;br&gt;
  }&lt;/p&gt;

&lt;p&gt;// Insert new node&lt;br&gt;
  setNodes(prev =&amp;gt; {&lt;br&gt;
    const updated = [...prev];&lt;br&gt;
    updated.splice(insertPos, 0, newNode);&lt;br&gt;
    return updated;&lt;br&gt;
  });&lt;br&gt;
}&lt;br&gt;
`&lt;code&gt;\&lt;/code&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Watch It
&lt;/h2&gt;

&lt;p&gt;  &lt;iframe src="https://www.youtube.com/embed/PGiqJTCUORo"&gt;
  &lt;/iframe&gt;
&lt;/p&gt;

&lt;h2&gt;
  
  
  What's Next
&lt;/h2&gt;

&lt;p&gt;Binary Search Tree — self organizing &lt;br&gt;
structure that achieves O(log n) for &lt;br&gt;
search, insert and delete simultaneously.&lt;/p&gt;

&lt;p&gt;Subscribe to AlgoCanvas:&lt;br&gt;
👉 youtube.com/@AlgoCanvas&lt;/p&gt;

</description>
      <category>react</category>
      <category>javascript</category>
      <category>algorithms</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Quick Sort — Why Your Programming Language Uses This Algorithm for .sort()</title>
      <dc:creator>Amar Gul</dc:creator>
      <pubDate>Sat, 23 May 2026 20:42:45 +0000</pubDate>
      <link>https://dev.to/amargul/quick-sort-why-your-programming-language-uses-this-algorithm-for-sort-25nm</link>
      <guid>https://dev.to/amargul/quick-sort-why-your-programming-language-uses-this-algorithm-for-sort-25nm</guid>
      <description>&lt;p&gt;Every time you call .sort() in JavaScript,&lt;br&gt;
Python, or Java — Quick Sort is running &lt;br&gt;
under the hood.&lt;/p&gt;

&lt;p&gt;Not Bubble Sort. Not Merge Sort. Quick Sort.&lt;/p&gt;
&lt;h2&gt;
  
  
  Why Quick Sort?
&lt;/h2&gt;

&lt;p&gt;It combines two things perfectly:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;O(n log n) average performance&lt;/li&gt;
&lt;li&gt;In-place sorting — no extra memory needed&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Merge Sort also achieves O(n log n) but &lt;br&gt;
requires O(n) extra space. Quick Sort only &lt;br&gt;
needs O(log n) stack space for recursion.&lt;/p&gt;
&lt;h2&gt;
  
  
  The Core Idea — The Pivot
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;\&lt;/code&gt;`javascript&lt;br&gt;
function partition(arr, low, high) {&lt;br&gt;
  const pivot = arr[high];&lt;br&gt;
  let i = low - 1;&lt;/p&gt;

&lt;p&gt;for (let j = low; j &amp;lt; high; j++) {&lt;br&gt;
    if (arr[j] &amp;lt;= pivot) {&lt;br&gt;
      i++;&lt;br&gt;
      [arr[i], arr[j]] = [arr[j], arr[i]];&lt;br&gt;
    }&lt;br&gt;
  }&lt;br&gt;
  [arr[i + 1], arr[high]] = [arr[high], arr[i + 1]];&lt;br&gt;
  return i + 1;&lt;br&gt;
}&lt;br&gt;
`&lt;code&gt;\&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Pick a pivot. Everything smaller goes left.&lt;br&gt;
Everything larger goes right.&lt;br&gt;
The pivot is now in its permanent position.&lt;/p&gt;
&lt;h2&gt;
  
  
  The One Weakness
&lt;/h2&gt;

&lt;p&gt;Worst case is O(n²) — when pivot is always &lt;br&gt;
the smallest or largest element.&lt;/p&gt;

&lt;p&gt;Modern implementations use randomized pivot &lt;br&gt;
selection to avoid this trap.&lt;/p&gt;
&lt;h2&gt;
  
  
  Watch It
&lt;/h2&gt;

&lt;p&gt;  &lt;iframe src="https://www.youtube.com/embed/9Pbn345vsxY"&gt;
  &lt;/iframe&gt;
&lt;/p&gt;

&lt;h2&gt;
  
  
  What's Next
&lt;/h2&gt;

&lt;p&gt;Linked Lists — a completely different &lt;br&gt;
approach to storing data in memory.&lt;/p&gt;

&lt;p&gt;Subscribe to AlgoCanvas:&lt;br&gt;
👉 youtube.com/@AlgoCanvas&lt;/p&gt;

</description>
      <category>react</category>
      <category>javascript</category>
      <category>algorithms</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Merge Sort vs Bubble Sort — Why 800 Comparisons Beats 147 Every Time</title>
      <dc:creator>Amar Gul</dc:creator>
      <pubDate>Sat, 16 May 2026 19:00:50 +0000</pubDate>
      <link>https://dev.to/amargul/merge-sort-vs-bubble-sort-why-800-comparisons-beats-147-every-time-1de0</link>
      <guid>https://dev.to/amargul/merge-sort-vs-bubble-sort-why-800-comparisons-beats-147-every-time-1de0</guid>
      <description>&lt;p&gt;Most developers know Merge Sort is faster &lt;br&gt;
than Bubble Sort. But watching it happen &lt;br&gt;
makes the difference visceral.&lt;/p&gt;
&lt;h2&gt;
  
  
  The Numbers
&lt;/h2&gt;

&lt;p&gt;Bubble Sort: 800+ comparisons&lt;br&gt;
Merge Sort: 147 comparisons&lt;br&gt;
Same 30 elements. Same result.&lt;/p&gt;
&lt;h2&gt;
  
  
  Why Such a Difference?
&lt;/h2&gt;

&lt;p&gt;Bubble Sort compares adjacent elements &lt;br&gt;
and moves them one step at a time — &lt;br&gt;
O(n²) in worst case.&lt;/p&gt;

&lt;p&gt;Merge Sort divides the array completely &lt;br&gt;
down to single elements, then merges &lt;br&gt;
them back in sorted order — O(n log n) &lt;br&gt;
guaranteed every single time.&lt;/p&gt;
&lt;h2&gt;
  
  
  The Key Code
&lt;/h2&gt;

&lt;p&gt;The entire algorithm is built on one &lt;br&gt;
recursive insight:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;\&lt;/code&gt;&lt;code&gt;javascript&lt;br&gt;
function mergeSort(arr, left, right) {&lt;br&gt;
  if (left &amp;gt;= right) return;&lt;br&gt;
  const mid = Math.floor((left + right) / 2);&lt;br&gt;
  mergeSort(arr, left, mid);&lt;br&gt;
  mergeSort(arr, mid + 1, right);&lt;br&gt;
  merge(arr, left, mid, right);&lt;br&gt;
}&lt;br&gt;
\&lt;/code&gt;&lt;code&gt;\&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;A single element is already sorted by &lt;br&gt;
definition. Everything else is just &lt;br&gt;
merging sorted groups together.&lt;/p&gt;
&lt;h2&gt;
  
  
  Built in React — Zero Libraries
&lt;/h2&gt;

&lt;p&gt;Animation state managed entirely with &lt;br&gt;
useState and useRef. No external &lt;br&gt;
animation libraries.&lt;/p&gt;

&lt;p&gt;Color coding:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Purple = unsorted&lt;/li&gt;
&lt;li&gt;Gold = currently merging
&lt;/li&gt;
&lt;li&gt;Red = comparing&lt;/li&gt;
&lt;li&gt;Cyan = fully sorted&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  Watch It
&lt;/h2&gt;

&lt;p&gt;  &lt;iframe src="https://www.youtube.com/embed/K5Cy4-47d5s"&gt;
  &lt;/iframe&gt;
&lt;/p&gt;

&lt;h2&gt;
  
  
  What's Next
&lt;/h2&gt;

&lt;p&gt;Quick Sort — the algorithm that actually &lt;br&gt;
powers sorting in most programming &lt;br&gt;
languages. Spoiler: it's faster than &lt;br&gt;
Merge Sort in practice despite worse &lt;br&gt;
worst-case complexity.&lt;/p&gt;

&lt;p&gt;Subscribe to AlgoCanvas:&lt;br&gt;
👉 youtube.com/@AlgoCanvas&lt;/p&gt;

</description>
      <category>react</category>
      <category>javascript</category>
      <category>algorithms</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Binary Search vs Linear Search — Visualized in React with No Libraries</title>
      <dc:creator>Amar Gul</dc:creator>
      <pubDate>Tue, 12 May 2026 16:45:09 +0000</pubDate>
      <link>https://dev.to/amargul/binary-search-vs-linear-search-visualized-in-react-with-no-libraries-3gke</link>
      <guid>https://dev.to/amargul/binary-search-vs-linear-search-visualized-in-react-with-no-libraries-3gke</guid>
      <description>&lt;p&gt;As a Senior React developer I wanted to &lt;br&gt;
show exactly WHY binary search exists — &lt;br&gt;
not just explain it with words.&lt;/p&gt;

&lt;p&gt;So I built a side by side comparison &lt;br&gt;
showing both algorithms running on the &lt;br&gt;
same array searching for the same target.&lt;/p&gt;
&lt;h2&gt;
  
  
  The Visual Difference
&lt;/h2&gt;

&lt;p&gt;Linear search checks every element from &lt;br&gt;
left to right. Predictable but slow.&lt;/p&gt;

&lt;p&gt;Binary search goes straight to the middle. &lt;br&gt;
Higher or lower? Eliminate half. Repeat.&lt;/p&gt;
&lt;h2&gt;
  
  
  Tech Stack
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;React functional components&lt;/li&gt;
&lt;li&gt;useState for animation state&lt;/li&gt;
&lt;li&gt;useRef for timeout management&lt;/li&gt;
&lt;li&gt;Zero external animation libraries&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  The Key Code
&lt;/h2&gt;

&lt;p&gt;Two separate animation pipelines running &lt;br&gt;
sequentially — linear first, then binary:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;\&lt;/code&gt;`javascript&lt;br&gt;
// Linear search steps&lt;br&gt;
for (let i = 0; i &amp;lt; array.length; i++) {&lt;br&gt;
  steps.push({ checking: i });&lt;br&gt;
  if (array[i] === target) break;&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;// Binary search steps&lt;br&gt;&lt;br&gt;
while (low &amp;lt;= high) {&lt;br&gt;
  const mid = Math.floor((low + high) / 2);&lt;br&gt;
  steps.push({ middle: mid, eliminated });&lt;br&gt;
  if (array[mid] === target) break;&lt;br&gt;
  else if (array[mid] &amp;lt; target) low = mid + 1;&lt;br&gt;
  else high = mid - 1;&lt;br&gt;
}&lt;br&gt;
`&lt;code&gt;\&lt;/code&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  The Result
&lt;/h2&gt;

&lt;p&gt;  &lt;iframe src="https://www.youtube.com/embed/FHQLbVrWEJo"&gt;
  &lt;/iframe&gt;
&lt;/p&gt;

&lt;h2&gt;
  
  
  What's Next
&lt;/h2&gt;

&lt;p&gt;Building visualizations for:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Merge Sort&lt;/li&gt;
&lt;li&gt;Quick Sort
&lt;/li&gt;
&lt;li&gt;Dijkstra's Algorithm&lt;/li&gt;
&lt;li&gt;Binary Search Trees&lt;/li&gt;
&lt;li&gt;Hash Tables&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Subscribe to AlgoCanvas on YouTube:&lt;br&gt;
👉 youtube.com/@AlgoCanvas&lt;/p&gt;

&lt;p&gt;Feedback welcome — drop a comment below!&lt;/p&gt;

</description>
      <category>react</category>
      <category>javascript</category>
      <category>tutorial</category>
      <category>algorithms</category>
    </item>
    <item>
      <title>How I Built a Bubble Sort Visualizer in React — No Animation Libraries</title>
      <dc:creator>Amar Gul</dc:creator>
      <pubDate>Sat, 09 May 2026 18:08:50 +0000</pubDate>
      <link>https://dev.to/amargul/how-i-built-a-bubble-sort-visualizer-in-react-no-animation-libraries-3d18</link>
      <guid>https://dev.to/amargul/how-i-built-a-bubble-sort-visualizer-in-react-no-animation-libraries-3d18</guid>
      <description>&lt;p&gt;As a Senior React developer I've built dozens &lt;br&gt;
of complex applications — but I wanted to create &lt;br&gt;
something that actually helps people understand &lt;br&gt;
computer science fundamentals visually.&lt;/p&gt;

&lt;p&gt;So I built AlgoCanvas — a series of algorithm &lt;br&gt;
visualizations built purely in React.&lt;/p&gt;
&lt;h2&gt;
  
  
  Why I Built This
&lt;/h2&gt;

&lt;p&gt;Most algorithm explanations use static diagrams &lt;br&gt;
or walls of code. Neither actually shows you &lt;br&gt;
what the algorithm is &lt;em&gt;doing&lt;/em&gt; at each step.&lt;/p&gt;

&lt;p&gt;I wanted to change that. Watch it work — and &lt;br&gt;
it clicks instantly.&lt;/p&gt;
&lt;h2&gt;
  
  
  The Tech Stack
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;React functional components&lt;/li&gt;
&lt;li&gt;useState for animation state&lt;/li&gt;
&lt;li&gt;useRef for timeout management&lt;/li&gt;
&lt;li&gt;CSS-in-JS inline styles&lt;/li&gt;
&lt;li&gt;Zero external animation libraries&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  How the Animation Works
&lt;/h2&gt;

&lt;p&gt;The key insight is building all animation steps &lt;br&gt;
upfront, then replaying them with setTimeout:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;bubbleSort&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;arr&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[...&lt;/span&gt;&lt;span class="nx"&gt;array&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;steps&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[];&lt;/span&gt;

  &lt;span class="k"&gt;for &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="nx"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;for &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;j&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;j&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="nx"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;j&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nx"&gt;steps&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;push&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; 
        &lt;span class="na"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[...&lt;/span&gt;&lt;span class="nx"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; 
        &lt;span class="na"&gt;comparing&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;j&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;j&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; 
      &lt;span class="p"&gt;});&lt;/span&gt;
      &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;j&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;j&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;j&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="nx"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;j&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;j&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="nx"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;j&lt;/span&gt;&lt;span class="p"&gt;]];&lt;/span&gt;
        &lt;span class="nx"&gt;steps&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;push&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; 
          &lt;span class="na"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[...&lt;/span&gt;&lt;span class="nx"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; 
          &lt;span class="na"&gt;comparing&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;j&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;j&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; 
        &lt;span class="p"&gt;});&lt;/span&gt;
      &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;steps&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then replay each step with a delay:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;steps&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;forEach&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;step&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;index&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nf"&gt;setTimeout&lt;/span&gt;&lt;span class="p"&gt;(()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nf"&gt;setArray&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;step&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="nf"&gt;setComparing&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;step&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;comparing&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="nx"&gt;index&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;120&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Color Coding System
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;🟣 Purple — unsorted elements&lt;/li&gt;
&lt;li&gt;🔴 Red — currently being compared&lt;/li&gt;
&lt;li&gt;🩵 Cyan — fully sorted and done&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This makes it immediately obvious what the &lt;br&gt;
algorithm is doing at every single step.&lt;/p&gt;
&lt;h2&gt;
  
  
  The Result
&lt;/h2&gt;

&lt;p&gt;  &lt;iframe src="https://www.youtube.com/embed/0_7TuvGp0GM"&gt;
  &lt;/iframe&gt;
&lt;/p&gt;

&lt;h2&gt;
  
  
  What's Next
&lt;/h2&gt;

&lt;p&gt;I'm building visualizations for:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Binary Search&lt;/li&gt;
&lt;li&gt;Merge Sort&lt;/li&gt;
&lt;li&gt;Quick Sort&lt;/li&gt;
&lt;li&gt;Dijkstra's Algorithm&lt;/li&gt;
&lt;li&gt;Binary Search Trees&lt;/li&gt;
&lt;li&gt;Hash Tables&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Subscribe to AlgoCanvas on YouTube if you &lt;br&gt;
want to follow along:&lt;br&gt;
👉 youtube.com/@AlgoCanvas&lt;/p&gt;

&lt;h2&gt;
  
  
  Feedback Welcome
&lt;/h2&gt;

&lt;p&gt;Would love to hear from other React developers:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Better patterns for animation state?&lt;/li&gt;
&lt;li&gt;Which algorithm should I visualize next?&lt;/li&gt;
&lt;li&gt;Any performance improvements?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Drop a comment below!&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>react</category>
      <category>algorithms</category>
      <category>tutorial</category>
    </item>
  </channel>
</rss>
