Computing Reviews
Today's Issue Hot Topics Search Browse Recommended My Account Log In
Review Help
Search
Python algorithms : mastering basic algorithms in the Python language (2nd ed.)
Hetland M., Apress, New York, NY, 2014. 320 pp. Type: Book (978-1-484200-56-8)
Date Reviewed: Mar 12 2015

Subject to the caution mentioned at the end of this review, I would use the earlier parts of this book to teach algorithms to a computer science introductory course using Python. The whole book would be a great support for an algorithms theme in the curriculum.

What are the main advantages of this book?

(1) It is written for Python, as opposed to just being the Python dialect of a generic algorithms text. It makes use of powerful Python features such as the dict structure, but is careful to explain from the start that Python constructs are not all of equal cost. Indeed, the motivational section “Why Are You Here?” at the start of the book dissects two apparently identical pieces of code, showing that one is O(n) and the other is O(n2) because one is using an amortized (which is explained later on) O(1) Python construct and the other an O(formula>n) construct. This use of Python makes for pedagogic simplicity: for example, because a map data structure is used, Kruskal’s algorithm fits on half a page (Listing 7-4).
(2) It makes serious use of the O/Ω/Θ family of notations, and does so properly in the sense that O and Ω are defined as sets of functions, Θ(f) is defined as O(F)∩Ω(f), and set membership is used rather than the equals sign.
(3) Throughout, the book makes a strong connection between recursive programs and inductive proofs. It is also good at presenting both recursive and nonrecursive solutions where appropriate. As an example, having already introduced memoization, the author presents an efficient recursive solution to the unbounded knapsack in ten lines, and then an iterative version in nine lines. There is an interesting synergy here: correctness is easier to see from the recursive version, but complexity is easier from the iterative version.
(4) There are good analogies and informal explanations. On the algorithmic front, I particularly liked the one explaining breadth-first/depth-first search via browsers (p. 108), and the explanation of reduction (p. 228) is one I will certainly borrow.

On the negative side, the text makes several references to sidebars, which aren’t actual sidebars in the sense of being placed alongside, but are quite long, sometimes multi-page, articles set in the same font as the main text. I eventually got used to this, but it disrupted reading initially.

The biggest problem, though, is the numerous typographical errors in the formulae, including generally not placing symbols as subscript/superscript. In Table 2-1 (p. 14), O(nk) should be O(nk) and Ω(kn) should be Ω(kn). Unless this is mentally corrected every time one uses the table, this reference table is badly misleading. At the bottom of the same page, O(2n) should be contrasted with O(n100), not O(2n). The same problem occurs in Table 3-1 (p. 56), where 2n should be 2n. Hence, if I were to use this book for teaching, I would need to issue a far more serious list of corrections than usual.

Reviewer:  J. H. Davenport Review #: CR143237 (1506-0444)
Bookmark and Share
  Reviewer Selected
Featured Reviewer
 
 
Python (D.3.2 ... )
 
 
General (F.2.0 )
 
Would you recommend this review?
yes
no
Other reviews under "Python": Date
Practical Python
Hetland M., APress, LP, 2002.  648, Type: Book (9781590590065)
Mar 28 2003
Python programming: an introduction to computer science
Zelle J., Franklin B, 2003. Type: Book (9781887902991)
Dec 2 2004
Foundations of Python network programming
Goerzen J., APress, LP, Berkeley, CA, 2004.  512, Type: Book (9781590593714)
Dec 26 2004
more...

E-Mail This Printer-Friendly
Send Your Comments
Contact Us
Reproduction in whole or in part without permission is prohibited.   Copyright 1999-2024 ThinkLoud®
Terms of Use
| Privacy Policy