Skip to content

Commit ae732fc

Browse files
committed
Built site for gh-pages
1 parent b23b855 commit ae732fc

16 files changed

Lines changed: 355 additions & 361 deletions

.nojekyll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0e73843b
1+
ba2be488

00_intro.html

Lines changed: 22 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">
88

99

10-
<title>1&nbsp; Foundations – The Algorithm Codex</title>
10+
<title>Foundations – The Algorithm Codex</title>
1111
<style>
1212
code{white-space: pre-wrap;}
1313
span.smallcaps{font-variant: small-caps;}
@@ -111,7 +111,7 @@
111111
<button type="button" class="quarto-btn-toggle btn" data-bs-toggle="collapse" role="button" data-bs-target=".quarto-sidebar-collapse-item" aria-controls="quarto-sidebar" aria-expanded="false" aria-label="Toggle sidebar navigation" onclick="if (window.quartoToggleHeadroom) { window.quartoToggleHeadroom(); }">
112112
<i class="bi bi-layout-text-sidebar-reverse"></i>
113113
</button>
114-
<nav class="quarto-page-breadcrumbs" aria-label="breadcrumb"><ol class="breadcrumb"><li class="breadcrumb-item"><a href="./00_intro.html"><span class="chapter-number">1</span>&nbsp; <span class="chapter-title">Foundations</span></a></li></ol></nav>
114+
<nav class="quarto-page-breadcrumbs" aria-label="breadcrumb"><ol class="breadcrumb"><li class="breadcrumb-item"><a href="./00_intro.html">Foundations</a></li></ol></nav>
115115
<a class="flex-grow-1" role="navigation" data-bs-toggle="collapse" data-bs-target=".quarto-sidebar-collapse-item" aria-controls="quarto-sidebar" aria-expanded="false" aria-label="Toggle sidebar navigation" onclick="if (window.quartoToggleHeadroom) { window.quartoToggleHeadroom(); }">
116116
</a>
117117
<button type="button" class="btn quarto-search-button" aria-label="Search" onclick="window.quartoOpenSearch();">
@@ -145,7 +145,7 @@
145145
<li class="sidebar-item">
146146
<div class="sidebar-item-container">
147147
<a href="./00_intro.html" class="sidebar-item-text sidebar-link active">
148-
<span class="menu-text"><span class="chapter-number">1</span>&nbsp; <span class="chapter-title">Foundations</span></span></a>
148+
<span class="menu-text">Foundations</span></a>
149149
</div>
150150
</li>
151151
<li class="sidebar-item sidebar-item-section">
@@ -160,37 +160,37 @@
160160
<li class="sidebar-item">
161161
<div class="sidebar-item-container">
162162
<a href="./01_search.html" class="sidebar-item-text sidebar-link">
163-
<span class="menu-text"><span class="chapter-number">2</span>&nbsp; <span class="chapter-title">Basic Search</span></span></a>
163+
<span class="menu-text"><span class="chapter-number">1</span>&nbsp; <span class="chapter-title">Basic Search</span></span></a>
164164
</div>
165165
</li>
166166
<li class="sidebar-item">
167167
<div class="sidebar-item-container">
168168
<a href="./02_binary.html" class="sidebar-item-text sidebar-link">
169-
<span class="menu-text"><span class="chapter-number">3</span>&nbsp; <span class="chapter-title">Efficient Search</span></span></a>
169+
<span class="menu-text"><span class="chapter-number">2</span>&nbsp; <span class="chapter-title">Efficient Search</span></span></a>
170170
</div>
171171
</li>
172172
<li class="sidebar-item">
173173
<div class="sidebar-item-container">
174174
<a href="./03_sort.html" class="sidebar-item-text sidebar-link">
175-
<span class="menu-text"><span class="chapter-number">4</span>&nbsp; <span class="chapter-title">Basic Sorting</span></span></a>
175+
<span class="menu-text"><span class="chapter-number">3</span>&nbsp; <span class="chapter-title">Basic Sorting</span></span></a>
176176
</div>
177177
</li>
178178
<li class="sidebar-item">
179179
<div class="sidebar-item-container">
180180
<a href="./04_sort_fast.html" class="sidebar-item-text sidebar-link">
181-
<span class="menu-text"><span class="chapter-number">5</span>&nbsp; <span class="chapter-title">Efficient Sorting</span></span></a>
181+
<span class="menu-text"><span class="chapter-number">4</span>&nbsp; <span class="chapter-title">Efficient Sorting</span></span></a>
182182
</div>
183183
</li>
184184
<li class="sidebar-item">
185185
<div class="sidebar-item-container">
186186
<a href="./05_rankings.html" class="sidebar-item-text sidebar-link">
187-
<span class="menu-text"><span class="chapter-number">6</span>&nbsp; <span class="chapter-title">Rankings and Selection</span></span></a>
187+
<span class="menu-text"><span class="chapter-number">5</span>&nbsp; <span class="chapter-title">Rankings and Selection</span></span></a>
188188
</div>
189189
</li>
190190
<li class="sidebar-item">
191191
<div class="sidebar-item-container">
192192
<a href="./06_linear_sort.html" class="sidebar-item-text sidebar-link">
193-
<span class="menu-text"><span class="chapter-number">7</span>&nbsp; <span class="chapter-title">Linear Time Sorting</span></span></a>
193+
<span class="menu-text"><span class="chapter-number">6</span>&nbsp; <span class="chapter-title">Linear Time Sorting</span></span></a>
194194
</div>
195195
</li>
196196
<li class="sidebar-item">
@@ -262,13 +262,10 @@
262262
<h2 id="toc-title">Table of contents</h2>
263263

264264
<ul>
265-
<li><a href="#what-is-an-algorithm" id="toc-what-is-an-algorithm" class="nav-link active" data-scroll-target="#what-is-an-algorithm"><span class="header-section-number">1.1</span> What is an Algorithm?</a></li>
266-
<li><a href="#analyzing-algorithms" id="toc-analyzing-algorithms" class="nav-link" data-scroll-target="#analyzing-algorithms"><span class="header-section-number">1.2</span> Analyzing Algorithms</a></li>
267-
<li><a href="#measuring-efficiency-time-space-and-scaling" id="toc-measuring-efficiency-time-space-and-scaling" class="nav-link" data-scroll-target="#measuring-efficiency-time-space-and-scaling"><span class="header-section-number">1.3</span> Measuring Efficiency: Time, Space, and Scaling</a>
268-
<ul class="collapse">
269-
<li><a href="#the-unitary-cost-model" id="toc-the-unitary-cost-model" class="nav-link" data-scroll-target="#the-unitary-cost-model"><span class="header-section-number">1.3.1</span> The Unitary Cost Model</a></li>
270-
</ul></li>
271-
<li><a href="#final-words" id="toc-final-words" class="nav-link" data-scroll-target="#final-words"><span class="header-section-number">1.4</span> Final Words</a></li>
265+
<li><a href="#what-is-an-algorithm" id="toc-what-is-an-algorithm" class="nav-link active" data-scroll-target="#what-is-an-algorithm">What is an Algorithm?</a></li>
266+
<li><a href="#analyzing-algorithms" id="toc-analyzing-algorithms" class="nav-link" data-scroll-target="#analyzing-algorithms">Analyzing Algorithms</a></li>
267+
<li><a href="#measuring-efficiency" id="toc-measuring-efficiency" class="nav-link" data-scroll-target="#measuring-efficiency">Measuring Efficiency</a></li>
268+
<li><a href="#final-words" id="toc-final-words" class="nav-link" data-scroll-target="#final-words">Final Words</a></li>
272269
</ul>
273270
</nav>
274271
</div>
@@ -277,7 +274,7 @@ <h2 id="toc-title">Table of contents</h2>
277274

278275
<header id="title-block-header" class="quarto-title-block default">
279276
<div class="quarto-title">
280-
<h1 class="title"><span class="chapter-number">1</span>&nbsp; <span class="chapter-title">Foundations</span></h1>
277+
<h1 class="title">Foundations</h1>
281278
</div>
282279

283280

@@ -295,8 +292,8 @@ <h1 class="title"><span class="chapter-number">1</span>&nbsp; <span class="chapt
295292

296293

297294
<p>Before we begin our journey through specific algorithms, we must establish the ground on which we stand. To study algorithms is to study the limits of what can be computed and the cost of doing so.</p>
298-
<section id="what-is-an-algorithm" class="level2" data-number="1.1">
299-
<h2 data-number="1.1" class="anchored" data-anchor-id="what-is-an-algorithm"><span class="header-section-number">1.1</span> What is an Algorithm?</h2>
295+
<section id="what-is-an-algorithm" class="level2">
296+
<h2 class="anchored" data-anchor-id="what-is-an-algorithm">What is an Algorithm?</h2>
300297
<p>At its simplest, an algorithm is a procedure that takes an input and produces an output. However, in this Codex, we view an algorithm as a <strong>formal mathematical object</strong>—a precise strategy that exploits the structure of data to achieve an outcome efficiently.</p>
301298
<p>To be considered a valid algorithm in our context, a procedure must satisfy several key characteristics:</p>
302299
<ul>
@@ -307,8 +304,8 @@ <h2 data-number="1.1" class="anchored" data-anchor-id="what-is-an-algorithm"><sp
307304
<p>Most academic texts rely on <strong>pseudo-code</strong>—a high-level, informal description of an algorithm. While pseudo-code is useful for broad strokes, it often hides subtle complexities and can be interpreted in multiple ways.</p>
308305
<p>In <strong>The Algorithm Codex</strong>, we deliberately avoid pseudo-code in favor of actual, runnable <strong>Python 3.13</strong>. By using a real programming language, we ensure that every operation is precisely defined and that the implementations you see are ready to be tested, scrutinized, and executed. This approach removes the “translation layer” between theory and practice, making the logic transparent and absolute.</p>
309306
</section>
310-
<section id="analyzing-algorithms" class="level2" data-number="1.2">
311-
<h2 data-number="1.2" class="anchored" data-anchor-id="analyzing-algorithms"><span class="header-section-number">1.2</span> Analyzing Algorithms</h2>
307+
<section id="analyzing-algorithms" class="level2">
308+
<h2 class="anchored" data-anchor-id="analyzing-algorithms">Analyzing Algorithms</h2>
312309
<p>Following the definition of what an algorithm is, we must establish a framework for evaluating them. Once an implementation is complete, the work of a computer scientist is only beginning. We must subject our solution to a rigorous three-step analysis to ensure it is not just a working program, but a complete solution to a computational problem.</p>
313310
<p>When we finish writing an algorithm, we must ask ourselves three fundamental questions. Only when all three are answered can we consider our work in computer science truly satisfied.</p>
314311
<p><strong>Is it correct?</strong></p>
@@ -319,11 +316,9 @@ <h2 data-number="1.2" class="anchored" data-anchor-id="analyzing-algorithms"><sp
319316
<p>The final question is perhaps the most profound: <strong>Is this the most efficient algorithm possible, or can there be a better one?</strong> We are not just looking for a “fast” algorithm; we are looking for the theoretical limits of the problem itself. Throughout this Codex, we will try to provide intuitive proofs of <strong>optimality</strong>—explaining why a certain complexity (like O(nlogn) for comparison-based sorting) cannot be improved upon.</p>
320317
<p>When we can prove—even intuitively—that we have reached the optimal efficiency for a correct algorithm, we have solved the problem completely. At that point, the computational task is no longer a mystery; it is a solved piece of the science of computation.</p>
321318
</section>
322-
<section id="measuring-efficiency-time-space-and-scaling" class="level2" data-number="1.3">
323-
<h2 data-number="1.3" class="anchored" data-anchor-id="measuring-efficiency-time-space-and-scaling"><span class="header-section-number">1.3</span> Measuring Efficiency: Time, Space, and Scaling</h2>
319+
<section id="measuring-efficiency" class="level2">
320+
<h2 class="anchored" data-anchor-id="measuring-efficiency">Measuring Efficiency</h2>
324321
<p>Once we have established that an algorithm is correct, we must ask how much it “costs” to run. In this book, we care about two primary resources: <strong>Time</strong> (the number of operations performed) and <strong>Space</strong> (the amount of memory required).</p>
325-
<section id="the-unitary-cost-model" class="level3" data-number="1.3.1">
326-
<h3 data-number="1.3.1" class="anchored" data-anchor-id="the-unitary-cost-model"><span class="header-section-number">1.3.1</span> The Unitary Cost Model</h3>
327322
<p>Because hardware changes so rapidly, it is rarely useful to talk about runtime in terms of seconds or memory in terms of megabytes. A sorting algorithm that takes ten seconds on a vintage machine might take a fraction of a millisecond on a modern supercomputer. To remain hardware-agnostic, we fix a <strong>unitary unit of cost</strong>.</p>
328323
<p>We assume that “atomic” operations—such as variable assignment, basic arithmetic, or printing to the console—each take exactly <strong>one unit of time</strong>. Similarly, we assume that atomic data types—like a single number or a character—occupy <strong>one unit of memory</strong>. By counting these units, we can discuss the cost of an algorithm as a mathematical function of its input.</p>
329324
<p>However, we rarely care about the absolute number of steps. Knowing that a specific sort takes exactly 1,024 operations is less useful than knowing how that cost grows as the input size <span class="math inline">\(n\)</span> increases.</p>
@@ -340,9 +335,8 @@ <h3 data-number="1.3.1" class="anchored" data-anchor-id="the-unitary-cost-model"
340335
</ul>
341336
<p>By focusing on these growth rates, we can determine the “efficiency ceiling” of our solutions and decide whether we have found the optimal approach for a given problem.</p>
342337
</section>
343-
</section>
344-
<section id="final-words" class="level2" data-number="1.4">
345-
<h2 data-number="1.4" class="anchored" data-anchor-id="final-words"><span class="header-section-number">1.4</span> Final Words</h2>
338+
<section id="final-words" class="level2">
339+
<h2 class="anchored" data-anchor-id="final-words">Final Words</h2>
346340
<p>Now that we have settled our expectations, you are ready to start the journey. It will be fast-paced but–I hope–really exciting. We will discover many algorithms, close to a hundred of them! And in each case, we ill ask ourselves these same three questions. And, surprisingly often, we will be able to answer them pretty well!</p>
347341

348342

0 commit comments

Comments
 (0)