Skip to content

Commit 856fe02

Browse files
committed
Built site for gh-pages
1 parent cced6d5 commit 856fe02

16 files changed

Lines changed: 103 additions & 55 deletions

.nojekyll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
d2ee1911
1+
389e4a72

00_intro.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,8 +195,8 @@
195195
</li>
196196
<li class="sidebar-item">
197197
<div class="sidebar-item-container">
198-
<a href="./07_lessons_1.html" class="sidebar-item-text sidebar-link">
199-
<span class="menu-text"><span class="chapter-number">7</span>&nbsp; <span class="chapter-title">Lessons from Part I</span></span></a>
198+
<a href="./lessons_1.html" class="sidebar-item-text sidebar-link">
199+
<span class="menu-text">Lessons from Part I</span></a>
200200
</div>
201201
</li>
202202
</ul>

01_search.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -201,8 +201,8 @@
201201
</li>
202202
<li class="sidebar-item">
203203
<div class="sidebar-item-container">
204-
<a href="./07_lessons_1.html" class="sidebar-item-text sidebar-link">
205-
<span class="menu-text"><span class="chapter-number">7</span>&nbsp; <span class="chapter-title">Lessons from Part I</span></span></a>
204+
<a href="./lessons_1.html" class="sidebar-item-text sidebar-link">
205+
<span class="menu-text">Lessons from Part I</span></a>
206206
</div>
207207
</li>
208208
</ul>
@@ -374,7 +374,7 @@ <h2 data-number="1.3" class="anchored" data-anchor-id="min-and-max"><span class=
374374
<span id="cb9-5"><a href="#cb9-5" aria-hidden="true" tabindex="-1"></a> <span class="cf">return</span> <span class="dv">0</span></span>
375375
<span id="cb9-6"><a href="#cb9-6" aria-hidden="true" tabindex="-1"></a> <span class="cf">else</span>:</span>
376376
<span id="cb9-7"><a href="#cb9-7" aria-hidden="true" tabindex="-1"></a> <span class="cf">return</span> <span class="dv">1</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
377-
<p>Let’s write the <code>minimum</code> method using this convention. Since we have no knowledge of the structure of the sequence other than it supports partial ordering, we have to test all possible items, like before. But now, instead of returning as soon as we find the “correcOf course, we t” item, we simply store the minimum item we’ve seen so far, and return at the end of the <code>for</code> loop. This guarantees we have seen all the items, and thus the minimum among them must be the one we have marked.</p>
377+
<p>Let’s write the <code>minimum</code> method using this convention. Since we have no knowledge of the structure of the sequence other than it supports partial ordering, we have to test all possible items, like before. But now, instead of returning as soon as we find the correct item, we simply store the minimum item we’ve seen so far, and return at the end of the <code>for</code> loop. This guarantees we have seen all the items, and thus the minimum among them must be the one we have marked.</p>
378378
<div class="sourceCode" id="cb10" data-export="src/codex/search/linear.py"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb10-1"><a href="#cb10-1" aria-hidden="true" tabindex="-1"></a><span class="im">from</span> codex.types <span class="im">import</span> Ordering, default_order</span>
379379
<span id="cb10-2"><a href="#cb10-2" aria-hidden="true" tabindex="-1"></a></span>
380380
<span id="cb10-3"><a href="#cb10-3" aria-hidden="true" tabindex="-1"></a><span class="kw">def</span> minimum[T](items: Sequence[T], f: Ordering[T] <span class="op">=</span> <span class="va">None</span>) <span class="op">-&gt;</span> T:</span>

02_binary.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,8 +230,8 @@
230230
</li>
231231
<li class="sidebar-item">
232232
<div class="sidebar-item-container">
233-
<a href="./07_lessons_1.html" class="sidebar-item-text sidebar-link">
234-
<span class="menu-text"><span class="chapter-number">7</span>&nbsp; <span class="chapter-title">Lessons from Part I</span></span></a>
233+
<a href="./lessons_1.html" class="sidebar-item-text sidebar-link">
234+
<span class="menu-text">Lessons from Part I</span></a>
235235
</div>
236236
</li>
237237
</ul>

03_sort.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -230,8 +230,8 @@
230230
</li>
231231
<li class="sidebar-item">
232232
<div class="sidebar-item-container">
233-
<a href="./07_lessons_1.html" class="sidebar-item-text sidebar-link">
234-
<span class="menu-text"><span class="chapter-number">7</span>&nbsp; <span class="chapter-title">Lessons from Part I</span></span></a>
233+
<a href="./lessons_1.html" class="sidebar-item-text sidebar-link">
234+
<span class="menu-text">Lessons from Part I</span></a>
235235
</div>
236236
</li>
237237
</ul>
@@ -427,7 +427,7 @@ <h2 data-number="3.5" class="anchored" data-anchor-id="verification"><span class
427427
<section id="conclusion" class="level2" data-number="3.6">
428428
<h2 data-number="3.6" class="anchored" data-anchor-id="conclusion"><span class="header-section-number">3.6</span> Conclusion</h2>
429429
<p>Selection, Insertion, and Bubble sort are all <span class="math inline">\(O(n^2)\)</span> algorithms. The reason is structural: in the worst case, a list of size can have <span class="math inline">\(O(n^2)\)</span> inversions. Since each swap in these algorithms only fixes one inversion at a time–in the best case–we are forced to perform a quadratic number of operations.</p>
430-
<p>To break this ceiling and reach the theoretical limit of <span class="math inline">\(O(n^2)\)</span>, we need to be more clever. We need algorithms that can fix <em>many</em> inversions with a single operation. This “divide and conquer” approach will be the focus of our next chapter: <strong>Efficient Sorting</strong>.</p>
430+
<p>To break this ceiling and reach the theoretical limit of <span class="math inline">\(O(n \log n)\)</span>, we need to be more clever. We need algorithms that can fix <em>many</em> inversions with a single operation. This “divide and conquer” approach will be the focus of our next chapter: <strong>Efficient Sorting</strong>.</p>
431431

432432

433433
</section>

04_sort_fast.html

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -230,8 +230,8 @@
230230
</li>
231231
<li class="sidebar-item">
232232
<div class="sidebar-item-container">
233-
<a href="./07_lessons_1.html" class="sidebar-item-text sidebar-link">
234-
<span class="menu-text"><span class="chapter-number">7</span>&nbsp; <span class="chapter-title">Lessons from Part I</span></span></a>
233+
<a href="./lessons_1.html" class="sidebar-item-text sidebar-link">
234+
<span class="menu-text">Lessons from Part I</span></a>
235235
</div>
236236
</li>
237237
</ul>
@@ -373,7 +373,7 @@ <h2 data-number="4.1" class="anchored" data-anchor-id="merge-sort-intuition-thro
373373
<span id="cb1-38"><a href="#cb1-38" aria-hidden="true" tabindex="-1"></a> j <span class="op">+=</span> <span class="dv">1</span></span>
374374
<span id="cb1-39"><a href="#cb1-39" aria-hidden="true" tabindex="-1"></a> k <span class="op">+=</span> <span class="dv">1</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
375375
<p>In Merge Sort, the structural strategy is to <strong>fix inversions within each half first</strong>. We recursively dive deep into the sequence, sorting smaller and smaller sub-sequences. Only when the sub-sequences are internally free of inversions do we perform the merge step to fix the “global” inversions between the two halves.</p>
376-
<p>Because the list is halved at each step, the recursion depth is . Since we perform work at each level of the tree to merge the results, the total complexity is .</p>
376+
<p>Because the list is halved at each step, the recursion depth is <span class="math inline">\(log(n)\)</span>. Since we perform <span class="math inline">\(O(n)\)</span> work at each level of the tree to merge the results, the total complexity is <span class="math inline">\(O(n ĺog n)\)</span>.</p>
377377
</section>
378378
<section id="quick-sort-sorting-by-partitioning" class="level2" data-number="4.2">
379379
<h2 data-number="4.2" class="anchored" data-anchor-id="quick-sort-sorting-by-partitioning"><span class="header-section-number">4.2</span> Quick Sort: Sorting by Partitioning</h2>
@@ -408,7 +408,7 @@ <h2 data-number="4.2" class="anchored" data-anchor-id="quick-sort-sorting-by-par
408408
<span id="cb2-27"><a href="#cb2-27" aria-hidden="true" tabindex="-1"></a></span>
409409
<span id="cb2-28"><a href="#cb2-28" aria-hidden="true" tabindex="-1"></a> _quick_sort(<span class="dv">0</span>, <span class="bu">len</span>(items) <span class="op">-</span> <span class="dv">1</span>)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
410410
<p>The striking difference here is the order of operations. Quick Sort <strong>fixes inversions between both halves first</strong>. By partitioning, we ensure that there are zero inversions between the left “half” and the right “half” (no item in the left is greater than an item in the right). Once this global structure is established, we recursively fix the remaining inversions <strong>within</strong> each half.</p>
411-
<p>This approach allows Quick Sort to operate <strong>in-place</strong>, requiring only auxiliary space for the recursion stack. While its worst-case is , its average-case performance is a highly efficient .</p>
411+
<p>This approach allows Quick Sort to operate <strong>in-place</strong>, requiring only <span class="math inline">\(O(\log n)\)</span> auxiliary space for the recursion stack. While its worst-case is <span class="math inline">\(O(n^2)\)</span>, its average-case performance is a highly efficient <span class="math inline">\(O(n \log n)\)</span>.</p>
412412
</section>
413413
<section id="verification" class="level2" data-number="4.3">
414414
<h2 data-number="4.3" class="anchored" data-anchor-id="verification"><span class="header-section-number">4.3</span> Verification</h2>
@@ -429,7 +429,7 @@ <h2 data-number="4.3" class="anchored" data-anchor-id="verification"><span class
429429
</section>
430430
<section id="conclusion" class="level2" data-number="4.4">
431431
<h2 data-number="4.4" class="anchored" data-anchor-id="conclusion"><span class="header-section-number">4.4</span> Conclusion</h2>
432-
<p>Both Merge Sort and Quick Sort reaffirm our central theme: <strong>structure matters</strong>. By moving away from the unstructured swaps of Bubble Sort and adopting a rigorous divide-and-conquer strategy, we change how we interact with the geometry of inversions.</p>
432+
<p>Both Merge Sort and Quick Sort reaffirm our central theme: <strong>structure matters</strong>. By moving away from the unstructured swaps of Bubble Sort and adopting a rigorous divide-and-conquer strategy, we change how we interact with the geometry of inversions.</p>
433433
<p>Whether we fix local inversions first (Merge Sort) or global ones first (Quick Sort), the result is a massive leap in efficiency. We have traded the simplicity of a double-loop for the power of recursion and structural partitioning.</p>
434434

435435

05_rankings.html

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,35 @@
105105
}
106106
}</script>
107107

108+
<script src="https://cdnjs.cloudflare.com/polyfill/v3/polyfill.min.js?features=es6"></script>
109+
<script src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-chtml-full.js" type="text/javascript"></script>
110+
111+
<script type="text/javascript">
112+
const typesetMath = (el) => {
113+
if (window.MathJax) {
114+
// MathJax Typeset
115+
window.MathJax.typeset([el]);
116+
} else if (window.katex) {
117+
// KaTeX Render
118+
var mathElements = el.getElementsByClassName("math");
119+
var macros = [];
120+
for (var i = 0; i < mathElements.length; i++) {
121+
var texText = mathElements[i].firstChild;
122+
if (mathElements[i].tagName == "SPAN") {
123+
window.katex.render(texText.data, mathElements[i], {
124+
displayMode: mathElements[i].classList.contains('display'),
125+
throwOnError: false,
126+
macros: macros,
127+
fleqn: false
128+
});
129+
}
130+
}
131+
}
132+
}
133+
window.Quarto = {
134+
typesetMath
135+
};
136+
</script>
108137

109138
</head>
110139

@@ -201,8 +230,8 @@
201230
</li>
202231
<li class="sidebar-item">
203232
<div class="sidebar-item-container">
204-
<a href="./07_lessons_1.html" class="sidebar-item-text sidebar-link">
205-
<span class="menu-text"><span class="chapter-number">7</span>&nbsp; <span class="chapter-title">Lessons from Part I</span></span></a>
233+
<a href="./lessons_1.html" class="sidebar-item-text sidebar-link">
234+
<span class="menu-text">Lessons from Part I</span></a>
206235
</div>
207236
</li>
208237
</ul>
@@ -348,7 +377,7 @@ <h2 data-number="5.1" class="anchored" data-anchor-id="quick-select-selection-vi
348377
<span id="cb1-43"><a href="#cb1-43" aria-hidden="true" tabindex="-1"></a> i <span class="op">+=</span> <span class="dv">1</span></span>
349378
<span id="cb1-44"><a href="#cb1-44" aria-hidden="true" tabindex="-1"></a> items[i], items[high] <span class="op">=</span> items[high], items[i]</span>
350379
<span id="cb1-45"><a href="#cb1-45" aria-hidden="true" tabindex="-1"></a> <span class="cf">return</span> i</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
351-
<p>The probabilistic analysis of Quick Select is striking. In the worst case—where we consistently pick the worst possible pivot—the complexity is still . However, on average, the size of the search space follows a geometric series: , which converges to . This means that on average, Quick Select finds the -th order statistic in **** time.</p>
380+
<p>The probabilistic analysis of Quick Select is striking. In the worst case—where we consistently pick the worst possible pivot—the complexity is still <span class="math inline">\(O(n^2)\)</span>. However, on average, the size of the search space follows a geometric series which converges to <span class="math inline">\(O(n)\)</span>. This means that on average, Quick Select finds the <span class="math inline">\(k\)</span>-th order statistic in <span class="math inline">\(O(n)\)</span> time.</p>
352381
</section>
353382
<section id="median-of-medians-deterministic-selection" class="level2" data-number="5.2">
354383
<h2 data-number="5.2" class="anchored" data-anchor-id="median-of-medians-deterministic-selection"><span class="header-section-number">5.2</span> Median of Medians: Deterministic Selection</h2>

0 commit comments

Comments
 (0)