<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Priority-Queue on Algorithms in 60 Days</title><link>https://algorithmsin60days.com/tags/priority-queue/</link><description>Recent content in Priority-Queue on Algorithms in 60 Days</description><generator>Hugo</generator><language>en-us</language><lastBuildDate>Fri, 10 Jul 2026 00:00:00 +0000</lastBuildDate><atom:link href="https://algorithmsin60days.com/tags/priority-queue/index.xml" rel="self" type="application/rss+xml"/><item><title>Heaps: A Study Guide</title><link>https://algorithmsin60days.com/topics/heaps/</link><pubDate>Fri, 10 Jul 2026 00:00:00 +0000</pubDate><guid>https://algorithmsin60days.com/topics/heaps/</guid><description>&lt;p&gt;A heap is a complete binary tree with a simple ordering rule: in a &lt;strong&gt;min-heap&lt;/strong&gt;, every parent is smaller than or equal to its children, so the smallest element is always at the root. (A &lt;strong&gt;max-heap&lt;/strong&gt; flips the comparison.) The heap does not fully sort its elements; it only guarantees the extreme value sits on top, which is exactly what you need for a priority queue.&lt;/p&gt;

&lt;h2 id="why-heaps-matter"&gt;Why Heaps Matter&lt;a class="header-anchor" href="#why-heaps-matter" aria-label="Permalink to this heading"&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Whenever a problem asks for the &amp;ldquo;top k&amp;rdquo;, the &amp;ldquo;kth largest&amp;rdquo;, the &amp;ldquo;next smallest&amp;rdquo;, or &amp;ldquo;process the cheapest item next&amp;rdquo;, a heap is usually the answer. Dijkstra&amp;rsquo;s shortest-path algorithm, Huffman coding, merge-k-sorted-lists, and median-of-a-stream all lean on heaps. The heap gives you repeated access to the min or max without paying O(n log n) to fully sort.&lt;/p&gt;</description></item></channel></rss>