11 ms·
50 Algorithms Every Programmer Should Know (Second Edition)
- sidcool 3y agoAgain. Packt publication books are rarely good. Nothing against the author. But I have been time and again disappointed with their content quality. They go for quantity of books over even the basic quality.
- blowski 3y agoIndeed, they do very little work in selecting authors and editing the books, but they still take a big revenue cut. So they tend to attract lower-quality authors. There are a few exceptions but I agree with the general opinion of Packt. They approached me a few years ago to write something, and Leanpub seemed a much more compelling offer.
- rich_sasha 3y agoI have one or two Packt books that are very good. But overall agreed. This seems like a strange mix of "hard" algorithms like sorting or binary search, and ML things like k-means clustering. Not sure who the intended audience is.
- wyclif 3y agoThe intended audience is the legions of people grinding Leetcode and going through our industry's ridiculous interviewing process.
- usrbinbash 3y agoThey would be better served with more focused books however.
- mlrtime 3y agoBetter served pre or post interview? I'd argue they're better served doing leetcode (given finite time) to land the job, THEN reading this book to become better at their job.
- rtaylorgarlock 3y agoI came here to specifically look for this comment, and... well, the rest says a lot about HN ;)
- wyclif 3y agoThat's because Packt, unlike O'Reilly titles, are the shovelware of the programming textbook market. They have a pretty sorry business model. Lots of copypasta-style content slapped up into a book, then sending free copies of the book in exchange for reviews.
- bradley13 3y agoI wondered about that. I just looked at the table of contents, and there is far, far too much stuff in this book. Either it is 2000 pages long (it's not), or it is incredibly superficial.
- zerkten 3y agoThey will take on literally anyone as an author. Authorship gets you kudos in the increasingly large segment of programmer influencers.
- 0RQ2kaTBBlQp 3y agoAny opinion on this specific book?
- W0lf 3y agoJudging from the table of contents it seems that the first half of this book covers basic CS stuff (what is an algorithm, Big O notation, sorting and searching, data structures etc) and then discusses some machine learning basics before looking at the more recent deep learning architectures. I would not buy this book as there are plenty of (better) online resources and even better books IMHO such as the books from Bishop or Marsland.
- lxgr 3y agoI just randomly picked a chapter discussing a topic I'm somewhat familiar with (the one on TLS handshakes), and I'm not impressed with what I'm seeing. I don't think anybody that doesn't already know the basics of TLS would be able to make sense of it as presented there: There's an implicit assumption that an RSA public key is used for key establishment that's never mentioned, and the diagram (which is sloppily drawn too) doesn't help things either. In the end, "a" secret key is used to encrypt something – but the core of TLS key establishment (again, only the RSA variants) is how that key is agreed upon using only the server's public key. That's arguably the entire algorithm here (the rest is protocol negotiation)!
- cengizIO 3y agoDitto. I was asked to write a Rust for Linux book back in 2020. Rust was (and still is) not actually driving any part of the Linux kernel so I kindly refused. They very clearly stated that they are only interested in being the first publisher with a book on this supposedly green field.
- matsemann 3y agoI was asked to be a reviewer / editor for a book back in 2014, as a uni student having a somewhat viral github library on top of a framework, but really no deeper understanding of the framework the book was supposed to be about. And what I would get for that work was a short bio in the book, a copy of the finished book, and another book of my choice. While I at the time was flattered and almost said yes, it also felt a bit weird knowing they didn't vet people more. What did that say about other books from them I had read?
- flor1s 3y agoIt's weird how mixed quality their books are, and how many overlapping books they have. From Packt I like Sebastian Raschka's books on Python Machine Learning. Other than that from time to time they do have some good "recipes", but hardly any of their books seems worth reading cover to cover.
- zerkten 3y agoI think that's a case where a good author has chosen the publisher for some reason. They are good enough to be published by someone else but went with Packt possibly because it was an easy onboarding.
- _the_inflator 3y agoDid you read the book? Or is this just some general judgment you are passing? I own the book, and I enjoy it. Bought it for Xmas.
- sidcool 3y agoI read it superficially. And it's okayish. Again, nothing against the author.
- jmaker 3y agoOpposite to Manning, O’Reilly proper, and No Starch Press books, Packt’s aren’t even properly edited. Apress books are the worst in my experience, really zero editorial work noticeable, lots of grammatical and logical mistakes, many obvious code errors. There are a couple better Packt books, but I don’t even bother looking inside anymore.
- wyclif 3y agoJust a thought: if I were a decision-maker at O'Reilly, there's no way I'd allow my brand to get diluted by Packt with these oreilly.com joint publications. Reputation is everything (or almost everything) in the publishing world, and it's why when you see O'Reilly's name on the spine, or Wiley, Addison-Wesley, Manning, or No Starch, you can expect a certain quality.
- 3abiton 3y agoAny better recommendations?
- harshreality 3y agoAlgorithms? - Algorithm Design Manual (3rd ed.) (by Skiena) - Art of Computer Programming vols 1, 2, 3, 4A, 4B (editions 3,3,2,1,1) (collectively, "TAOCP") (by Knuth) - Algorithms (by Erickson) [CC-BY-4.0] - Algorithms (by Sedgewick & Wayne) - Introduction to Algorithms (4th ed.) ("CLRS") (by Cormen et al.) - How to Design Programs (by Felleisen et al.) - crossover between basic programming advice, functional programming, and some limited/basic algorithms coverage [CC-BY-NC-ND-4.0] - Pearls of Functional Algorithm Design (by Bird) - Purely Functional Data Structures (by Okasaki) Publishers? Pragmatic Bookshelf, or O'Reilly (not oreilly.com-selling-Packt). Find what everyone is using as a learning/reference resource for a specific topic and use that, regardless of publisher; it's rarely if ever Packt.
- tmtvl 3y agoI would also add James Aspnes' Notes on Data Structures and Programming Techniques (<https://cs.yale.edu/homes/aspnes/classes/223/notes.html https://cs.yale.edu/homes/aspnes/classes/223/notes.html>, CC BY-SA 4.0).
- emmanueloga_ 3y agoFrom all these I feel like the best intro is Sedgewick & Wayne. CLRS is less solo-learner friendly, in my opinion. I skimmed Erickson and I liked it too. In the "friendly+actually-useful" category, you missed "Open Data Structures" [1] ... I think it has one of the best descriptions of trees, including B-Trees which seem to be only superficially described in other books. The "Think" series is also pretty good and covers more than just algorithms [2]. TAOCP, Okasaki, Bird: these feel really academic and/or less useful for industry work. Reading HTDP wasn't as useful to me, at least: I feel like Felleisen's books describe what he "imagines" would be a good way to write software on a "real" job :-p (non-academic setting). Skiena: I have mixed feelings about it... It seems to have gained popularity since Steve Yegge's blog post about Google interviews, but imho many concepts in that book are better explained elsewhere. I suppose the intended purpose of the book was to serve as a reference and an index to other resources. However, it often refers to sources that are 10 years old or older, academic implementations that could be challenging to apply in a real job setting, or things that are no longer available online afaict (e.g., LEDA), or hard to read papers, most of which lack a working implementation of the described concepts, etc. I wonder if anybody can really vouch for it or have a personal anecdote of the book being useful or enjoyable. -- 1: https://github.com/patmorin/ods https://github.com/patmorin/ods 2: https://greenteapress.com/wp/ https://greenteapress.com/wp/
- raincole 3y agoPackt feels like Udemy to me. I know there are some good stuff, but...
- wyclif 3y agoIt's a comparable situation, I tend to agree. I wouldn't make a 1:1 comparison but Packt is not known for publishing well-edited and written books.
- aerhardt 3y agoPersonally had an order of magnitude better experience with Udemy than Packt. Hard to find advanced content on Udemy but there’s a lot of beginner content that I’d consider rigorous for its level - can’t say the same about Packt.
- ruiycombinator 3y agosecond this, it seems that anyone can publish with them and the books most of the times are terrible, like reading clickbait articles on medium. Terrible.
- bogomipz 3y agoI completely agree. Packt as a publisher is hot garbage. That's not to say every author is bad but but even when you get a quality author with good content, you will have horrific formatting and nonsense like pages with one sentence on them, illegible screenshots and there's often a complete absence of proof-reading or editing. The Packt game seems to be to simply flood search results hence quantity over quality.
- r00tanon 3y agoReading down further I see this is a follow-up to "40 Algorithms Every Programmer Should Know". So, is this new book the same 40 algorithms from the prior book with 10 added? If so, perhaps the real book could be called "The One Book Writing Algorithm You Will Ever Need."
- vorticalbox 3y ago> The One Book Writing Algorithm You Will Ever Need.* * until we publish the next one
- AlchemistCamp 3y agoThe gp means they’ll use the same algorithm to publish the next book.
- amoss 3y agoPersonally I'm holding out for "The ten algorithms that every programmer that needs to know 50 algorithms should know, but are dispensable for programmers that only need to know 40". I feel it could be a real gem, but when will O'Reilly deliver??
- samsaga2 3y agoIt jumps from basic graph algorithms to unsupervised machine learning. It's a "let's put shit that sells" book.
- tgv 3y agoYeah. I really can't call RNN an algorithm every programmer should know. It may be a predecessor to deep learning (which also isn't an algorithm every programmer should know), but it's purely academic.
- jillesvangurp 3y agoMost of those you'd consume in library form. Most programmers shouldn't be writing their own lists, hash maps, b-trees, sort algorithms, etc. Or generally reinvent wheels. It's nice to understand how this stuff works and have a notion of complexity and other limitations. But, mostly we're just sticking things together that already works. I've dabbled a bit over the years with reinventing wheels like this and it's fun. and of course I had an algorithms course when I did my CS degree, 30 years ago. But, I can't say I spend a lot of time obsessing about algorithm implementations. I mostly just use them in library form; just like everybody else.
- chasd00 3y agoOne thing about learning algorithms from scratch is you learn how to measure code in terms of various resource costs (cpu, men, I/O). Being able to understand the cost of a given code block is very valuable.
- zerkten 3y agoIt doesn't seem that people actually learn those things in many cases. I encounter programmers fairly regularly who struggle to grasp CPU vs memory vs I/O trade-offs and have no mastery of tools for measuring them. This is unfortunate because the tools can often be a cheat code. It's painful to see people fixate on one possible cause without going to fundamentals and making a proper assessment. These people all pass the traditional programming interview filters for algorithms.
- jdthedisciple 3y agoSrsly With technology moving faster than ever, I believe we need to cultivate more acceptability for simply using existing stuff while rudimentarily understanding how it works, obviously ...
- jmaker 3y agoSometimes the general purpose implementations just don’t cut it, depending on the data access patterns, the hardware, etc., neither do they exhibit sufficient tuning capabilities. Sometimes people find out how embarrassingly inefficient a stdlib implementation under the hood is.
- deleted 3y ago[deleted]
- cnewey 3y agoThis book seems to be suffering from an identity crisis. It’s ostensibly aimed at “programmers” but the content is predominantly machine learning topics. What sort of general software engineer needs to know about GRUs and LLMs?! Add that to the fact that it’s published by Packt - this is probably one to avoid.
- mirekrusin 3y agoIt's aimed at people who will... spend money on it. Pivoted where money seems to be trying to cash on hype. If it was written few years ago, there would be blockchain chapter followed by llms now.
- cnewey 3y agoPackt’s business model is so transparent and so cynical. I hate it.
- la_fayette 3y agoWhat a book? When looking at the toc it seems overwhelming (basics, cryptography, ml, ...), haven't seen the page count, but must be a very thick book...
- arisAlexis 3y agoControversial: why? Your LLM knows it and you can ask it.
- jbstack 3y agoWhy learn anything?
- arisAlexis 3y agoFor pleasure? Sure
- j-pb 3y agoShelved right next to other literary gems such as, "Complexity Theorists Hate This One Weird Trick", "You’ll Never Believe This Bayesian Network", “The 10 Best Constants” and "This Is What Happens If You Don't Check Your Borrow"...
- RcouF1uZ4gsC 3y agoHas anyone ever used Shell sort? It is more complicated than Bubble and insertion sort, but has worse complexity than Merge, HeapSort, QuickSort which are n lg n.
- woadwarrior01 3y agoIt's fairly popular in extremely resource constrained embedded systems (micro-controllers). Because like bubble and insertion sort, it doesn't need a stack, the average case time complexity is often better than bubble sort and insertion sort. Also, it can be tuned to a certain extent using different gap sequences.
- nwallin 3y agoHeapsort is best and worst case O(n log n), does not require a stack, and the code is simple; more complicated than shellsort but no so much that you'd notice. I feel like heapsort is always a better choice than shellsort, no? If I were to make a list of 50 algorithms that every programmer should know, I can't imagine why I would put bubblesort and shellsort on the list, but include neither heapsort nor quicksort.
- AlchemistCamp 3y agoI agree. Heapsort is on the optimal frontier.
- ksherlock 3y agoI did once. I needed to do some sorting in VB5 which I don't believe had any built in sorting library (or if it does, I was unaware of it or it didn't work for my use case). I think I went with shell sort because it was easy enough to implement in VB5.
- charlieyu1 3y agolong long time ago. When there was no built-in sorting library and I forgot how to implement n log n sorts.
- gorbachev 3y agoThe reviews for the 1st edition, which only had 40 algorithms you should know, are pretty awful.
- eps 3y agoWhat's with the book cover design being almost the same as [1]? [1] https://www.amazon.de/-/en/gp/product/1839217715/ https://www.amazon.de/-/en/gp/product/1839217715/
- ahmedfromtunis 3y agoI'm a self-taught developer and always suffered from imposter syndrome, especially with regards to "advanced" algorithms. So, professional devs, do you use these algorithms in solving the problems you are working on, on a regular basis?
- siva7 3y agoNo. Despite what the book title says, 99% of programmers won't need any of these to implement themselves in a professional setting (ever). There is more useful stuff to learn about than this for most devs.
- sjfjsjdjwvwvc 3y agoI may be a very grug-brained „junior programmer“ but I literally never had to implement an algorithm from scratch in a 5 year „career“. Neither did any of my colleagues, who are as a rule smarter and working on harder problems than me.
- matsemann 3y agoImplement? Never. Unless for fun, advent of code or something, but never at work. Knowing how they work, that the algorithm even exists and when to use them? Quite often. Very useful to know that "my problem can be modeled as this algorithm problem, and then I can use some tool to solve it". And the same for various data structures. Knowing which one to use can make some things trivial, and not knowing can make it sooo slow. But would never implement them myself.
- ahmedfromtunis 3y agoAbsolutely get where you're coming from! Knowing the ins and outs, recognizing when to pull them out of the toolbox, and understanding the underlying principles—now that's the sweet spot. It's like having a cheat sheet for problem-solving, making things click into place without having to reinvent the wheel every time.
- itslennysfault 3y agoI'm also a self taught programmer. I've been coding since I was a child, and professionally for just shy of 20 years. I took the Stanford Algorithms 1 & 2 courses that used to be free on Coursera and certainly never regretted it. I've since worked at several large tech companies and ALMOST never needed them. From my memory I've needed to implement my own binary search and my own tree traversal (BFS) once each. Both were due to an odd data structure that made it hard to use a library. I probably could've shoe-horned it in somehow, but it was easier (or maybe more fun) in the moment to implement it myself. However, the thing that REALLY triggered my imposter syndrome wasn't algorithms, but design patterns. When I started at Microsoft I'd been programming for over 10 years and suddenly felt like people spoke an entirely different language. Luckily, it turned out most of the patterns they were referencing by name I had already been using, but just didn't know the vocabulary. I spent a lot of time studying design patterns largely just to have a shared vocabulary (and not feel dumb whenever someone said "maybe we should use a ___ pattern" in a meeting), but I also learned several new ones.
- mda 3y agoWhat is with this "N things every X should know/eat/do/not do" titles? It is patronizing and stupid.
- corobo 3y agoEasy reading (promises bullet points you can skim) plus fomo (you're missing this knowledge) plus no true Scotsman (you don't know this so you're not a real dev) Or, to summarise, it's clickbait
- rthkljlkrj 3y ago[dead]
- BananaaRepublik 3y agoI found the 40 and 50 algorithms book from the same publisher at a library, most of it was machine learning algorithms though.
- sylware 3y ago... with their mathematical proof. I wonder if it does include the minimal polynomial proof required for floating point computations of trancendental functions.
- louthy 3y agoSlightly O/T but am I the only person sick of seeing the word “every“ followed by the word “programmer”? I realise this might be because I’m a very experienced developer, and these things are not interesting to me, but it always seems anything titled this way is often incredibly dogmatic.
- jansan 3y agoEvery programmer is sick of seeing this. Joking aside, welcome to the attention economy. There is probably another book with similar content and a less dramatic title, but unfortunately it did not make it to the HN frontpage due to the descriptive title. There is not much you can do, just use your experience to interpret the title correctly ("50 of the most common programming algorithms"). Trying the world from changing never worked.
- mihaic 3y agoI have seen that shaming sometimes works, so I wouldn't abandon it. After all, there are so few social deterents we can use that I only say "that won't work" when I have a better suggestion.
- 255kb 3y agoSick and tired. But this is working. It seems that many developers actually want to do/use/learn whatever their peers are. Just look at all the tweets and reddit posts starting with "What should I use...?" or "What is the best...?. All aboard the hype train!
- say_it_as_it_is 3y agoLet's do a thought experiment and imagine that we instead titled it in the passive mode: "50 Algorithms Some Programmers May be Interested in Knowing". Are you as likely to read this?
- iamcasen 3y agoHonestly, it's so offbeat compared to the sensationalist headlines that have been optimized over the last 20 years that it feels refreshing. I would probably read it just for that fact alone!
- nraynaud 3y agoI would really add a bit of geometry. It’s mostly a blend of graphs and numerical, but it gives a sense of a way they can be intermixed, and adds the idea that you will have a shit sandwich and are coping with classes of errors and can’t know really know the true result but it’s good enough to produce meaningful outputs.
- ruiycombinator 3y agothe whole series "* Algorithms Every Programmer Should Know" is, how to put it, not good.
- theusus 3y agoI would have read it if it wasn't published from Packt
- marstall 3y ago30 years into my career as a programmer, and I've never had to understand how any of these worked internally, not even once.
- ActionHank 3y agoWhen last did you go through a round of job interviews? The world seems crazy about algorithms as a must-know thing to get a job. Built large scale projects? Built production teams that can tackle any problem? Deeply understand the process of delivering value quickly without defects? Doesn't matter. Show me how you would do a binary search. Show me that you know the whole API for our weird stack. Show me that you know how to do a systems design on a white board of a webcrawler or twitter. Once you've done that you can do one-liner bug fixes on this legacy system that breaks routinely because we have no idea what we are doing.
- marstall 3y agoha yeah totally. things are out of whack. i did misspeak when i said "never" because there have been times when I have learned some of those algorithms for an upcoming job interview, which i always failed to get if they required that. i generally get jobs through people I know. going back to about 2009 every FT job I've gotten has been through that way, 3 or 4 jobs. So not much in the way of technical interviews, just kind of "we know you, welcome aboard."
- m3kw9 3y agoWho not extend it to pipelining algorithms, caching algorithms if you are at it? I don’t think any programmers really know how any of that works.
- throwawy4983 3y agoI'm a little tired of endless lists of things I should or must know. There have been tons of them created and has only added to the confusion. It only increases my burden but doesn't really contribute to my bottom line. It would be different if salary scaled more directly with what I know. Considering we can't figure out the minimum knowledge required to be employed, I don't trust we have a good idea of what "every programmer should know" either. This "every programmer should know" meme has simply become lazy, useless, and harmful and prevented the book from choosing a good title.
- donatj 3y agoI have been working in the industry for almost 20 years and had to implement a B-tree for the first time since college a little over a year ago. Felt like I'd finally made it as a developer.
- deleted 3y ago[deleted]
- paxys 3y ago"Generative AI and large language models (LLMs), deep learning techniques, including LSTMs, GRUs, RNNs, neural networks, unsupervised learning, Seq2Seq model, the SciPy ecosystem, Jupyter Notebooks, Keras, TensorFlow". No, every programmer does not need to know these things. Not even close. Looking over the table of contents it is maybe 20% relevant topics and 80% soup of current hot buzzwords strung together to sound appealing and sell the latest edition of the book. And of course you can hit a button to get a monthly subscription and read all of it! If you want some actually helpful algorithms-focused material look up the website and YouTube channel of any good university. They all have great foundational courses covering data structures and algorithms available for free online that will be much more concise and useful.
- tonyarkles 3y agoI generally agree with you. If you want classical algorithms (which are, imo, fundamental), you can't go wrong start with Skiena's "Algorithm Design Manual" or lecture notes: https://www3.cs.stonybrook.edu/~skiena/ https://www3.cs.stonybrook.edu/~skiena/ > the SciPy ecosystem, Jupyter Notebooks These, though, are gems that can be dramatic quality-of-life improvements for all kinds of data analysis. I resisted for a while (writing code in a web browser? BARF), but have gradually come to have a deep affection for pandas, numpy, scipy, seaborn, etc. They're quirky, their APIs are sometimes a bit strange and unintuitive, but they make data analysis tasks go so much quicker. I'm not a data scientist; most days I'm more of a systems programmer. Being able to take log files, write a bit of Python glue to transform them into Pandas Dataframes, and then slice-and-dice-and-plot different facets of the data rapidly is a game changer.
- vips7L 3y agoI really like David Kopec's Classic Computer Science Problems series. He has it implemented in multiple languages too. https://classicproblems.com/ https://classicproblems.com/
- tikhonj 3y agoFrankly, the classic algorithms courses at universities aren't great either. The set of "classic" algorithms covered in an intro course is arbitrary and comes down to history more than pedagogy. There are some useful concepts that all programmers should know like dynamic programming or divide-and-conquer, but spending a bunch of time on relatively specialized and narrow algorithms like the simplex algorithm or FFT is not a great way to illustrate them. The core algorithms sequence ends up feeling more like a grab bag of "historically significant" algorithms rather than a coherently structured introduction to the subject. The set of algorithms taught is not a great practical foundation for solving problems, but also aren't especially effective at teaching how to generalize the ideas and design algorithms for your own problems. You can use a classic algorithms course as a starting point to learn more, but it's not an obviously great starting point. One grab-bag of algorithms might be better than another, but it isn't fundamentally better.
- greenhearth 3y agoWe all should know machine learning algos? They're cool and I've learned a bunch in school, but this is the crux of programming now?
- alabhyajindal 3y agoThis is just garbage. The publisher's business model is producing as much content as possible without care for what programmers actually need to know.
- badcppdev 3y agoHow is this still on the HN front page 10 hours after being posted with the most damning comment thread I've ever seen?
- wdb 3y agoI still enjoy Julian Bucknall's Tomes of Delphi book: https://www.lulu.com/content/435417 https://www.lulu.com/content/435417 Explains everything well and easy to apply in other languages