Retidy, removing align=left from headings and empty paragraphs

This commit is contained in:
James Gregory 2013-12-30 15:37:13 +11:00
commit a96a114403
362 changed files with 8472 additions and 5040 deletions

View file

@ -1,5 +1,4 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
@ -19,17 +18,21 @@
<center>
<table border="1">
<tr>
<td><a href="59-04.html">Previous</a></td>
<td>
<a href="59-04.html">Previous</a>
</td>
<td><a href="index.html">Table of Contents</a></td>
<td>
<a href="index.html">Table of Contents</a>
</td>
<td><a href="59-06.html">Next</a></td>
<td>
<a href="59-06.html">Next</a>
</td>
</tr>
</table>
</center>
<p><br /></p>
<p>Take a few minutes to look over Listing 59.4 and relate it to Listing 59.2. The structure is different, but upon examination it becomes clear that both listings reflect the same underlying model: For each node, visit the left subtree, visit the node, visit the right subtree. And although Listing 59.4 is longer, that&rsquo;s mostly because I commented it heavily to make sure its workings are understood; there are only 13 lines that actually do anything in Listing 59.4.</p>
<p>Let&rsquo;s look at it another way. All the code in Listing 59.2 does is say: &ldquo;Here I am at a node. First I&rsquo;ll visit the left subtree if there is one, then I&rsquo;ll visit this node, then I&rsquo;ll visit the right subtree if there is one. While I&rsquo;m visiting the left subtree, I&rsquo;ll just push a marker on a stack that tells me to come back here when the left subtree is done. If, after visiting a node, there are no right children to visit and nothing left on the stack, I&rsquo;m finished. The code does this at each node&mdash;and that&rsquo;s <i>all</i> it does. That&rsquo;s all Listing 59.4 does, too, but people tend to get tangled up in pushes and pops and <b>while</b> loops when they use data recursion. When the implementation model changes to one with which they are unfamiliar, they abandon the perfectly good model they used before and try to rederive it in the new context by the seat of their pants.</p>
@ -48,7 +51,7 @@
</tr>
</table>
<h4 align="left" id="Heading10">Measure and Learn</h4>
<h4 id="Heading10">Measure and Learn</h4>
<p>How much difference does all this fuss make, anyway? Listing 59.5 is a sample program that builds a tree, then calls <b>WalkTree</b> () to walk it 1,000 times, and times how long this takes. Using 32-bit Visual C<small>++</small> 1.10 running on Windows NT, with default optimization selected, Listing 59.5 reports that Listing 59.4 is about 20 percent faster than Listing 59.2 on a 486/33, a reasonable return for a little code rearrangement, especially when you consider that the speedup is diluted by calling the <b>Visit()</b> function and by the cache miss that happens on virtually every node access. (Listing 59.5 builds a rather unique tree, one in which every node has exactly two children. Different sorts of trees can and do produce different performance results. Always know what you&rsquo;re measuring!)</p>
@ -123,16 +126,20 @@ void Visit(NODE *pNode)
</pre>
<p><br /></p>
<center>
<table border="1">
<tr>
<td><a href="59-04.html">Previous</a></td>
<td>
<a href="59-04.html">Previous</a>
</td>
<td><a href="index.html">Table of Contents</a></td>
<td>
<a href="index.html">Table of Contents</a>
</td>
<td><a href="59-06.html">Next</a></td>
<td>
<a href="59-06.html">Next</a>
</td>
</tr>
</table>
</center>