Unless I wrote, or I am supporting the code your are referring to,
I do not have the resources to answer such questions.
The book contains excellent advice on dealing with code that is difficult to understand,
try to apply it.
Please first have a look on the errata page to see
if this is a known and documented error.
If it isn't, you might have found a new one.
Please drop me a line with a short description of the error,
the page number, and the book's printing number
(shown on the bottom of the fourth page).
If this is an error in the text I wrote, I will probably add it in the
errata page with a reference to your name (unless you ask for your contribution
to remain anonynous).
Errors in the open source code examples also interest me, but do not go
in the errata page; I might include a note in a subsequent edition.
The
GNU General Public License
is associated with the code's copyright.
Copyright protects the expression of an idea, not the idea itsself.
Thus, using a variable name appearing in GPLed code one has read could
be problematic, but adopting a design used in GPLed code in new
code one creates should be ok.
In addition,
none of the code appearing in the book is GPLed. I have used code licensed
under BSD and similar licenses,
to avoid problems with intepreting the GPL and its requirements.
Disclaimer: I am not a lawyer, and this is not legal advice.
The code in the book's CD-ROM is there to give you the full
context of the more than 600 examples that point to it.
Compiling the code was tricky for me in the cases I had to do it,
and will probably will also be tricky for you,
because systems move forward and render older versions incompatible
with modern compilers, header files, tools, and libraries.
The best option is to download a modern copy of the corresponding
system, and follow the compilation and installation instructions
that come with it.
More details of the question follow.
In section 2.11 you show the correctness of the binary search algorithm.
On page 59, just after the sentence ``When lim is decremented by one at
Figure 2.12:5 we substitute lim + 1 in our invariant to obtain'', there
are three equivalences, the last of which doesn't hold:
R ∈ [ base : base - (lim+1)/2 - 1 + lim + 1 ) ≡
R ∈ [ base : base + lim - (lim+1)/2 ) ≡
R ∈ [ base : base + lim/2 )
Answer: in integer arithmetic
1/2 = 0
and therefore it can be omitted.
Jukka Salmi suggested to add an additional equivalence to make things
clearer:
R ∈ [ base : base - (lim+1)/2 - 1 + lim + 1 ) ≡
R ∈ [ base : base + lim - (lim+1)/2 ) ≡
R ∈ [ base : base + lim/2 -1/2 ) ≡
R ∈ [ base : base + lim/2 )
See my personal FAQ list, and if that fails
to answer your question
send me an email with a concise description of
your question.
Keep in mind that I receive more than a hundred messages every day,
so I may take some time to answer to your message.
Book homepage | Author homepage
(C) Copyright 2000-2009 D. Spinellis.
May be freely uploaded by WWW viewers and similar programs.
All other rights reserved.
Last modified: 2009-01-02