My personal favourite is Sedgewick & Wayne's _Algorithms_.
https://algs4.cs.princeton.edu/home/
You can even find an excellent two-part MOOC on Coursera:
https://www.coursera.org/learn/algorithms-part1
https://www.coursera.org/learn/algorithms-part2
Maybe it's not the "purest" class or book, but it's engaging and it lets you understand how algos work AND how to use them in practice.
If your goal is to be good at LeetCode, then save yourself the time and just go straight to LeetCode. Nobody cares if you actually understand the stuff. They just want you to come in and do the dance (recognize the problem archetype, talk through your thought process for solving it, and adjust based on whatever twists they've thrown in).
If you're interviewing for senior positions, it is worthwhile to read through Designing Data Intensive Systems. This will prepare you for System Design interviews where you do need to actually understand stuff.
Sedgewick's Algorithms [1] is pretty good. I found it way more approachable than CLRS. There's also a free course on Coursera[2] from him.
1. https://www.amazon.com/Algorithms-4th-Robert-Sedgewick/dp/03...
I would recommend Open Data Structures: https://opendatastructures.org/
It's available for free online, or if you'd like you can buy a physical copy. It's got 14 chapters that take you through a variety of data structures, introduces you to the theory behind them, and teaches you the basics of analyzing them.
I've done many of the exercises from this book, and found them useful for learning the topic.
"Algorithms Illuminated" by Roughgarden. Very accessible. Reads like a novel not a textbook. Has exercises throughout the chapter to test knowledge. I recommend it over your suggestion that you want a textbook. This book will serve you much better.
Back when I was in high school I learned all leetcode algorithms from doing programming competitions. One of the books I used was: http://acm.cs.buap.mx/downloads/Programming_Challenges.pdf
What really put me to the next level is this amazing free training program which I still recommend anyone who wants to nail the interviews. It teaches each algorithm and data structure and gives you appropriate challenging exercises so you really understand them: https://train.usaco.org/
"A Common-Sense Guide to Data Structures and Algorithms, 2nd Edition" by Jay Wengrow is one I'd recommend every time. It really makes it easy enough to understand things I previously only considered to be the domain of math-oriented people. Not sure if it goes deep enough for you though...
A great and quite unconventional book on Algorithms is "INTRODUCTION TO ALGORITHMS - A Creative Approach" by Udi Manber. After leaving academia the author was hired first by Amazon (A9.com) and then by Google. At some point around 2010 he was responsible for all search products at Google [0].
The book not only describes the algorithms per se, but also teaches how to think about the algorithms and the problems they are solving. I enjoyed it very much as a complimentary reading to the classic Knuth volumes.
> I want a book that can go into the details of each specific DS or Algorirhm.
I'm not aware of any book like that. At the uni, the process is repetitive and incremental.
First you learn how to implement the algo, then you learn how to count (discrete math) and, finally, you learn how to analyze its complexity. Concurrently, you might see some more details on how those data structure are used in Operating System and learn how to implement them in some lecture about parallel computing.
MIT has a great resource online. They have recorded lecture, exercises, lecture notes with reading suggestion, etc.
Their intro to algo. https://ocw.mit.edu/courses/electrical-engineering-and-compu...
Also, see what it the reading for similar lectures on other universities.
"Foundations of Computer Science" by Aho and Ullman is an excellent book and freely available:
I read CLRS in the fashion you described, mostly cover to cover, as a textbook with exercises. I found it extremely helpful. It gives both intuitive and mathematical proofs for each of the algorithms and data structures.
In case you want to go for something aimed at competitive programming have a look at the "Competitive Programmer’s Handbook" https://cses.fi/book/book.pdf
There are literally hundreds of threads with this topic on the Web. Most of them contain the same standard references which IMO are not always the best for people without much mathematical maturity and wishing to learn from first principles. That said, here are my recommendations for them (pdfs of almost all are available online and they can also be purchased cheaply as used books);
* 1) Functions and Graphs and 2) The Method of Coordinates by I.M.Gelfand et. al. - These give you the basics on functions and how to visualize them which is crucial for understanding.
* Introductory Logic and Sets for Computer Scientists by Nimal Nissanke - Nice succinct introduction to various required topics for Comp. Sci.
* Compared To What?: Introduction to the Analysis of Algorithms by Gregory Rawlins - This is a classic book which takes you by hand and walks you through Algorithm Analysis and the reqd. mathematics. You will find this more approachable than most other text books and well worth a study.
* How to Think about Algorithms by Jeff Edmonds - Practical techniques without too much mathematical formalism.
* Data Structure Techniques by Thomas Standish - A Classic text; good adjunct to more modern texts.
* Advanced Data Structures by Peter Brass - Nice succinct text but not necessarily "advanced".
One final point; try to get a Algorithms and Data Structures book with code in the language with which you are most familiar. That way you understand the mapping from "Abstract Algorithm" to "Concrete Language Implementation" which is not always trivial.
If you want basics and details, the art of computer programming is a good candidate.
Unfortunately, it isn’t done yet (1), and the completed parts have are very basic and have parts that are a bit dated (multi-tape sorting, for example)
(1) and likely never will be. Knuth is turning 84 in two months, and isn’t even halfway writing it, after almost 60 years
Yes there’s lots of algorithm books! Too many to learn them all. I had an anxiety attack and bought most of the introductory algo books mentioned in CLRS chapter 1.
I liked ALGS4 by Sedgewick as my introduction to Algorithms. I still refer to the Coursera course. I actually started with CLRS and doubled back to ALGS4. I wish I did it in reverse order but it was still useful reading CLRS and refreshing my math skills.
I would say grab a few and see which ones you like. CLRS, ALGS4, Algorithm Design Manual, and Algorithm Design by Kleinberg and Tardos are a good start. You can look in the bibliography of each books for more suggestions from the experts themselves.
Shameless plug: you might want to accompany a book with explained animations of Algorithms and Data Structures: https://www.chrislaux.com
I find the writing style in CLRS to be quite readble. Sure the book is huge but so maybe pick and choose chapters but each chapter can be read "cover to cover". Perhaps some of the stack details you are looking for are left to exercises in CLRS? Most good "textbooks" will do this. Perhaps you don't want a general textbook on data structures but want a deep dive article on stacks.
I admit I haven't explored many other books on this topic but CLRS is very good in my opinion.
> For example a basic Stack is explained in a page and a half or two, for me this is not enough
Why not? It's a simple data structure. What more do you think can be said about it?
I better recommend you to try your hands on code-forces, CP Algorithm etc. If you got stuck in any of the problems just read the discussion and given solution. If you continue this you several months then you quickly learning the data structures and algorithms. Because if you don't apply DSA which you will learn from any book then i guess it doesn't add much value to you. In the beginning problems might not able to solve but after giving time and looking solution you will start getting things. And I guess its just a myth or we can say a phobia that you need to know each and every piece of mathematics.
And I think graph is a data structure that you should be work upon. For this you can refer this book Introduction to Graph Theory Subsequent Edition by Douglas Brent West. This book you can just read and practice while solving problems on above coding problem platforms.
So, I recommend you first do code-forces DIV3, DIV2 problems, gain some confidence, and then pick any DSA book.
Or one thing you can also do just filter out problems related to math,Combinatorics etc.on code-forces and try to solve them. Through this approach you will learn to apply the concepts.
I hope this comment add some value to you! Happy coding.
Im not good at maths but to get my work done this books helped me a lot:
https://www.amazon.de/Problem-Solving-Algorithms-Structures-... If I remember correctly it is Python 2
https://www.amazon.de/Algorithms-Illuminated-Part-1-Basics/d...
https://www.amazon.de/Algorithms-Illuminated-Part-Graph-Stru...
https://www.amazon.de/Algorithms-Illuminated-Part-Dynamic-Pr...
I recommend to start with "Elements of Programming Interviews (in Java or Python)". It serves as a nice practical overview of the main algorithms and data structures and when to use them. Personally I found it more complete than the usually recommended "Cracking the Coding Interview" while being equally approachable.
Truth is, if you want to really learn algorithms and data structures, then you are the one who has to "go into the details". CLRS is the bible, I can't think of a better book, and you don't have to read it sequentially because most chapters are independent of each other.
It really depends. It is a bit difficult to answer this question without understanding your background first. What CS lectures have you already taken? What related courses (e.g., math) have you done?
For example, the Stack data structure that you bring into discussion is quite simple (but interesting and important), so I am not surprised it is treated speedily. Introduction to Algorithms typically has more difficult content.
Depending on this, I could recommend for example that you follow the lectures on the excellent MIT OCW YouTube channel (https://www.youtube.com/c/mitocw). But you could also do one of the numerous algorithms and data structures courses on coursera/edx. It all depends on what you know so far and what your goal is.
I visited a friend a while ago and she was reading this amazing book on her tablet, "The AgloDaily Book: Core Essentials"
https://algodaily.gumroad.com/l/yYEqr
I really loved its illustrations; it looks so easy to follow.
I’m in the initial phase of structuring a book that aims to teach some simple algorithms and data structures using Python. The idea is that the reader should do the (guided) exercises to learn how to build those data structures. It’s basically “learn by doing”.
For instance, to teach what a stack is I’ll explain the basic idea of a stack, then provide a base class and the reader must implement each method (init, push, pop, peek, etc) given the requirements and intended results of each functionality.
I already have a kind-of “learn by doing” ebook about Python (https://github.com/joaoventura/full-speed-python), so it’s like a follow-up to that one.
Don’t know if people are interested in a book like this, though..
I usually don't complete online courses(I get bored watching educational videos) except for one. This course is on data structures and is conducted by University of California, San Diego. It is available both on edX[0] and Stepik[1]. The reason this online course is so engaging is because it uses the active-learning way of teaching. I was surprised how well that technique worked!
[0] https://www.edx.org/course/data-structures-an-active-learnin...
CLRS does about 5 pages on linked lists. If you want more, my advice would be to implement one in your language of choice, then look at the API for the standard lib impl of a linked list in your language of choice (if there is one).
Otherwise, for more reading on linked lists, read through adlist.c from redis, by antirez.
Next, one of the best books (IMO) on algorithmic thinking is SICP. Get through a few chapters, do the exercises, grok recursion, etc.
In no particular order:
Algorithm Design Manual, Skiena
Algorithm Design, by Kleinberg/Tardos
Algorithms, Sedgwick 4th ed. (also Algorithms in C)
If you find you need or would like more math:
Discrete Mathematics (Epp is an easier read, Rosen seems more verbose)
Mathematical Proofs, Charrand
For interview prep:
Elements of Programming Interviews (EPI)
Designing Data Intensive Applications
I'm only a student, but I personally really liked https://jeffe.cs.illinois.edu/teaching/algorithms/
This is better for more advanced topics, like dynamic programming (well, advanced for me, anyway). I started out taking over an hour to solve the first problem in the problem sets, but they build on each other slowly, so I was soon able to see solutions within minutes. It took me a weekend to go through chapters I was struggling with, and I did really well on my coding interview the next day.
CLRS is pretty accessible for beginners, at least as far as computer science textbooks go.
Perhaps you would benefit from pairing it with a MOOC like MIT's Introduction to Algorithms. https://ocw.mit.edu/courses/electrical-engineering-and-compu...
Are they any algorithms books that don't use data structures backed by linked lists but rather arrays or vectors? Linked data structures are barely used in practice. It can take a student weeks to go through Linked Lists and data structures using them, just to find that they're hardly ever used in practice. Contiguous data structures are the dominant types used today.
Not a book but I've been working on a project that sounds like it might be what you're looking for. It's algos and data structures courses in code-along style. It's free to audit, so do check it out even if you aren't interested in the certification stuff :)
Best I can offer is for data structure think about working backwards if possible.
Every time I've been involved in projects using 10TB+ data it's the processing that tends to expose the most bottlenecks. Nothing competes with making a pseudo dataset about 5%-10% of the size and running benchmarks which roughly match your expected workflow.
Good luck
For algorithms, I can't think of a book better than CLRS, honestly, unless you want to read The Art of Computer Programming by Knuth. For data structures, a great book with a huge amount of detail is Data Structures Using C and C++ by Langsam and Tanenbaum.
"Foundations of Computer Science" by Aho and Ullman is my personal favourite.
just move on to leetcode. you just memorize the bullshit questions and their answers. that is what everyone seems to be doing. actual experience makes no difference. you have 2 minutes to produce the exact answer expected.
Algorithms in a nutshell by George T. Heineman helped me a lot. It's not too dense so it's easy to read, just enough to learn and understand how an algorithm works.
I had "walls and mirrors". Recently I met someone who said that was the only book they kept from uni.
I can't say if it is good or not, I lost mine well over a decade ago.
Segwick's book is far more useful in self-learning environment than other text books. He has videos and fully functioning code to help you understand.
Introduction to Algorithms -Thomas H. Cormen
Grokking Algorithms -Aditya Bhargava
Cracking the Coding Interview Book by Gayle Laakmann McDowell
in case you want to code along, Ive been through some of the books mentioned here and solved the algorithms. You can check it out at https://github.com/realpacific/algorithms
The good thing about Algorithm Design & Analysis as a topic is that there is no lack of great resources to learn from! And even better, a large portion of them are freely available online (in forms of lecture notes, or entire books, video lectures, programming challenges with online judging, etc).
In addition to what others have mentioned, here are some example resources you might prefer for a beginner-intermediate level intro:
1. (free online) Algorithms by Dasgupta, Papadimitriou, and Vazirani http://algorithmics.lsi.upc.edu/docs/Dasgupta-Papadimitriou-...
2. (free online) Algorithms by Jeff Erickson https://jeffe.cs.illinois.edu/teaching/algorithms/
3. Algorithm design by Kleinberg & Tardos https://www.amazon.com/Algorithm-Design-Jon-Kleinberg/dp/032...
4. Another one specifically for more applied view (esp., how they are used in programming contests such as ICPC) is Skiena & Revilla's "Programming Challenges" book (https://www.amazon.com/Programming-Challenges-Contest-Traini...). Note that this is different than Skiena's other popular book (Algorithm Design manual) which is also pretty good and has a "war story" based perspective to design of algorithms.
5. There are also several resources where lecture notes from university Algorithm & DS courses are very useful. Here is an example from my previous Professor, David Kempe: http://david-kempe.com/teaching/DataStructures.pdf
6. Several programming competition specific tutorials can be found on Topcoder: https://www.topcoder.com/thrive/tracks?track=Competitive%20P... (individual SRM archives are also good place to try problems first hand and then learn from other's approach). In general, if you search for ACM-ICPC resources, you will find a lot more targeted information/problems which will apply not only for leetcode, but also for detailed understanding of the theory too.
CLRS is what I used in college
The Art of computer programming by Donald Knuth.
I like:
algorithms.wtf
Algorithms by Jeff Erickson
tl;dr: No
The Algorithm Design Manual by Steven Skiena
Amazing book. Very readable. I highly recommend it. The book has a section call "War story" at the end of each chapter in which Skiena shares his real life experience of when the contents from that particular chapter came in handy for him.
Go through it. You won't regret
https://www.amazon.com/Algorithm-Design-Manual-Steven-Skiena...