HN Academy

Online courses recommended by Hacker News users. [about]

Learn Algorithms, Part I

Coursera · Princeton University · 116 HN points · 29 HN comments

This course covers the essential information that every serious programmer needs to know about algorithms and data structures, with emphasis on applications and scientific performance analysis ...

HN Academy may receive a referral commission when you make purchases on sites after clicking through links on this page. Most courses are available for free with the option to purchase a completion certificate.

Hacker News Comments about Learn Algorithms, Part I

All the comments and stories posted to Hacker News that reference this course.

I recommend learning discrete mathematics, then data structures and algorithms.

I cannot stress enough how important mathematical foundations is. It'll make everything else much easier to learn. I haven't read the book but heard good things about: as a beginner text.

Coursera has multiple offerings on Data Structures / Algorithms -- find one that works best for you.

For instance:

By doing all of those you'll get a good introductory exposure to the topics.

You should also look at a rigorous course offering of Algorithms. MIT has a few online to view.

Some readings for a beginner are: (not beginner level but classic)

After all of this you should be fine with diving into interview books. You'll want to whiteboard solutions and be able to do all the difficult problems. Look into sites like leetcode, glassdoor and be able to do the difficult problems posted there.


Thanks, there are some good resources here. I rushed through CLRS to help prepare for these interviews but I failed at the phonescreen, which was mostly comprised of Leetcode / Hackerrank type questions. I'll definitely take a look at the coursera course specialization but it seems as though these interviews comprise of a 'programming challenge' type question for the phone screen and more with a focus on data structures, algorithms and system design for the onsite.

Nov 04, 2016 · sn9 on Advanced Data Structures

Skiena's book is excellent and is definitely one to get.

Another would be Sedgewick's Algorithms . He has a pair of courses on Coursera [0] that follow his 4th edition which uses Java.

You're in for such a treat! Learning data structures and algorithms is so fun and really changes the way you think about programming.



Thank you for your recommendation and advice. I will go for Skiena's book since a lot of people recommend it.

I viewed classes from all three mentioned above and found Prof Sedwick's classes to be very structured and to my style/liking. Prof. Roughgarden is "free flowing" and may require fast thinking to follow him. Prof Demaine's classes gets very mathematical and I found myself sometimes lost in Greek symbols. But Prof. Demaine is very thorough in building the theory.

[1] Prof Sedwick:

As @carise said, the content may be gone after June 30th and if you want to download, you can do so using coursera-dl tool

[2] Prof Roughgarden:

[3] Prof Erik Demaine (MIT OpenCourseware):

There are videos of MIT's Prof Erik Demaine's Intro to Algo's from various semesters. I think any one should do.

I use a combination of Coursera and Udacity to learn the algorithms, and Hacker Rank to find places to implement them.

I actually just cruised through this course and found it super useful. Edit: By cruised I don't mean did it easily but instead just watched the videos, because I was cramming whenever I could fit time in.

It covers Binary Search Trees pretty well and some other things on the list. I also really like this teacher.

Also, Algorithms, Part I and II ( and ) by Kevin Wayne and Robert Sedgewick of Princeton University. They approach algorithms from a slightly different angle than Stanford course does and in my opinion they complement each other very well. I was very impressed by the lectures, practical problems, the autograder, and the 'Algorythms 4th edition' book.

p.s. don't expect any certificate of acomplishment for those courses though. I did them both close to 100% and they did not even show up in completed courses on Coursera. I guess it's the Princenton thing, and I came just for the knowledge so that was fine with me.

The Sedgewick/Wayne algorithm classes: and

I took these to prepare for first-job interviews coming out of grad school. Got an offer from a company frequently mentioned on this site, so I guess they helped.

Coursera's Algo part 1 starts in 2 days.

There are a lot of MOOCs (Massive Open Online Courses) nowadays that offer CS theory. For example, Coursea has an algorithm class available ( ).

MIT also offers classes as well ( ).


Coursera, etc. offer great resources for learning CS. I think Roughgarden's sequence is better than Sedgewick's, because it's targeted at upper division rather than lower division students and is language neutral.

On the other hand, Coursera etc. fall into a bit of a grey area regarding "outside of college". Though I tend to think that limiting the options to outside of college doesn't get the OP much.

Jul 21, 2015 · simi_ on Nibble Sort

There's an ongoing Algorithms course on Coursera right now!

edit: found another one, also happening now (can't believe I missed it):

Coursera has a couple courses coming up:

Algorithms: Design and Analysis, Part 1:

Algorithms, Part I:

Sedgewick's course on Algorithms, through Coursera, is pretty good, for anyone who wants to learn more about basic algorithms, or (like me) needs a refresher.

You could check out the following resources:

1. Coursera Algorithms I for formal university-style learning. See

2. for visualising algorithms. See

3. for time/space complexities for the most common data structures & algorithms.

4. The book - Cracking the Coding Interview which goes through the questions that top companies like Google, Amazon, Microsoft ask during interviews. For their solutions, see

Hope that helps in some ways.


+1, I just enrolled on the Coursera algorithms course, I was going to recommend that one.

My only complaint is that they removed the videos from past sessions (I did find them elsewhere on the web).

There are plenty of very good MOOCs on algorithms -







Which of these would you recommend for someone who has been programming since 2 years but wants to improve their fundamentals ?


I'd go for aofa

If you're familiar with online courses, then you probably know Coursera, but there are two decent algorithm courses that cover a lot of good stuff about data structures and algorithms starting again in the new year. You can check them out on these pages:

Coursera has both Sedgwick's lower division sequence in Java and Roughgarden's two class upper division sequence using whatever language the student chooses.

There are also upper division courses by Sedgewick as well.

Just don't apply to those companies, you probably wouldn't like it there anyway.

In fact that interviewing style is being abandoned, see here the case of Google:

So why invest so much time and effort in preparation for an interviewing style that is only practiced by a small minority of employers. Its a big world out there.

One alternative: become a freelance, as those interviews are usually only for employees, and you tend to take a lot less bulshit being interviewed as a freelance, things are kept much more to the point.

Alternativelly, take this course at Coursera, lots of food for thought there ->

Still for those interviews you indeed need to prepare: buy books on how to do those interviews, practice at home, etc. remember it has nothing to do with on the job day to day work, its just an absurd silly game.

The two books that helped me the most were:

Algorithms, 4th Edition by Robert Sedgewick. Material:

and Data Structures and Algorithms in Java, 2nd Edition by Robert Lafore

Both are in java.

For points 1 and 2 has a great set of courses on algorithms[1], Taught by a Princeton professor. I started the first one a couple of months ago, but had to drop out because of time constraints. I've re-enrolled for the upcoming section. It has a companion book, Algorithms[2], that I bought which was a great help. I don't have a copy of CLRS[3] But I've heard it is also a great reference and is on my amazon wishlist. Other than that, MIT's OpenCourseWare[4] also has the entire CS degree online for free. It's funny, reading your post I thought I hide sleep posted or something. You seem to be experiencing exactly what I'm going through. I'm also 27 and don't have a CS degree. I am highly motivated though, and have no problem hacking at this stuff on my own. I've talked to a bunch of CS majors who actually still feel inferior after they graduate so other than helping the impostor syndrome[5] that I suffer from, I'm not sure that a degree would do me a lot of good. (With the exception of padding my resume and getting me in the door for an interview). [1] [2] [3] [4] [5] The Cousera couse above is a really good. Its centered mostly around Java, but the basic principles, of course, can be used in any programming language.

My high school math teacher used to say math is like handcraft. I'm a lousy student but if you have the discipline and will to learn something I'd look at where you tap out in the chapter and try to learn that. Math is based on a lot of concepts. You have to solve the problem sets in order to grasp a lot of concepts. A lot of books are very dense and theoretical. Start small. Read the college textbooks for the algorithm courses and try to solve the problem sets on your own. If you are stuck join some communities. There are subreddits and forums dedicated to math. If you ask there kindly with a concrete problem and your efforts you'll get an helpful answer. That's the only thing that works for me: Solve the problem sets on your own. Everything will be easier. And don't take shortcuts. That's at least my experience.

There is: which is pretty readable.

And there are a lot of MOOCs:

If you work yourself up from there and solve one problem after another you'll be quite good at these things in a few months time.

There is an Intro to Programming in Java on Udacity[1] and an Algorithms in Java class on Coursera[1]

[1] [2]

I've been taking an algorithms course on Coursera and I'm really enjoying it. It's taught by two professors from Princeton, Kevin Wayne and Robert Sedgewick. Heres the link:

I'm sure there are plenty of other online algorithms courses online too.

If you have enough time, the Robert Sedgewick's course[1] could be the answer you're looking for. It's much more engaging to watch video lectures and discuss the material with other students than it is to read articles on Wikipedia or some boring textbook.


I started taking Bob Sedgewick's class and like it so far.

Aug 25, 2013 · 109 points, 34 comments · submitted by carlosgg

I believe Java is chosen for its popularity and its static typing, which helps the learner gain a better understanding of the algorithm at play than a duck-typed language would. It is even better to learn algorithms in C, where one has to work directly with the memory trade-offs. But learning these algorithms in Java is certainly more effective than learning them in Python, Ruby, etc.


I watched the video (but didn't take part in the class assignments) last spring, and I want to paraphrase an important remark by prof Sedgewick that really struck a chord in my mind:

> Though we have faster computers, algorithms remain absolutely essential in our field, because the amount of data that we process is greater than ever before.

It was nice to hear someone in a position of authority clearly explain why this field of research is important. It also helps understand why he prefers tilde notation to big-theta notation; the former takes into account the constant factor of the fastest growing term, thus allowing us to compare different implementations that are all O(n^2) in theory.


"If I have not programmed before, can I still take the course?"

"Probably not."

much appreciated (I can code, but I was hunting around for some coding courseras for a friend who has expressed interest in learning)


Signed up. I've been developing online education software for a few years now, and never actually used any. And like many self-taught, working programmers, I'm very weak on algorithms. So I'm excited.

Side note, am I the only person on earth who whitelists cookies? With cookies blocked, every page on, including the home page shows nothing but the word "loading" and a spinning gif. Blogger was like that for a while, except they had gears. Sure, you need cookies to log in, and sure, they're used for analytics, and sure, you can do some progressive enhancements if I come back. I guess I'm old fashioned, but I'm at a loss to understand how the failure to get cookies back from a first-time visitor can stop all content from "loading," including the template. Must be a framework thing.


I took this class in Princeton - COS226

It was easily one of my favorite classes. It's very straightforward and the lecture slides are great. I highly recommend flipping through them.


Great, but I hope it doesn't follow the book...

"Algorithms in C" by Sedgewick is a great book, which uses C to implement the algorithms talked about in the book. "Algorithms" also by Sedgewick, which looks like this course is based on, spends a hell of a lot of time teaching you Java!


I took one of the previous offerings of the course, and they assume that you know Java. The programming assignments start on week 1 with "real algorithm" work, there's no time wasted introducing you to Java or anything like that.


It look substantially similar to COS 226 at Princeton, also taught by Kevin Wayne, which uses this textbook:


Yes, that's the textbook for this course.


If that's the case, there's an unhealthy amount of basic Java in the text, but it's still a very good course.


I've just done the first week's lectures and exercises. They assume you know Java, but if you don't you're pointed in the right direction for suitable resources.


Sedgewick's tone/approach is very natural. He says things in terms of "this is what we know," sometimes implying that the subject is not as settled as it appears. This in contrast to professors that just go through the motions of "this is X, this is Y, quiz on Friday."


Seeing some comments about Java...

I'm taking this course right now (just finished the first "percolator" assignment this afternoon!). I've never used Java before this, but getting Eclipse up and running with "Hello World" was easy. Eclipse took a little exploring to get used to, but the C-like syntax of Java makes the language very easy to pick up.

If interested in this material, but turned off because you can't use your favorite language: take this as an opportunity to step outside of your comfort zone. That's what I'm doing. It's character building.


This looks great, but I'm not so keen on getting into Java at this point. Has anyone taken this, and if so would it be feasible for someone from a Ruby/Python background to grok what they're getting at?


I took this last time (for the first few weeks). It is a very applied course. The autograder for the exercises is terrific, it will pinpoint the space time complexity of individual parts of your program so you can fine tune your data structures and algorithms. The whole setup is java based. IMHO, the course is far less valuable if you don't do the exercises. If you want theory oriented courses the Stanford ones (Tim Roughgarden) are more to your liking. The exercises for that course are in any language of your choice.


Excellent reply, exactly what I was looking for. Thanks very much!


I took this course the last time it was offered and 3 months later I was at Google :D Ofcourse there were other factors too.


I know some (most?) of you reading HN saw this last week, but remember that you can use Coursera-dl[1] to download the material for offline reference.



I just tried it, did not work :(. Says failed to authenticate as username. I tried it on Saturday and it worked ok. Maybe they are blocking it?


It's working for me ... this was a godsend! Thanks a lot!


When was the last time you tried it?


Not working for me too with the same error.

Noticed the issue raised ( probably by you? ) -

Edit: Tried this one ( ) and it too failed for login.


Are you running Firefox at the same time as the script? :)


Yes that was me. I hope Coursera has not blocked it somehow...I think the dgorissen implementation is based on the other one, so not surprising the other one doesn't work either.


I'm glad to see more classes like this come online. I think its a bit of a shame that the material (of the book) focuses so much on Java, however. The algorithms classes I took in college focused a lot on math, logic and proofs. It took me a long time to understand exactly why; I thought we'd be learning L1 cache hacks and register tricks in Assembly or C. But the technology used to implement the algorithms changes a lot faster than the algorithms themselves, and the details of the best optimizations are different for just about every language. I now think it's far more important to have a solid grounding in problem decomposition and theory than it is to understand the intricacies of efficient algorithm designs for a specific language.

If you feel like I do, there are two books in particular that come to mind in that their content transcends the normal teaching curriculum and they both force you to think long and hard about how the authors came up with these fantastic little optimizations. I personally learned a lot from trying to reconstruct the thought process that must have led up to some of the algorithms implemented therein.

The first book is called Pearls of Functional Algorithm Design , and while it focuses on implementation in Haskell, you don't need to be a functional programming expert to get a lot out of the book.

The second book is called Foundations of Multidimensional and Metric Data Structures , and while the name might scare some away, it has a lot of interesting algorithms and accompanying research paper references so you can go off and explore. It took me several years to make my way through it completely, but I have gained a much better understanding of algorithms (and data structures!) that deal with more complex topics (such as computer vision).

There's one book I'd like to call out, as well. Introduction to Algorithms could be so much better than it is. It has all the right ingredients for a fantastic introduction to algorithms, but the way its written had most people in my algorithms class, myself included, bored beyond belief.

Just my 2 cents.


"the material (of the book) focuses so much on Java,"

This isn't really true. There is one section of the book (section 2 in Chapter 1 iirc) that details the minimalistic subset of java used, and there are a total of four interfaces used in the book (Comparable, Comparator, Iterable, Iterator) and each is explained very clearly. The code uses no inheritance, no fancy types, no design patterns. Input and Output are abstracted away by author provided classes with the minimal methods required to read in and write out strings, ints etc (vs struggling with BufferedOutputStreams or whatever in mainstream java).

In other words, Java is used as a very minimalistic pseudocode. (e.g ). It is almost python like.

A simple imperative language is best to learn the basics of algorithms in. You can't appreciate functional datastructures before you thoroughly understand imperative ones..

Something like SML may have been better, but the minimal 'loops + classes-as-structs-and-no-java-heavy-machinery' approach in the book works fine. There are certainly valid criticisms of the book to be made, but an 'excessive focus on Java' is not one of them imo (and I don't even like Java fwiw).

PS: Thank You for your book reccommendations. The "Metric Data Structures" book looks really interesting. Ordered.


I found the video lectures for this course extraordinarily boring compared to the Stanford algorithms courses taught by Roughgarden. Sedgewick is a brilliant computer scientist, but those videos really put me to sleep.

Both classes are still solid offerings from Coursera, but having gone through both levels of both, I'd recommend the Stanford ones first.

Also, I don't know if this has changed, but the programming assignments required a custom Java installation provided by Princeton with a bunch of extra packages specifically for the course. I found that a little weird compared to the Stanford class's approach of just giving you an input file and verifying the output provide (ala a coding competition).


There is no "custom Java installation" required, although they do offer one (called "DrJava") to get people up and running quickly and presumably to make support easier. I used IDEA and it worked just fine.

They do require one JAR file, stdlib.jar, to handle things like file I/O that are boring and take away from the algorithms themselves.

There is a second JAR, algs4.jar that contains all of the completed classes, which is useful if you want to implement one particular algorithm yourself, without going back and implementing the others that it relies on.


On the contrary, I found Sedgewick's lectures very interesting. The animations of algorithms using cards, trees, nodes etc. is an excellent way to get a good grasp. It is a solid representation of what you would imagine in your mind while learning algorithms.

Another particularly interesting thing about his lectures is when he shares some stories from his vast experience over the years. For eg. When they named a red-black BST after the best contrasting colours you could get on the first ever color printer built in Xerox PARC. Or his excitement to build an animation for Prim's MST on a personal computer.


Came here to say the same thing, I thought he explained things well and in different ways then I had learned them in the past.


> I found the video lectures for this course extraordinarily boring compared to the Stanford algorithms courses taught by Roughgarden. Sedgewick is a brilliant computer scientist, but those videos really put me to sleep.

At the risk of sounding overly negative when it's not intended: they're both very boring lecturers. I actually wonder if that might change a bit when they're interacting with a real audience.


Having actually been in Sedgewick's lectures, I can confirm that his soothing slow monotone is more effective than Nyquil for lulling students to sleep. That said, his course is damn excellent, and I know of no other teachers that have done better at making a course that actually teaches comp sci fundamentals in an approachable way. He's very understandable and clear even when played at 1.5x speed, which I recommend to anyone who isn't having trouble thinking through the concepts faster than he can lecture through them.


for me it was the other way around :) I felt Roughgarden was skimming through the lessons..Sedgewick ,in my opnion is the better teacher


it's the grandfatherly tone...

If you're fine with online video tutorials (not just books), a Coursera class "Algorithms" uses Java <>.

Jun 08, 2013 · 7 points, 7 comments · submitted by karpodiem

(I'm referring to this course -

I'm very disappointed that Coursera 'locks' courses after the registration window closes. This was one of the brilliant aspects of MIT OCW - courses there were essentially knowledge dumps, anyone interested could view the material at any time.

If you were enrolled in either Part 1 or Part 2, can you please capture the course material/video lectures and torrent it? I'd be interested in taking this course.


Though not the same ones but here are the lectures from University of New South Wales - ;


There is a better way that occurred to me yesterday.Go to Tim Roughgarden's Stanford website.He has links to the archived classes.


This is different than Sedgewick's class but looks interesting.

Locking the class isn't Coursera-wide. I actually took the Algs part II class, but can't access the videos anymore, while other classes that have been over for much longer (e.g. the Scala course) are still available.

And some courses have video downloading disabled altogether for some reason, e.g. High-performance scientific computing.


You can get lectures from the can link Just change the number


I'm not sure I should out right torrent it against their wishes if only to encourage the school to continue providing more materials -- however, I signed up with just this in mind.

Email in profile.

Also for future reference: there is a handy utility called coursera-dl if you want to save time faffing around with wget.

Edit: Oh great, there are backups online, yay.


YouTube to the rescue! I just found this guy's channel not too long ago and he's posted all of the videos along with a number of other courses.


awesome, thanks!

No lecture videos as of yet, but perhaps eventually. Princeton began a partnership with Coursera last year and the CS department has been relatively active, e.g., our algorithms course is now on the site [1], and I believe that they actually 'flipped' the course over the past semesters, i.e., students were expected to watch the lectures online and typical lecture hours were replaced with professors fielding questions / working through examples.

[1] -

Try this link: , if that doesn't work, just log in to coursera, then find Courses, then look for Sedgwick.

I believe companies are paying them for access to the best students of specific courses (for recruiting).

For example, the Princeton Algorithms course says:

.. Coursera will maintain limited data regarding student progress and performance in this course and, with your permission, provide authorized third parties with access to such data.

Given what recruiting fees are, I'd imagine this could work quite well. It is unclear how well it will scale, but if they can keep their costs low enough it may not need to.

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
HN Academy is an independent project and is not operated by Y Combinator, Coursera, edX, or any of the universities and other institutions providing courses.
~ [email protected]
;laksdfhjdhksalkfj more things ~ Privacy Policy ~