<?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: 张旭</title>
    <description>The latest articles on DEV Community by 张旭 (@illegal).</description>
    <link>https://dev.to/illegal</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%2F2297725%2Fe1dba687-48d6-4692-9d6a-5d56721d9f8b.png</url>
      <title>DEV Community: 张旭</title>
      <link>https://dev.to/illegal</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/illegal"/>
    <language>en</language>
    <item>
      <title>See Quick Sort partitioning, one step at a time</title>
      <dc:creator>张旭</dc:creator>
      <pubDate>Wed, 15 Jul 2026 03:30:00 +0000</pubDate>
      <link>https://dev.to/illegal/see-quick-sort-partitioning-one-step-at-a-time-f9i</link>
      <guid>https://dev.to/illegal/see-quick-sort-partitioning-one-step-at-a-time-f9i</guid>
      <description>&lt;p&gt;Quick Sort is easy to summarize: choose a pivot, partition, and repeat. It is much harder to reason about while indices and subranges are moving. This visualizer turns those hidden state changes into a timeline you can inspect.&lt;/p&gt;

&lt;h2&gt;
  
  
  What the visualization shows
&lt;/h2&gt;

&lt;p&gt;This implementation uses Lomuto partitioning with the rightmost item as the pivot. The red &lt;code&gt;i&lt;/code&gt; pointer marks the boundary of the smaller-than-pivot region, while the blue &lt;code&gt;j&lt;/code&gt; pointer scans the active range. When &lt;code&gt;a[j] &amp;lt; pivot&lt;/code&gt;, that value moves into the smaller region and &lt;code&gt;i&lt;/code&gt; advances. Once the scan reaches &lt;code&gt;hi&lt;/code&gt;, the pivot swaps into &lt;code&gt;i&lt;/code&gt; and reaches its final position.&lt;/p&gt;

&lt;p&gt;Pending &lt;code&gt;[lo, hi]&lt;/code&gt; ranges appear on an explicit stack, so the recursive work is visible instead of being hand-waved. Every frame keeps the array, active range, pivot, pointers, swap count, stack, caption, and current source line synchronized. You can compare the same execution against TypeScript, Python, Go, and Rust implementations.&lt;/p&gt;

&lt;h2&gt;
  
  
  Try these inputs
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;An already sorted array shows how a rightmost pivot can create severely unbalanced partitions.&lt;/li&gt;
&lt;li&gt;A reverse-sorted array exposes the same worst-case shape through a different sequence of swaps.&lt;/li&gt;
&lt;li&gt;Duplicate-heavy input reveals that the strict &lt;code&gt;&amp;lt; pivot&lt;/code&gt; comparison leaves equal values on the other side of the boundary.&lt;/li&gt;
&lt;li&gt;A mixed input makes the typical divide-and-conquer behavior easier to see.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What to look for
&lt;/h2&gt;

&lt;p&gt;Quick Sort runs in &lt;code&gt;O(n log n)&lt;/code&gt; time on average, but this pivot strategy can degrade to &lt;code&gt;O(n^2)&lt;/code&gt;. Pause at each pivot placement, compare the sizes of the two resulting ranges, and watch the pending stack grow or shrink. Then change the input and replay the exact same checkpoints. The goal is not only to see a sorted result, but to understand how partition balance determines the work required.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://algo.illegalscreed.cn/en/docs/quick-sort/?utm_source=dev&amp;amp;utm_medium=community&amp;amp;utm_campaign=c127-t3d3-smoke&amp;amp;utm_content=dev-en-link-1" rel="noopener noreferrer"&gt;Explore the interactive Quick Sort visualizer&lt;/a&gt;&lt;/p&gt;

</description>
      <category>algorithms</category>
      <category>computerscience</category>
      <category>showdev</category>
      <category>tutorial</category>
    </item>
  </channel>
</rss>
