3 ms·
You should know enough to avoid doing nested loops to find the intersection of two lists. Things like that come up on a regular basis for me, although I don't
by recursive 13y ago
You should know enough to avoid doing nested loops to find the intersection of two lists. Things like that come up on a regular basis for me, although I don't work at any tech giant.
- rhizome 13y agoYou mean like this built-in from Ruby's standard Array class? intersection = ary1 & ary2
- jw2013 13y agohe is probably talking about using hashtable, but that needs linear memory so there is a trade off.
- recursive 13y agoRuby's method uses something like a hashtable internally.
- recursive 13y agoYes, exactly.
- rhizome 13y agoSo, is that really knowing "enough" to avoid the things you mention, or can the heuristic be that you should know the standard library?
- recursive 13y agoThere are things built into some standard libraries that are able to be combined in a way that produces a list intersection, but that are O(n^2). I prefer working in high level languages as much as the next person, but there's no substitute for knowing basic algorithms and data structures.
- rhizome 13y agoI just demonstrated a substitute for knowing basic algorithms and data structures.
- recursive 13y agoYes, you just demonstrated an example of a case where a developer is not hurt by not understanding algorithms or runtime complexity. Here's one where they are: In python, the in operator works on both lists and sets. For one, large numbers of elements will perform very quickly. For the other, it will perform very slowly. If a developer doesn't understand how they work, and where it's appropriate to use each, they can still do something completely terrible without even straying away from basic APIs.
- rhizome 13y agoWhile it seems like you're moving goalposts, this example also appears to be something a person could know without touching on nested loops or O(n) at all. Case in point, 10s of Googling produced this link: http://stackoverflow.com/questions/2831212/python-sets-vs-lists http://stackoverflow.com/questions/2831212/python-sets-vs-li... ...and I don't even use Python yet.
- recursive 13y agoIs it possible to write working code without understanding O()? Definitely. Is it helpful to understand? Definitely.
- rhizome 13y agoOf course, but neither was your point. You were rebutting that algo & bintree knowledge are unnecessary in the vast majority of companies, in favor of the pursuit of O(n) knowledge in candidates. None of your examples validated this, and "should" became merely "helpful."