News for hackers. Stuff that matters.
Re:Harder programming questions do a worse job of predicting... by tombert on Monday February 18, 2019 @02:43PM (#19193672)
I go back and forth about how I feel about doing heavy algorithm/data-structure stuff in interviews. On the one hand, I have never once written any kind of sort algorithm or LRU cache by hand for a production system, because why would I? Pretty much every language's standard library has a fairly-optimized sort and caching thing built in, and if they don't then there's still probably a million outside libraries to do it for me.

On the other hand, I genuinely do feel theory is really important. While not knowing the minutia of a tim-sort doesn't indicate that you'll be a bad engineer, not knowing the runtime efficiency of a sort can lead to some really awful code. Not knowing when to use a hash table instead of a nested-for loop can be a sign that you don't really know what you're doing, and not knowing some rough theory on concurrency indicates that I might be stuck debugging your race conditions or deadlock.

I try to not be a complete jerk and I won't do stuff like give out an NP-complete problem (which an interviewer gave me once), nor will I ask for intimate details of how one would implement CSP, but I do tend to focus on theory-heavy questions more than my peers, but I try to give a fairly-generous amount of hints so that people don't get too stuck.

Re:Harder programming questions do a worse job of predicting... by KallDrexx on Monday February 18, 2019 @03:51PM (#19194324)
> On the other hand, I genuinely do feel theory is really important. While not knowing the minutia of a tim-sort doesn't indicate that you'll be a bad engineer, not knowing the runtime efficiency of a sort can lead to some really awful code. Not knowing when to use a hash table instead of a nested-for loop can be a sign that you don't really know what you're doing, and not knowing some rough theory on concurrency indicates that I might be stuck debugging your race conditions or deadlock.

Theory is important but what's more important is how someone applies the theory to actual problem solving.

Reversing a binary tree isn't testing your knowledge of theory as much as it's really just testing memorization of a very very specific application. Knowing how to reverse a binary tree or how a hash map works is pointless if the person can't identify when to use them when solving an actual higher level problem. No one is ever given a binary tree and told to reverse it in the real world, they are given a business problem that you identify can be solved efficiently by modelling it as a binary tree and reversing it.

I'd bet most of the good people who fail the "reverse a binary tree" type of questions would succeed if you give them a realistic problem to solve without forcing a very specific solution onto them. Either they will come up to the realization that the solution is to think of the problem in terms of binary tree or they won't.

And neither is a terribly bad answer either. If they recognize you gave them a problem that can be represented as a binary tree and efficiently solved by reversing it then there you go, not only did you prove they knew the "theory" but they knew how to apply it as well. If they don't recognize it you gain valuable insight into their line of thinking and they might find novel ways to represent the problem and apply other theoretical concepts that solve it efficiently (maybe more maybe less).

Re:Harder programming questions do a worse job of predicting... by tombert on Monday February 18, 2019 @05:44PM (#19195174)
I don't think you're wrong in general, but in one specific case I actually can give an example where me not knowing how a hash-map worked was really bad. I was working on a very limited set of memory for a small embedded thing when I was an intern, and was using hashmaps all over the place because they're magic, and kept getting out of memory exceptions.

I learned later that hashmaps are inherently O(n) (or O(log n)), or they take a lot of memory; internal arrays can get super huge if you're not careful.

In this particular case, an ugly nested for-loop was the immediate solution, and eventually I was able to cheat a little and have hard-coded integer indexes and was able to use an array.

Anyway, your point is valid, I just figured I'd give an example where knowing the internals for a hash table would have saved me a lot of time.

Re:Harder programming questions do a worse job of predicting... by gejjaxxita on Wednesday February 20, 2019 @08:12PM (#19213665)
Hash maps are O(1)
Re:Harder programming questions do a worse job of predicting... by riskneutral on Monday February 18, 2019 @06:06PM (#19195302)
> On the other hand, I genuinely do feel theory is really important. While not knowing the minutia of a tim-sort doesn't indicate that you'll be a bad engineer, not knowing the runtime efficiency of a sort can lead to some really awful code.

OK but why don’t these interviewers ever ask “internals” questions? How does a CPU works, or what the different levels of memory hierarchy are, what an interrupt request is, what is pipelining, what is SIMD, what is a GPU, etc. Or how about compiler internals, what are the different stages in a compilers, what are the different grammars and parsers, what is an AST, what is interpretation, compilation, bytecode, JIT, and how does it work? How about database internals? How is a database implemented, what is relational algebra, what is normalization, what is a data model, how do indices work? Similar questions can be asked about operating system internals, networking, floating point arithmetic, etc. In my experience, no interviewer has ever asked me these questions. And as an interviewer, I have consistently been disappointed with candidates’ inability to answer basic and relevant “internals” questions. Ironically, the algorithms and data structures questions that are commonly asked in interviews are outdated ways of thinking which do not take the underlying hardware reality into account (memory hierarchy and parallelism). It could be because a lot of these FANG(-like) “engineers” are themselves not knowledgeable to ask such questions. Or they are aware that new comp sci graduates are unlikely to really understand anything at a deep level, but all comp sci students are drilled on algorithms and data structures. If you are targeting a very specific age group (0-5 years experience) and want a standardized test then I guess asking CS201 exam questions in a job interview make sense. Companies prefer the 0-5yrs experience segment because they’re cheap, don’t have children, are easy to exploit, and they are easier to “mold” into your corporate culture.

Re:Harder programming questions do a worse job of predicting... by vkou on Monday February 18, 2019 @08:40PM (#19196057)
> In my experience, no interviewer has ever asked me these questions

Because not everyone writing Java code has had a background that exposes them to compiler internals or grammars and parsers.

But everyone writing Java code should at least be a little bit arsed to figure out what common data structures do - or how to write two for loops that print out "1 2 fizz 4 buzz"...

Re:Harder programming questions do a worse job of predicting... by andmed3 on Tuesday February 19, 2019 @02:00AM (#19197180)
Where are those companies who ask such questions, and not for a embedded software engineer role but for someone higher up stack. I wish I knew
Re:Harder programming questions do a worse job of predicting... by Waterluvian on Monday February 18, 2019 @03:16PM (#19193986)
I think the important thing here is the difference between understanding complexity and implementing a sorting algorithm.

If I were hiring a carpenter I would want to know they understand their tools and when to use them. I don't care if they don't know how to make them. But of course knowing how to make them suggests an intimate appreciation for the craft (looking your way Matthias Wandel)

Re:Harder programming questions do a worse job of predicting... by sjg007 on Monday February 18, 2019 @03:34PM (#19194162)
The flip side would be asking a carpenter to do trigonometry problems or something... Anyway, what's most important is measure twice and cut once. That and following a blueprint and going the extra mile.
Re:Harder programming questions do a worse job of predicting... by gedy on Monday February 18, 2019 @03:37PM (#19194192)
> On the other hand, I genuinely do feel theory is really important.

My beef with this in interviewing is that a huge chunk of modern programming work is developing UIs - and user interface theory and skills are treated like some softball thing. You ask UI-related questions to interviewers and half the time you get some shrug "oh we use whatever", etc.

Re:Harder programming questions do a worse job of predicting... by joshuamorton on Monday February 18, 2019 @03:47PM (#19194287)
This depends highly on the domain. I'm the only person on my team with any level of frontend work in the past ~2 years. And when I did, I was able to consult with UX experts and designers.

I can't say that theory is more universal than frontend, though anecdotally, for me, it is. But ui isn't universal.

Re:Harder programming questions do a worse job of predicting... by Apocryphon on Monday February 18, 2019 @03:26PM (#19194084)
> Not knowing when to use a hash table instead of a nested-for loop

On the flip side, the O(1) look-up nature of hash tables make them the no-brainer data structure to use, at least for passing programming interviews. Perhaps more interesting test questions would be when not to use hash tables.

Re:Harder programming questions do a worse job of predicting... by entee on Monday February 18, 2019 @04:07PM (#19194468)
Fully agreed. Most questions I got when I started out as a data scientist interviewing for jobs were pretty simple: "use a hash table to count stuff, join stuff, lookup stuff". However not once did I get asked, "why do databases not exclusively use hash tables if they're so good?" That's a much more interesting question, though perhaps out of scope for a data scientist. I'd add that I've never heard that question being asked of engineers, I'd love to hear of people out there getting it though.
Re:Harder programming questions do a worse job of predicting... by tombert on Monday February 18, 2019 @04:10PM (#19194488)
I actually got that exact question once, or pretty close to it. I'm paraphrasing, but the question was "Hash tables are cool, but what's a data structure they might use in a DB besides that?". This was pretty early in my career, so it stumped me, and he pointed out that a binary tree is used semi-often because of ordering.
Re:Harder programming questions do a worse job of predicting... by pedrosorio on Tuesday February 19, 2019 @12:06AM (#19196743)
I am surprised B-trees were not the first data structure in that discussion, as they are "famous" for being used in DBs.

Although these days one should talk about "learned index structures" instead, I guess :)

Re:Harder programming questions do a worse job of predicting... by bunderbunder on Monday February 18, 2019 @02:57PM (#19193805)
I'd be curious to see if there is any value in questions that focus on understanding of the basic ideas behind algorithms and data structures as a subject. Time complexity, sure, but what I would really want to know is, given a description of a data structure and some algorithms for manipulating it, can you identify the invariants that should be true of these rules?

That sort of thing might give a better sense of if someone has an instinct for how to verify whether the code is working. And, by extension, if they have a grasp of some concepts that go a long way toward helping a person come up with more reliable and maintainable designs.