Saturday, July 29, 2017

Data Structure and Algorithms books are often taught as textbooks in various universities, colleges, and Computer Science degree courses, yet, when you put programmers in a situation, where they need to find and decide, which data structures and algorithms to use to solve a problem, they struggle. I have seen this, and I think one reason for this is perspective. When you read something as a textbook and your perspective is just to do well in the exam, you might not be thinking about learning and applying that knowledge to real-world problems. Since data structures and algorithms are the core of any programming problem, it becomes extremely important for programmers to master them even if you have learned well during academics.
In this article, I am sharing five of my favorite books on data structures and algorithms, which I think are a great read and can help every programmer to master data structure and algorithms.

I have chosen these books because of different reasons. Some books are really easy to read and their focus is aligned to my expectation, some of them are really comprehensive and can be used as reference material, and few of them offers different perspective of using data structures and algorithms e.g. while solving a real world problem or helping to crack interviews at Google, Amazon, Microsoft or Facebook.

It's hard to judge your knowledge of data structure and algorithms by knowledge based questions because that's not how they are used in a project. It doesn't help to know about every single detail of a Car if you can't even drive.

These data structure and algorithms books have helped me to find and fill in gaps and taught me a lot of things about different data structures e.g. stacks, queues, linked list, arrays, hash tables, heaps, trees, and graph. If you are using a different data structure and algorithm book, which is good and not on this list, you can share with us.

Top 5 Data Structure and Algorithm Books

Here is my list of some of the good books to learn data structure and algorithm. Since both data structure and algorithm are both languages independent, but I suggest you pick a book which has an example in your preferred language e.g. C, C++, Java or Python. You should also try to implement and use those data structure by your own e.g. writing your NAry tree to hold hierarchical data, writing your own hash table even though you have HashMap in Java. Ok, now let's see my favorite algorithm and data structure books:

This is one of the best books on Computer Algorithms, it's written by four authors, one of them is Thomas H. Cormen, whose another book Unlocked Algorithm is also the most recommended book to learn algorithms. This book is a lot more comprehensive and covers lots of different algorithm and advanced problem-solving technique e.g. greedy algorithms, dynamic programming, Amortized Analysis, along with elementary data structures like Stacks and Queues, Array and linked list, Hash tables, Tree, and Graph. This book is a unique combination of completeness and rigorous. Another good thing about this book is that algorithms are explained in English, and in pseudo code, which can be understood by even programmers, who has just started programming. It's equally useful for all kinds of programmers e.g. senior, experienced and freshers and in all kind of programming language e.g. Java, C or C++. One of the must-reads books on Algorithms for software programmers and developers.

Algorithms are complex and hard to understand, even for a computer science graduate. Any book, which makes a readable attempt of the algorithm, by associating with real worth things, does a huge favor for its reader. Algorithm Unlocked is one of such book, which presents some of the widely known computer algorithms in the field of finding the shortest path, searching and sorting algorithms, String related algorithms, cryptography and data compression algorithms and some interesting problems. This book is one of the most engaging and readable books on the topic of algorithms and worth of every penny spent on it. Only thing, I found this book lacks is that it only covers Algorithms and not data structures, as it can not be used as a reference book. It's the best to use is as a companion, along with a much more comprehensive book on data structures and algorithms.

This is another data structure and algorithm book, which scores well on readability and practical usefulness. I particularly like its clean, clear and concise explanation; followed by real world use case and then lots of problems to master a particular data structure or algorithm. Only thing, which is not per my convenience was its examples, which are written in C programming language. If you can easily manage that then it's a very good book to learn data structure. In fact, this encouraged me to write my own implementation in Java while going through it, which certainly helps in long run. Remember, getting an objective feel of what is data structure, how does it work is quite different than implementing same data structure by yourself, and then trying different things e.g. finding cycles in linked list or finding middle node of linked list in single pass, is a good exercise after you implemented linked list data structure in Java. Combining back to the book, you can certainly buy this book on readability, clear and concise explanation and, more importantly, nontrivial examples. One of the best book to learn data structure and algorithms for beginners.

This is another conventional book on Algorithms and Data structures. Two things, which I liked about this books are, examples are given in my favorite Java programming language and you can use this book as a reference for learning data structures like stack, queue, linked list, tree or graph. The good thing about this book is that if not only focuses on data structures and algorithms but also on Java, which makes it an ideal choice for Java programmers. Though it doesn't cover a lot of algorithms, it did cover algorithms related to directed and cyclic graphs, minimum spanning trees and comes up with a lot of exercises for practice. Not the best, but a good book to learn algorithm and data structure in Java.

Algorithms for Interviews is quite different than previous books on data structures and algorithms. It offers a different perspective of designing and using algorithms by applying them to different interview questions. If you are preparing for software engineer interviews at Google, Microsoft, Amazon or Facebook, you can expect a lot of questions from the data structure and algorithms, and this book helps a lot. I liked this book because I learned a lot of things, which I haven't learned by following conventional books on data structures and algorithms. It's not a textbook, neither a comprehensive guide of algorithms, but it's worth reading to improve your understanding of algorithm and problem-solving skills. It definitely deserves a place on the bookshelf of a programmer, who like to learn from other's experience.

That's all on my list of must read books data structures and algorithms. This list is equally useful to both Java and C, C++ programmers, or better any programmer because it's a common programming concept and used in all kind of projects, written in different programming languages. At least one book on data structures and algorithms must always be on a programmers self, along with some timeless classic like Clean Code and Effective Java.

Thanks for reading this article so far. If you like this article then please share with your friends and colleagues. If you have any question or doubt then please let us know and I'll try to find an answer for you.