Skip to content
Merged
Prev Previous commit
Next Next commit
Merge branch 'master' into 10-clarifications
  • Loading branch information
justinmeiners committed Dec 14, 2021
commit 98faebdd0e9fd34d65b2ac8a104eb6ba43c24186
19 changes: 9 additions & 10 deletions 10_binary_counter.html
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,8 @@ <h2>Alice in wonderland</h2>
If you haven&rsquo;t read it, do<sup id="fnref:1"><a href="#fn:1" rel="footnote">1</a></sup>.
No person should be hired ever unless they read &ldquo;Alice in Wonderland&rdquo;.
In any case, he was also a mathematician.
He also dabbled in all kind of games
apparently he invented Scrabble and a bunch of other games<sup id="fnref:2"><a href="#fn:2" rel="footnote">2</a></sup>.</p>
He also dabbled in all kind of games.
Apparently he invented Scrabble and a bunch of other games<sup id="fnref:2"><a href="#fn:2" rel="footnote">2</a></sup>.</p>

<p>At some point he decided that there is a clear problem with lawn tennis tournaments.
He observed that with a very high probability,
Expand All @@ -160,14 +160,13 @@ <h2>Alice in wonderland</h2>
which assures that the second-placed guy is truly the second best player.
He published it in 1883<sup id="fnref:3"><a href="#fn:3" rel="footnote">3</a></sup>.
The algorithm wasn&rsquo;t quite an algorithm<sup id="fnref:4"><a href="#fn:4" rel="footnote">4</a></sup> and it was clearly not optimal.
It took 15 more years before the problem was stated correctly.
It took 50 more years before the problem was stated correctly.
People realized that you could talk about the minimum
number of comparisons but it took another thirty years, until 1964 when a
Russian mathematician <a href="http://www.mathnet.ru/eng/person27000">Sergei S. Kislitsyn</a> published a paper which
proved there is an optimal algorithm and described it.</p>

<p>By the way, all of this information is available in
a
<p>By the way, all of this information is available in a
book called <a href="https://en.wikipedia.org/wiki/The_Art_of_Computer_Programming">&ldquo;The Art of Computer Programming&rdquo;</a> by <a href="https://en.wikipedia.org/wiki/Donald_Knuth">Donald Knuth</a><sup id="fnref:5"><a href="#fn:5" rel="footnote">5</a></sup>.
You really should buy it.
You make a certain commitment.
Expand Down Expand Up @@ -299,7 +298,7 @@ <h3>Tournament tree shapes</h3>
</code></pre>

<p>It has <code>n - 1</code> internal nodes.
But we don&rsquo;t want the min to do <code>n - 1</code> comparisons.
But we don&rsquo;t want the winning element to do <code>n - 1</code> comparisons.
We need to transform that into the way they play tennis tournaments.
We need to balance the tree.</p>

Expand All @@ -315,7 +314,7 @@ <h3>Tournament tree shapes</h3>
One way is to just pair up elements and build up.
But then we need lots of memory to save the intermediate results<sup id="fnref:6"><a href="#fn:6" rel="footnote">6</a></sup>.
Note that once a bottom-level round has been played, they are ready to move up.
Our goal is to basically to become eager.
Our goal is basically to become eager.
Whenever elements are ready to be paired together, we want to pair them.
So if we store only the winner at each level, we never need to store <code>log(n)</code> things.
We can define the <strong>power</strong> of each element
Expand Down Expand Up @@ -395,7 +394,7 @@ <h2>Binary counting and reduction</h2>

<p>If you are familiar with <a href="https://en.wikipedia.org/wiki/Numerical_analysis">numerical analysis</a>,
whenever you sum up large number you don&rsquo;t really want to
add small quantities to big quantitative.
add small quantities to big quantities.
Bad things happen to the errors<sup id="fnref:11"><a href="#fn:11" rel="footnote">11</a></sup>.
So, you could use the same device for balancing your addition.
If you want to implement <a href="https://en.wikipedia.org/wiki/Merge_sort">merge sort</a> you can use exactly the same device, since
Expand Down Expand Up @@ -630,7 +629,7 @@ <h2>Code</h2>
</code></pre>

<p>You can see why associativity is often referred to as being
able to &ldquo;re-paranthesize&rdquo; expressions.</p><a href="#fnref:7" rev="footnote">&#8617;</a></li>
able to &ldquo;re-parenthesize&rdquo; expressions.</p><a href="#fnref:7" rev="footnote">&#8617;</a></li>
<li id="fn:8">
<p>A binary function <code>f</code> is <a href="https://en.wikipedia.org/wiki/Commutative_property">commutative</a>
if for all <code>a, b</code> in its domain:</p>
Expand Down Expand Up @@ -733,7 +732,7 @@ <h2>Code</h2>
<li id="fn:12">
Alex: Maybe we should make it in China.
That&rsquo;s a necessary prerequisite for beautiful design.
<a href="https://signalvnoise.com/posts/2710-designed-by-apple-in-california">Designed in Cupertino</a> assembled in China.
<a href="https://signalvnoise.com/posts/2710-designed-by-apple-in-california">Designed in Cupertino</a>, assembled in China.
So let&rsquo;s try to assemble our machine in Palo Alto.<a href="#fnref:12" rev="footnote">&#8617;</a></li>
</ol>
</div>
Expand Down
10 changes: 5 additions & 5 deletions 10_binary_counter.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ but the book called ["Alice's Adventures in Wonderland"][alice-in-wonderland].
If you haven't read it, do[^alice-free-ebook].
No person should be hired ever unless they read "Alice in Wonderland".
In any case, he was also a mathematician.
He also dabbled in all kind of games
apparently he invented Scrabble and a bunch of other games[^inventor-of-scrabble].
He also dabbled in all kind of games.
Apparently he invented Scrabble and a bunch of other games[^inventor-of-scrabble].

At some point he decided that there is a clear problem with lawn tennis tournaments.
He observed that with a very high probability,
Expand All @@ -30,7 +30,7 @@ But he wanted to come up with an algorithm
which assures that the second-placed guy is truly the second best player.
He published it in 1883[^lawn-tennis-article].
The algorithm wasn't quite an algorithm[^not-an-algorithm] and it was clearly not optimal.
It took 15 more years before the problem was stated correctly.
It took 50 more years before the problem was stated correctly.
People realized that you could talk about the minimum
number of comparisons but it took another thirty years, until 1964 when a
Russian mathematician [Sergei S. Kislitsyn][sergei] published a paper which
Expand Down Expand Up @@ -190,7 +190,7 @@ Right now `min_element` plays a tree structure that looks like this:
/\

It has `n - 1` internal nodes.
But we don't want the min to do `n - 1` comparisons.
But we don't want the winning element to do `n - 1` comparisons.
We need to transform that into the way they play tennis tournaments.
We need to balance the tree.

Expand All @@ -205,7 +205,7 @@ How do we do it?
One way is to just pair up elements and build up.
But then we need lots of memory to save the intermediate results[^early-ref-to-inplace].
Note that once a bottom-level round has been played, they are ready to move up.
Our goal is to basically to become eager.
Our goal is basically to become eager.
Whenever elements are ready to be paired together, we want to pair them.
So if we store only the winner at each level, we never need to store `log(n)` things.
We can define the **power** of each element
Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.