Friday, May 16, 2014

Book review of Python Algorithms: Mastering Basic Algorithms in the Python Language


Disclaimer 
I have absolutely no connection to the author/publisher and have no stakes in the financial success of the book.
The book happens to lie intersection of two of my interest areas and the book itself is interesting, hence this post.

A review of Python Algorithms


Don't worry! It's not a new book. Neither is the topic covered precisely bleeding edge. This beauty should have been named Miss Algorithms in the year 2010 but for some reason managed to dodge most literary radars. Let's give it another shot!
I happened to come across a copy of the book on an uneventful Friday evening at a friend's place. As an algorist and a(n ex-)Python enthusiast, it piqued my interest. And I am glad it did. I borrowed the book for a weekend, and ordered my own copy on Monday. The content and the presentation of the content won this book place on my shelf. Alas! I had to retire another book, but let's save constant space book shelf algorithm for some other day.

I have been in constant touch with Python for a decade and with algorithms for better part of two decades now, but still the book proved to be a nice read. I got insights into things which had long 'sunk in' and on which my mind refused to think any more. These algorithms and their explanations were taken for granted and the book's viewpoints were revolutionary to say the least. You can't just fail to follow the explanations for they are in the simplest terms.

First and foremost is the flow of the material presented. The book (like so many others) starts with basics but then does not digress into some archaic topics such as on disk sorting. Topics such as asymptotic complexity are covered to the extent required for a practitioner. I am a big fan of mathematics and mathematical proofs, but when it comes to a practical book on programming, too much math is more of a hindrance than a boon. 

The author does not get lost in the beauty of quick or merge sort, but leads you up to the point of guessing what is about to come, gives the code and makes a clean exit. The representation of trees and graphs can offer a new insight into the simplicity that comes with Python. For data structure enthusiast it may be an eye opener and provide evidence of why Python is an ideal candidate for being a first language.

Chapter 04 on induction, recursion and reduction needs some special mention. I am sure you have known these techniques from the time before you learnt crawling. Trust me, the presentation of reduction techniques is going to be a mind changer and provides you with different view point. This chapter may impact how you approach a new problem.

The chapter on traversal techniques also offers a unique insight into this generally underestimated and ignored area of algorithms. Most often these techniques are usually presented along with the relevant data structure (tree or graph). Packaging traversal as a technique in itself is in spirit of the iterator design pattern.

Chapter 06 starts the entertaining journey into slightly advanced but well presented techniques - divide and conquer, greedy algorithms and dynamic programming. These three chapters besides discussing techniques, also describe when and why a particular technique cannot be applied. 

Chapter 09 marks the beginning of final leg of the push into algorithms. Matchings, cuts and flows are presented in a pretty matter of fact style. NP-completeness, approximation algorithms and some well known hard problems are discussed in the last chapter.

The book has some pretty interesting sidebars. The information in these sidebars range from intriguing history of Konigsberg to some eye openers such as pseudo polynomilaity of primality testing. References section in each Chapter is also nicely written and does not just give you a list of more literature but also gives you a context and what to expect in the reference.

The only downside of the book I can think of is that it is not exhaustive. The author has a chosen a few topics, which he possibly considered important and has done justice to those topics. A longer book would perhaps have been scary and I wouldn't have touched it on a sleepy weekend. The book is short and sweet - around 300 pages. Doesn't even come close to the ground covered in, say CLR or Sedgewick or Horowitz or even Drozdek, but then this is like comparing pumpkins and grapes. 



Overall - 4.99 out of 5.
Go buy your copy now, you won't regret. Even if you know all the topics covered, it still makes a nice read. It isn't pricey either. Check it out at amazon.com 




UPDATE: While returning the book I asked the friend why he had purchased the book and his reply gave another perspective. He said this book makes an ideal answer for the usual interview question - Which was the last book you read? The topics covered in the book are evergreen and the material covered in the book is one which you are never likely to forget.

1 comment:

  1. Thanks for sharing those useful basic programming information, it helps me a lot to explore my knowledge in programming...if you want to switch your career in developing area you should know the basic of programmings for that you have to learn python, it was the first programming language.
    Regards,
    Python Training in Chennai|Python Training

    ReplyDelete