Remove colour attributes from body and strip most of the font tags out
This commit is contained in:
parent
7e957c0bb4
commit
c1f88ddb41
362 changed files with 1632 additions and 1706 deletions
13
15-01.html
13
15-01.html
|
|
@ -24,7 +24,7 @@
|
|||
<!--CHAPTER=15//-->
|
||||
<!--PAGES=279-284//-->
|
||||
<!--UNASSIGNED1//-->
|
||||
<!--UNASSIGNED2//--></HEAD><BODY LINK=#0000FF ALINK=#000099 VLINK=#0000FF BGCOLOR=#FFFFFF>
|
||||
<!--UNASSIGNED2//--></HEAD><body>
|
||||
|
||||
<CENTER>
|
||||
<TABLE BORDER>
|
||||
|
|
@ -36,9 +36,8 @@
|
|||
</TABLE>
|
||||
</CENTER>
|
||||
<P><BR></P>
|
||||
<H2><A NAME="Heading1"></A><FONT COLOR="#000077">Chapter 15<BR>Linked Lists and plain Unintended Challenges
|
||||
</FONT></H2>
|
||||
<H3><A NAME="Heading2"></A><FONT COLOR="#000077">Unfamiliar Problems with Familiar Data Structures</FONT></H3>
|
||||
<H2><A NAME="Heading1"></A>Chapter 15<BR>Linked Lists and plain Unintended Challenges</H2>
|
||||
<H3><A NAME="Heading2"></A>Unfamiliar Problems with Familiar Data Structures</H3>
|
||||
<P>After 21 years, this story still makes me wince. Oh, the humiliations I suffer for your enlightenment....
|
||||
</P>
|
||||
<P>It wasn’t until ninth grade that I had my first real girlfriend. Okay, maybe I was a little socially challenged as a kid, but hey, show me a good programmer who wasn’t; it goes with the territory. Her name was Jeannie Schweigert, and she was about four feet tall, pretty enough, and female—and willing to go out with me, which made her approximately as attractive as Cheryl Tiegs, in my book.</P>
|
||||
|
|
@ -48,7 +47,7 @@
|
|||
<P>I was a pretty mature teenager, so this was only slightly more traumatic than leading the Tournament of Roses parade in my underwear. On the next try, though, I did manage to get the hang of this kissing business, and eventually even went on to have a child. (Not with Jeannie, I might add; the mind boggles at the mess I could have made of <I>that</I> with her.) As it turns out, none of that stuff is particularly difficult; in fact, it’s kind of enjoyable, wink, wink, say no more.</P>
|
||||
<P>When you’re dealing with something new, a little knowledge goes a long way. When it comes to kissing, we have to fumble along the learning curve on our own, but there are all sorts of resources to help speed up the learning process when it comes to programming. The basic mechanisms of programming—searches, sorts, parsing, and the like—are well-understood and superbly well-documented. Treat yourself to a book like <I>Algorithms,</I> by Robert Sedgewick (Addison Wesley), or Knuth’s <I>The Art of Computer Programming</I> series (also from Addison Wesley; and where was Knuth with <I>The Art of Kissing</I> when I needed him?), or practically anything by Jon Bentley, and when you tackle a new area, give yourself a head start. There’s still plenty of room for inventiveness and creativity on your part, but why not apply that energy on top of the knowledge that’s already been gained, instead of reinventing the wheel? I know, reinventing the wheel is just the kind of challenge programmers love—but can you really afford to waste the time? And do you honestly think that you’re so smart that you can out-think Knuth, who’s spent a lifetime at this stuff and happens to be a genius?</P>
|
||||
<P>Maybe you can—but I sure can’t. For example, consider the evolution of my understanding of linked lists.</P>
|
||||
<H3><A NAME="Heading3"></A><FONT COLOR="#000077">Linked Lists</FONT></H3>
|
||||
<H3><A NAME="Heading3"></A>Linked Lists</H3>
|
||||
<P>Linked lists are data structures composed of discrete elements, or nodes, joined together with links. In C, the links are typically pointers. Like all data structures, linked lists have their strengths and their weaknesses. Primary among the strengths are: simplicity; speedy sequential processing; ease and speed of insertion and deletion; the ability to mix nodes of various sizes and types; and the ability to handle variable amounts of data, especially when the total amount of data changes dynamically or is not always known beforehand. Weaknesses include: greater memory requirements than arrays (the pointers take up space); slow non-sequential processing, including finding arbitrary nodes; and an inability to backtrack, unless doubly-linked lists are used. Unfortunately, doubly linked lists need more memory, as well as processing time to maintain the backward links.
|
||||
</P>
|
||||
<P>Linked lists aren’t very good for most types of sorts. Insertion and bubble sorts work fine, but more sophisticated sorts depend on efficient random access, which linked lists don’t provide. Likewise, you wouldn’t want to do a binary search on a linked list. On the other hand, linked lists are ideal for applications where nothing more than sequential access is needed to data that’s always sorted or nearly sorted.</P>
|
||||
|
|
@ -58,7 +57,7 @@
|
|||
<P>The basic concept of a linked list—the one I came up with for that <I>DDJ</I> column—is straightforward, as shown in Figure 15.1. A head pointer points to the first node in the list, which points to the next node, which points to the next, and so on, until the last node in the list is reached (typically denoted by a <B>NULL</B> next-node pointer). Conceptually, nothing could be simpler. From an implementation perspective, however, there are serious flaws with this model.</P>
|
||||
<P>The fundamental problem is that the model of Figure 15.1 unnecessarily complicates link manipulation. In order to delete a node, for example, you must change the preceding node’s <B>NextNode</B> pointer to point to the following node, as shown in Listing 15.1. (Listing 15.2 is the header file LLIST.H, which is <B>#include</B>d by all the linked list listings in this chapter.) Easy enough—unless the preceding node happens to be the head pointer, which doesn’t <I>have</I> a <B>NextNode</B> field, because it’s not a node, so Listing 15.1 won’t work. Cumbersome special code and extra information (a pointer to the head of the list) are required to handle the head-pointer case, as shown in Listing 15.3. (I’ll grant you that if you make the next-node pointer the first field in the <B>LinkNode</B> structure, at offset 0, then you could successfully point to the head pointer and pretend it was a <B>LinkNode</B> structure—but that’s an ugly and potentially dangerous trick, and we’ll see a better approach next.)</P>
|
||||
<P><A NAME="Fig1"><!-- </A><A HREF="javascript:displayWindow('images/15-01.jpg',405,97 )"> --><IMG SRC="images/15-01.jpg"><BR><!-- </A>
|
||||
<BR><A HREF="javascript:displayWindow('images/15-01.jpg',405,97)"> --><FONT COLOR="#000077"><B>Figure 15.1</B></FONT></A> <I>The basic concept of a linked list.</I>
|
||||
<BR><A HREF="javascript:displayWindow('images/15-01.jpg',405,97)"> --><B>Figure 15.1</B></A> <I>The basic concept of a linked list.</I>
|
||||
<P><BR></P>
|
||||
<CENTER>
|
||||
<TABLE BORDER>
|
||||
|
|
@ -72,7 +71,7 @@
|
|||
|
||||
<hr width="90%" size="1" noshade>
|
||||
<div align="center">
|
||||
<font face="Verdana,sans-serif" size="1">Graphics Programming Black Book © 2001 Michael Abrash</font>
|
||||
Graphics Programming Black Book © 2001 Michael Abrash
|
||||
</div>
|
||||
<!-- all of the reference materials (books) have the footer and subfoot reveresed -->
|
||||
<!-- reference_subfoot = footer -->
|
||||
|
|
|
|||
Loading…
Reference in a new issue