Programming Books C Java PHP Python Learn more Browse Programming Books

Sorry, this item is not available in
Image not available for
Image not available

To view this video download Flash Player


Sign in to turn on 1-Click ordering
Sell Us Your Item
For a $19.93 Gift Card
Trade in
More Buying Choices
Have one to sell? Sell yours here
Start reading Python Algorithms on your Kindle in under a minute.

Don't have a Kindle? Get your Kindle here, or download a FREE Kindle Reading App.

Python Algorithms: Mastering Basic Algorithms in the Python Language (Expert's Voice in Open Source) [Paperback]

by Magnus Lie Hetland
3.5 out of 5 stars  See all reviews (10 customer reviews)

Buy New
$40.20 & FREE Shipping. Details
In Stock.
Ships from and sold by Gift-wrap available.
In Stock.
Rented by RentU and Fulfilled by Amazon.
Want it Monday, April 28? Choose Two-Day Shipping at checkout. Details
Free Two-Day Shipping for College Students with Amazon Student


Amazon Price New from Used from
Kindle Edition $25.49  
Paperback $40.20  
Shop the new
New! Introducing the, a hub for Software Developers and Architects, Networking Administrators, TPMs, and other technology professionals to find highly-rated and highly-relevant career resources. Shop books on programming and big data, or read this week's blog posts by authors and thought-leaders in the tech industry. > Shop now

Book Description

November 22, 2010 1430232374 978-1430232377 1

Python Algorithms explains the Python approach to algorithm analysis and design. Written by Magnus Lie Hetland, author of Beginning Python, this book is sharply focused on classical algorithms, but it also gives a solid understanding of fundamental algorithmic problem-solving techniques.  

  • The book deals with some of the most important and challenging areas of programming and computer science, but in a highly pedagogic and readable manner.
  • The book covers both algorithmic theory and programming practice, demonstrating how theory is reflected in real Python programs.
  • Well-known algorithms and data structures that are built into the Python language are explained, and the user is shown how to implement and evaluate others himself.

What you’ll learn

  • Transform new problems to well-known algorithmic problems with efficient solutions, or show that the problems belong to classes of problems thought not to be efficiently solvable.
  • Analyze algorithms and Python programs both using mathematical tools and basic experiments and benchmarks.
  • Prove correctness, optimality, or bounds on approximation error for Python programs and their underlying algorithms.
  • Understand several classical algorithms and data structures in depth, and be able to implement these efficiently in Python.
  • Design and implement new algorithms for new problems, using time-tested design principles and techniques.
  • Speed up implementations, using a plethora of tools for high-performance computing in Python.

Who this book is for

The book is intended for Python programmers who need to learn about algorithmic problem-solving, or who need a refresher. Students of computer science, or similar programming-related topics, such as bioinformatics, may also find the book to be quite useful.

Table of Contents

  1. Introduction
  2. The Basics
  3. Counting 101
  4. Induction and Recursion ... and Reduction
  5. Traversal: The Skeleton Key of Algorithmics
  6. Divide, Combine, and Conquer
  7. Greed Is Good? Prove It!
  8. Tangled Dependencies and Memoization
  9. From A to B with Edsger and Friends
  10. Matchings, Cuts, and Flows
  11. Hard Problems and (Limited) Sloppiness

Frequently Bought Together

Python Algorithms: Mastering Basic Algorithms in the Python Language (Expert's Voice in Open Source) + Foundations of Python Network Programming: The comprehensive guide to building network applications with Python (Books for Professionals by Professionals) + The Python Standard Library by Example (Developer's Library)
Price for all three: $111.36

Buy the selected items together

Editorial Reviews

About the Author

Magnus Lie Hetland is an experienced Python programmer, having used the language since the late 1990s. He is also an associate professor of algorithms at the Norwegian University of Science and Technology, having taught algorithms for the better part of a decade. Hetland is the author of Practical Python and Beginning Python, first and second editions, as well as several scientific papers.

Product Details

  • Series: Expert's Voice in Open Source
  • Paperback: 336 pages
  • Publisher: Apress; 1 edition (November 22, 2010)
  • Language: English
  • ISBN-10: 1430232374
  • ISBN-13: 978-1430232377
  • Product Dimensions: 9.2 x 7.5 x 0.8 inches
  • Shipping Weight: 1.9 pounds (View shipping rates and policies)
  • Average Customer Review: 3.5 out of 5 stars  See all reviews (10 customer reviews)
  • Amazon Best Sellers Rank: #263,814 in Books (See Top 100 in Books)

More About the Author

Discover books, learn about writers, read author blogs, and more.

Customer Reviews

Most Helpful Customer Reviews
29 of 30 people found the following review helpful
4.0 out of 5 stars Very good explanation of basic algorithms December 13, 2010
Format:Paperback|Verified Purchase
- Very clear explanation of a complex subject.
- Each chapter builds upon the previous chapters so that this is more like a class than a reference manual.
- More approachable that the Sedgewick and Cormen.

- The almost constant parenthetical phrases distract from the text and quickly become irritating. After page 20 I just skipped them and found that I understood the concepts more quickly.
- The use of single letter variables in the code examples makes it more difficult to understand the structure of a new concept. When there are several of them, it can become confusing. (See page 207.) Why not just use descriptive variable names?

There are sections that make note of how to implement certain algorithms using Python specific features, and this is very helpful, but this is first and foremost a book on algorithmic theory that happens to use Python for code examples.
Was this review helpful to you?
8 of 9 people found the following review helpful
5.0 out of 5 stars Instructive and Entertaining January 5, 2011
By Mike
I found Python Algorithms not only extremely helpful but an enjoyable read as well, not an easy task for an algorithm book. The text is conversational and well-organized, with numerous side notes that allow the reader to make insightful connections. The author's use of humor is not overwhelming, nor is it so sparse as to confuse novice readers to his intent. His use of sidebars can bog down the topics at times, but this has the advantage of making this text appropriate for readers of all skill levels.

The author also takes great pains to explain Python code within the book, which not only models well-written code to the reader but also takes advantage of eliminating pseudo-code with concrete examples of the Python language. The use of citations and notes on external sources within the book made it possible for me to independently research topics on the web. For more hands-on learners, there are exercises at the end of each chapter. This text could easily be the basis for a college-level class on Python and algorithm theory/development. All in all, a great text and a must-have for the Python programmer!
Comment | 
Was this review helpful to you?
14 of 18 people found the following review helpful
3.0 out of 5 stars It's okay but too chatty. March 24, 2011
This book presents a quite broad range of fundamental computer science
algorithms, with all illustrative code written in Python. There is a
strong emphasis on graph algorithms, perhaps reflecting a predilection
of the author. Since I like graphs too I cannot complain about that.

Beyond the actual implementations, the book aims for extra Python
relevance by including asides on Python internals (CPython, to be
precise). I was pleasantly surprised by the ones included, as they go
beyond the trivial. Given the prevalence of graph algorithms heaps (or
priority queues) had to play a central role, and the aside on Python's
heapq module is perhaps the most important of them. I wish there were
more of the Pythonic asides, though.

Even so, the book makes clear how Python's carefully balanced design
enables beautiful, concise implementations. There is almost no low
level busy-work code, the algorithms practically read themselves. And
they are commented too just in case you find a piece difficult to

There's more to algorithms then the implementations, though: one has to
address correctness proofs and efficiency properties. The book
certainly doesn't neglect these, but if there's one clear downside (for
this reader) it is this: too much English, too few symbols. The author
goes to great lengths to use informal language instead of "math" when
discussing correctness and efficiency, and in the end I think he
overdoes it. Here's an example from Chapter 7, on greedy algorithms,
discussing the scheduling problem with hard deadlines, discrete time
and tasks of equal length:

"The last question then becomes, does S' have the same profit as S?
Read more ›
Comment | 
Was this review helpful to you?
7 of 9 people found the following review helpful
Python Algorithms is of the same level as the book Pro Python by Marty Alchin,
also by Apress. So warning: this is not for beginners. Especially if you are
just starting with both Python and algorithms. Experienced algorists would
probably find their way through the book though.

So much for apologies, to use Dijsktra's words. This has been my hardest Apress
so far and second reading is in order. Oh and next time, I won't be skipping
the exercices. I advise you do the same. Some are very necessary if you want to
have a good grasp of all the algorithms covered.

Professor and author Magnus Lie Hetland is an experienced algorist and Python
coder. He promises in Chapter 1 (Introduction) to make you master basic
algorithms with Python and teach you how to create new ones. *cough* I think I
missed that latter part in the book. I only gathered that we can transform few
basic algorithms and apply them to new problems, especially graph algorithms.

It is thus important that you dont skip Chapter 5 (Traversal: The Skeleton Key
of Algorithmics) where I think the basics are found. No really, you don't want
to skip it. And while we are at it, you don't want to skip Chapter 4 (Induction
and Recursion... and Reduction) either. The idea of using reduction when
solving new problems is discussed in full in that chapter.

The last chapter I want to mention is Chapter 11 [Hard Problems and (Limited)
Sloppiness]. Weird but important terms used by experienced algorists are
discussed. I am talking about: solvable, tractable, P, NP, NPC, NP-hard, SAT,

The chapters I have not mentioned were difficult for me to understand. I wont
say more about them.
Read more ›
Comment | 
Was this review helpful to you?
Most Recent Customer Reviews
2.0 out of 5 stars Really Needs Clean Programming Style
While this author presents very interesting topics, following along with coding is particularly difficult. His coding style is very difficult to follow. Read more
Published 10 months ago by Cecil McGregor
2.0 out of 5 stars way, way too verbose, and then skips the real point
This is probably the most verbose book in Computer Science I have ever read. What annoyed me about the writing style is that the book keeps talking and talking and going around the... Read more
Published 23 months ago by peluk
1.0 out of 5 stars Very poor Kindle version
I have the iPad kindle version. It's a mess. No Kindle menu table of contents (though you can bookmark the TOC page), and more importantly, many listings are hopelessly scrambled... Read more
Published on November 13, 2011 by Reeftide
5.0 out of 5 stars Excellent Book, but it is not a Beginners Book
As a self taught python programmer, I purchased this book in hopes of fleshing out my knowledge of Algorithms.
There are tons of very important concepts covered in this book. Read more
Published on August 27, 2011 by dm03514
4.0 out of 5 stars Very good book - that gives a good overview of algorithms using Python
This is a very good and refreshing book - that brings together Algorithms and Python programming together very well. Read more
Published on June 5, 2011 by Sumit Pal
4.0 out of 5 stars Good reference book for algorithms
This book basically is for study on "algorithms". It has very rich
Examples of advanced study on algorithms that a reader can learn. Read more
Published on December 2, 2010 by Michael C
Search Customer Reviews
Only search this product's reviews


There are no discussions about this product yet.
Be the first to discuss this product with the community.
Start a new discussion
First post:
Prompts for sign-in

Look for Similar Items by Category