7 ms·
Algorithms
- ofek 10y agoSomewhat germane, https://github.com/patmorin/ods https://github.com/patmorin/ods is a great resource for data structures.
- Kimalsi 10y agoas someone who doesn't know much about this and is trying to join the tech community, what will I achieve through this?
- mirekrusin 10y agoSomewhere between 2-5x salary.
- ludicast 10y agoYou will learn more about this, and that will make it easier to join the tech community. -------------------------------------------- Also, to add some signal to my noise, Tom Cormen is apparently one of the designers of the course. He wrote the gigantic encyclopedia of algorithms, as well as a shorter, more-entry-level book on the subject. You'd be in good hands to learn the topic. And the topic is one that teaches you how to reason about your programs in a way that works across languages and disciplines.
- lebanon_tn 10y agoData structures and algorithms are foundational topics in computer science. While they can seem daunting to beginning programmers, they become very important as you progress into writing more advanced programs. Also, the interview process for software engineers at most companies ask about them almost exclusively.
- throwaway2016a 10y ago> they become very important as you progress into writing more advanced programs As someone with a Computer Science degree I can say that the only times I have ever used any of the algorithms I learned directly was when writing low level C and GoLang. I'm willing to bet 90% of programmers... even those that right "advanced" programs do not use them day to day. Every algorithm and data structure worth anything has been abstracted out into easy to use libraries years ago.
- ashark 10y agoAny time I make the effort to learn more or brush up on CS fundamentals I end up forgetting most of it in short order because I so rarely use any of it at work. Ditto mathematics past roughly Algebra 1. Every now and then I try to brush up on calculus or linear algebra or something, but it takes so much time to keep those skills up when you're not using them at work. Like keeping up foreign language skills while living somewhere you rarely encounter native speakers.
- stale2002 10y agoOf course! But how are you going to know WHICH library function to use if you don't know what to look for in the first place? Knowing that a problem at hand requires a certain solution is important.
- throwaway2016a 10y agoYou use the one labeled "sort" and trust the standard library chose reasonable defaults. It's not like the standard lib is going to use bubble sort. If the reasonable defaults aren't good enough... you're in the 10%.
- stale2002 10y agoIt is not about choosing "sort" it is about knowing if you need your data sorted in the first place. Sure, in some situations it might be obvious, but maybe not obvious for others. And things that are immediately, blindingly obvious to a 5 year experience programmer may not be obvious to a newbie. Ex: imagine if you didn't know what a hashtable or a dictionary was and just used single variables for everything.
- jhomedall 10y agoThere's a lot more to data structures and algorithms than sorting. For example, just knowing that bloom filters or interval trees exist opens up a ton of options, even if you don't implement them yourself. For that matter, the choice of sorting algorithm can have security implications. QuickSort on user-facing data can easily become a DoS vulnerability.
- jeron 10y agoyou will learn algorithms and data structures in all seriousness, algorithms and data structures are essential to computer science theory. When trying to get a job as a software engineer, technical interviews will mainly be problems about algos and data structures.
- jingwen 10y agoIDEs help you write correct syntaxes. Algorithms and data structures help you write correct programs.
- happy-go-lucky 10y agoData structures are ways of organizing and storing data. Algorithms are recipes or instructions. Usually it's learning algorithmic techniques for solving various computational problems and implementing algorithmic coding problems in a programming language. Hope that helps.
- SEJeff 10y agoDatastructures are akin to tools, and Algorithms are like plans. You need to use the tools to implement the plans for building your desired result. Each "tool" you learn inside and out allows you to build something new. The better you learn them, the more you can build.
- happy-go-lucky 10y agoIt's a better explanation than mine.
- SEJeff 10y agoI played with legos far more than is healthy as a child, and grew up to be a software engineer :) Can't help but think of it in literal lego terms.
- gspetr 10y agoProgramming is essentially working with data to solve some kind of real world problem. When working with algorithms, you’re trying to solve problems efficiently. Your programs should be fast, the wait for a solution should be short.
- a3n 10y agoAt some point the performance of your code (in time and or space) will really matter. Solid knowledge of algorithms and data structures are essential to getting that right. Early in my career, actually before my career, I taught myself the available language on our department's mini-computer (don't remember the language or the computer), so I could automate parts of my and my colleagues' job. I had to sort something, and I innocently "invented" bubble sort to do it. The system administrator visited me the day I first ran it, and told me to stop doing that. Soon after, I quit and went to school. :)
- stale2002 10y agoYou basically HAVE to learn this stuff, because it is all anyone every asks about in interviews. So the answer is "you will become good at tech interviews and be able to get a job"
- itsmemattchung 10y agoLet's say you are writing a python program, and you want to simply check if an element is in a list. So, you build a list and then check if 'd' is in the list: mylist = ['a','b','c','d']. if 'd' in mylist: ... This works just fine, however, the time it takes, to find the item, grows proportional to the number of items in the list. If your list grows to 1000 items, and the item you are searching for is positioned last, python will check 1000 times. This is known as O(N). Now, how does the performance compare, when using a set data structure? myset = ('a','b','c','d') if 'd' in myset: ... Well, underneath the hood, the set stores the data in what's known as a hash. The time it takes to check if an item is (or isn't) in a list does not grow proportional to the number of items in the list—it's always constant: O(1).
- ojr 10y agoexposure to more solution techniques into programming problems that you might run into most likely in an interview session. A lot will say learn this as it is the "core" of programming, but in industry practice I've seen using pure functions (functions that return the same result when the same parameter is passed in) is becoming more commonplace than having a trickier function that mutates a variable differently during each iteration, making it harder to reason about program state. Algorithmic problem solutions usually involve non-pure functions that are not intuitive until you've seen them before. Front-end UI is better built using several pure functions.
- SEJeff 10y agoFor anyone wanting to learn algorithms from one of the other heavyweights, not being a C developer, I found this series extremely beneficial: https://www.amazon.com/Algorithms-Parts-1-4-Fundamentals-Structures/dp/0201314525 https://www.amazon.com/Algorithms-Parts-1-4-Fundamentals-Str... It also helps that Robert Sedgewick has been in compsci forever (got hit PHC in 1975) and is one of the subject matter experts in algorithms.
- rajathagasthya 10y agoOr the newer book with Java code. https://www.amazon.com/Algorithms-4th-Robert-Sedgewick/dp/032157351X/ref=sr_1_1?ie=UTF8&qid=1487182924&sr=8-1&keywords=algorithms+robert+sedgewick https://www.amazon.com/Algorithms-4th-Robert-Sedgewick/dp/03... Robert Sedgewick also has fantastic algorithms courses on Coursera.
- MaxLeiter 10y agoMy Data Structures & Algorithms class uses this book - it's fantastic. One nitpick is the "EASYQUESTION" sorting visualizations in the book; they aren't too easy to quickly understand (why use letters instead of numbers demonstrating sorting algorithms or trees?
- shamino 10y agoBest book on Algorithms I know of. Extremely pedagogical and clear explanations!
- squeaky-clean 10y agoAnother vote here. I prefer this book to the CLRS.
- sn9 10y agoHe's got a pair of Coursera courses that run frequently covering most of the books.
- imakecomments 10y agoI don't like Sedgewick as much as CLRS. Sedgewick seems to assume knowledge in the physical sciences when explaining examples.
- hal9000xp 10y agoIt's strange they didn't cover dynamic programming at all. IMO every course should include at least one classical example of dynamic programming. For example: https://en.wikipedia.org/wiki/Longest_increasing_subsequence https://en.wikipedia.org/wiki/Longest_increasing_subsequence https://en.wikipedia.org/wiki/Longest_common_subsequence_problem https://en.wikipedia.org/wiki/Longest_common_subsequence_pro...
- santaclaus 10y agoThey didn't get the memo(ization)...
- nostrebored 10y agoNot being able to implement a DP solution to a problem has killed me in the last two Google interviews I've done. It's important to learn.
- deleted 10y ago[deleted]
- wopwopwop 10y agoI'd never heard of the expression "dynamic programming". https://en.wikipedia.org/wiki/Dynamic_programming https://en.wikipedia.org/wiki/Dynamic_programming Am I to understand that it is "just" recursion with caching?
- hal9000xp 10y agoPeople often make such conclusions about dynamic programming that it's just caching (including myself several years ago). I do recommend you to read this chapter: https://people.eecs.berkeley.edu/~vazirani/algorithms/chap6.pdf https://people.eecs.berkeley.edu/~vazirani/algorithms/chap6.... After reading this chapter, you can try to understand why Dijkstra and Floyd-Warshall shortest path in graph algorithms work. These classical and fundamental algorithms combine graph theory with dynamic programming.
- vga805 10y agoAnother great resource I highly recommend: https://www.manning.com/books/grokking-algorithms https://www.manning.com/books/grokking-algorithms
- bogomipz 10y agoI didn't care for this book. I found though the use "doodle drawings" for visualization to be hard to look at and distracting. The book felt half-finished to me. For instance how does an algorithms book not include anything on trees? I think a much better and free alternative is: http://interactivepython.org/runestone/static/pythonds/index.html http://interactivepython.org/runestone/static/pythonds/index...
- rapfaria 10y agoAbout the alternative, you can learn about algorithms but be prepared to not learn them in a pythonic way.
- bogomipz 10y agoI'm not sure I would say the book is "un-pythonic", but rather the book intentionally avoids overly language specific idioms in order to reduce algorithms to their most basic form. Once you have the basic knowledge its trivial to implement them in any language you want, using those language specific idioms - swaps without a temp variable or list comprehensions etc. It is not a "Python book" per se it is an algorithms book that uses Python to teach. I've seen many Algorithm book that use Java use a stripped-down back to basics procedural style as well I think for the same reason. The book also incorporate code lens and Python Tutor so you can step through your stack frames and pause execution. This is a wonderful teaching aide, especially for things like recursion. http://www.pythontutor.com/ http://www.pythontutor.com/
- chillaxdude 10y agoI'm currently referring this book to learn Python and Algorithms both in one go. Looks good so far. PS: I'm an experienced programmer (Perl).
- tomwphillips 10y agoThis is an excellent course and helped me get my current job. My background is chemistry/chemical engineering. I had applied for a data scientist position. Phone interview included a problem where I was asked about my solution's complexity. I admitted I didn't know about it. Still got called back for an interview on site, but the weekend before I powered through this course. Unsurprisingly, it came up in the on-site and they were really pleased I had learnt about it. I got the job. I also found it useful to implement all the algorithms in Python.
- michaelchisari 10y agoPython is the algorithm king as far as I'm concerned. It really gets out of your way and lets you focus on the abstract nature of what you're trying to accomplish.
- koolba 10y agoIf Python is the king, C is the court jester juggling knives. Done well it looks amazing, elegant, and efficient, but in the wrong hands you'll lose your hands.
- icpmacdo 10y agoI am slowly working my way through CS50 on EDX and its an interesting experience doing an intro to CS type course in C for sure.
- nostrebored 10y agoIt also forces you to know what's happening under the hood though. If learning the material comprehensively is your goal I think it's not a bad idea to dig in to a c implementation.
- michaelchisari 10y agoAt this point, I would recommend Rust for the "under the hood" part, while forcing you to write safer code.
- imakecomments 10y agoAs a follow up to this resource I recommend, Algorithms unlocked: https://www.amazon.com/Algorithms-Unlocked-Press-Thomas-Cormen/dp/0262518805 https://www.amazon.com/Algorithms-Unlocked-Press-Thomas-Corm... CLRS: https://www.amazon.com/Introduction-Algorithms-3rd-MIT-Press/dp/0262033844/ref=pd_sbs_14_img_0?_encoding=UTF8&psc=1&refRID=8N4X7T2JSRBSJYSVSBCM https://www.amazon.com/Introduction-Algorithms-3rd-MIT-Press... Both include the same author as the one in this article (Thomas Cormen).
- bogomipz 10y agoI'm a big fan of Kahn and I like the addition of CS material to the site. I hope they continue to add CS material.
- malloreon 10y agoIf you have the KA app installed this link opens in it! Which is great, except it takes you to the main list of subject matters, and algorithms isn't in there. So I'm not able to view this link on my iPad unless I uninstall KA?
- lorenzhs 10y agoThere should be a Safari action in the top right where usually you'd have the battery indicator
- OJFord 10y agoAm I the only one to think that, for anyone capable of making it through the course, the introduction is incredibly patronising? Not just the everyday examples of what constitutes an algorithm, but the voice, presentation, etc.
- koolba 10y agoIt's hard to pick one thing to tell budding developers they have to learn but Big-O notation is definitely up there. The follow up to that is understanding what you're counting and why, i.e. branches v.s. statements v.s. dereferences v.s. logical I/Os v.s. physical I/Os ...
- bigdataanswers 10y agowhy python???? ... any language with functions will do. I mean just create a java class with all public static functions if you want it to work like python (global functions). Its really language agnostic. Your answer will be a number a string or a list of things. All languages can do that. Im making an explicit opinion that python is no better than any other language for implementing algorithms. HN please prove me wrong in an objective way so we may all learn?
- ambulancechaser 10y ago> why python???? ... any language with functions will do. it will. and this person chose python. > HN please prove me wrong in an objective way so we may all learn? no one cares about the choice of language. This is about learning algorithms.
- skylark 10y agoSignificant whitespace is great for technical interviews - you don't need to worry about matching brackets and whatnot. No brackets also means you have some more vertical space to work with on the whiteboard. Beyond that, if your interviewer is fluent in python, list comprehensions can greatly shorten the amount of boilerplate you have to write.
- Bartweiss 10y agoAmusingly, significant whitespace is the one reason I don't like using Python in whiteboard interviews - my handwriting is far from excellent on a board, and I don't want any ambiguity when reading my control flow. I'll definitely second the list comprehension point, though. Between that and pleasant string support, a lot of standard interview answers are maybe 50% as long in python as Java. Not easier, necessarily, but faster to write and cleaner to read.
- aanm1988 10y agoIndentation is a pretty good thing to practice for whiteboards. A lot of people have a tendency to waste more and more space on the left as they go. It's a pretty easy thing to fix, just do some questions and have someone there to correct you whenever you start doing it. Even if you aren't using python, it will give you more room to work (the other part of this is divide the board before you start).
- j2kun 10y agoI understand that the focus on sorting is to have a simple application that everyone can understand. But I can't seriously expect people to get that excited about sorting. I sure didn't. It's not like we don't have tons of other applications that demonstrate the same principles.
- evahop 10y agoCan anyone recommend an alternative introduction to asymptotic notation?
- contravariant 10y agoDifferent in what way? The general idea is that something takes O(f(n)) time if it takes at most C·f(n) time for some constant C and all but finitely many values of n. The 'all but finitely many values' is what makes this definition 'asymptotic'. Basically 'O(f(n))' ignores constant factors and the behaviour at 'small' n (i.e. small inputs), the reasoning behind this is that an algorithm in O(f(n)) is faster than any algorithm not in O(f(n)) provided you make the input big enough. The little o, big Omega, big Theta are just small variations on this, which won't be too hard to understand if you get the general concept, and really the distinction isn't too important usually, just know that O(f(n)) gives an upper bound, not necessarily the best possible upper bound. To understand the big-O notation better it might help to have some basic knowledge of limits.
- evahop 10y agoThe information made intuitive sense to me. I just couldn't apply what was read directly to the exercises. It felt as though something crucial had been omitted. That something turns out to be calculus.
- contravariant 10y agoYou don't technically need calculus, but knowing about limits does help.
- evahop 10y agoI appreciate the insight. For w/e reason this has been one of the more difficult concepts to grasp.
- girzel 10y agoMy high-school-age daughter is using Khan Academy to learn about logarithms for her math class. She was telling me about it, and I thought "hmm, maybe I should finally figure out what Big-O actually means". Now here we are! I guess we'll both be on KA tonight.
- contravariant 10y agoOdd choice to start with the iterative factorial before moving on to the recursive one. Usually it's the other way around, since the iterative algorithm is faster and uses less memory.
- mildbow 10y agoRecursive might be harder to grok to someone new because of the implied stack. However, once you understand the iterative version, it's probably easier to understand how the recursion is actually working.
- wopwopwop 10y agoThanks for the link. However, it seems just a subset of Cormen et al.
- machiaweliczny 10y agoGrade school level :/
- machiaweliczny 10y agoTotal basics. Grade school level :/
- dang 10y agoPlease don't post comments that are dismissive of other people's work. It may not be at your level, but everyone needs to start somewhere.
- machiaweliczny 10y agoTotal basics. Grade school level :/
- fahimulhaq 10y agoWe at educative.io re-published this course as a free course with implementations in Java, C++ and Python (in addition to Javascript). https://www.educative.io/collection/10370001/760001 https://www.educative.io/collection/10370001/760001 One of the authors - Professor Balkcom is our advisor as well.
- bhu1st 10y agoHere is Princeton's Algorithm text I've found useful (The code is in JAVA though): http://algs4.cs.princeton.edu/home/ http://algs4.cs.princeton.edu/home/ Pair this up with this excellent lecture by the authors Sedgewick and Wayne: https://www.coursera.org/learn/algorithms-part1/home/welcome https://www.coursera.org/learn/algorithms-part1/home/welcome
- b3b0p 10y agoThe Coursera Stanford [0] and Princeton [1] courses start again soon, February 20 to be exact. Not sure which one is better, but to refresh my atrophied CS skills of 10 years I've joined the Stanford course. Not sure how it compares to the Khan Algorithms course. Anyone have any feedback? [0] https://www.coursera.org/learn/algorithm-design-analysis/ https://www.coursera.org/learn/algorithm-design-analysis/ [1] https://www.coursera.org/learn/algorithms-part1/ https://www.coursera.org/learn/algorithms-part1/
- bootload 10y agoEdX as well, - 6-00-1x https://www.edx.org/course/introduction-computer-science-mitx-6-00-1x-9 https://www.edx.org/course/introduction-computer-science-mit... (started) - 6.00.2x https://www.edx.org/course/introduction-computational-thinking-data-mitx-6-00-2x-5 https://www.edx.org/course/introduction-computational-thinki... (March) All are good and are pitched at various levels of complexity. The Princeton course uses Java. Okay if you're into that sort of language/thinking. MIT is using Python. Found one using lisp, "Systematic Program Design" ~ https://www.edx.org/xseries/how-code-systematic-program-design https://www.edx.org/xseries/how-code-systematic-program-desi...
- imakecomments 10y agoThis is just my opinion and I'm sure it differs from others... Roughgarden's class is advance and expects mathematical maturity. You may find his course quite fast and rough if you are a beginner. Sedgwick's class is much easier. He is a bit boring and tries to use "real life" examples (in some instances) from the physical sciences to make the material relatable. This in my opinion detracts from the material. Also, he doesn't always fully explain where he got some of the big ohs here and there. My advice? Follow MIT's OCW course (it uses CLRS). Supplement it with Algorithms Unlocked, the Khan Academy link in OP and CLRS. If you use those 4 resources and put in the work you'll understand the material. All 4 sources have Thomas C's DNA touch to it (he is the C in CLRS). So you'll find it consistent when you read from one source to the other. After reading/hearing the same thing about 4 different times in 4 different ways it'll begin to click. Order of easiness is probably Khan Academy > Algorithms Unlocked > MIT Algorithms Course > CLRS. Algorithms Unlocked is like "pre-CLRS" and Khan Academy's version is the TL;DR version of Algorithms Unlocked. Hope this helps. Below are the links, https://www.amazon.com/Algorithms-Unlocked-Press-Thomas-Cormen/dp/0262518805 https://www.amazon.com/Algorithms-Unlocked-Press-Thomas-Corm... https://www.amazon.com/Introduction-Algorithms-3rd-MIT-Press/dp/0262033844/ref=pd_sbs_14_img_0?_encoding=UTF8&psc=1&refRID=AYGC508DGP6YSYKSA759 https://www.amazon.com/Introduction-Algorithms-3rd-MIT-Press... https://www.khanacademy.org/computing/computer-science/algorithms https://www.khanacademy.org/computing/computer-science/algor... https://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-046j-introduction-to-algorithms-sma-5503-fall-2005/video-lectures/ https://ocw.mit.edu/courses/electrical-engineering-and-compu...
- awesomepantsm 10y agoTalked to someone who wanted to work at one of the big megacorps as a software engineer, asked for advice to pass the interview. I asked them if they could implement quicksort. They said maybe, but they didn't really want to study algorithms. I guess they really didn't want the job after all.
- uber1geek 10y agoSo what are some good resources for Data Structures out there, you can vouch for ?
- oferzelig 10y agoUnbelievable, a guy posts a link to some course and gets 458 HN upvotes (as of this writing).
- ankurdhama 10y agoIt is really sad that people still start the discussion about algorithms by telling it as a sequence of actions or operations to accomplish a task. How to go to airport is not an algorithm, how to cook food is not an algorithm.
- ponco 10y agoWhile I agree "following instructions" !== "algorithm", it does serve as a decent bit of context to people who are COMPLETELY unfamiliar with computing let alone programming.
- ankurdhama 10y agoIt provides them incorrect context, if you really want to provide context then start with long addition which everyone understands and tell them that it was the first algorithm they learned. Physical activities are not algorithms, algorithms are sequence of calculations on data and there are many many examples that people know about that they learned in elementary mathematics and that can serve as the proper context.
- Apocryphon 10y agoThe Algorithm Design Manual by Skiena is pretty great. https://www.amazon.com/Algorithm-Design-Manual-Steven-Skiena/dp/1848000693/ref=sr_1_1?ie=UTF8&qid=1487232535&sr=8-1 https://www.amazon.com/Algorithm-Design-Manual-Steven-Skiena... It's nearly a third of the length of CLRS, and half of Sedgwick. Much more precise, yet offers more in that it talks about common problem solving uses cases with data structures and algorithms, rather than writing going through the theoretical proofs behind them.
- chillaxdude 10y agoI really love the war problems.
- godmodus 10y agoI have to applaud the attempt. And I'm kind of smirking right now, because again asymptotic got butchered. I've spent the good part of this semester trying to get my head around a very formal, very dense script of my own algorithms course. And I finally cracked asymptotic. Maybe I'm just dense. But If that's the case, I'm sharing a classroom with others who are equally dense. We dealt with all 5 classes, big oh, small oh, theta, big omega and little omega. We're required to always give the "most exact" classification for best/avg/worst. Including "does not get as fast as" or "does not get as slow as" I'm willing to write a "freshman friendly" write up if someone's willing to post it or use it. I'm shit at self publishing.