News for hackers. Stuff that matters.
Re:U.S. regulators accuse Palantir of bias against Asians by ng12 on Monday September 26, 2016 @09:48PM (#12586992)
Anecdotally, I've learned to expect nothing. I used to ask a graph-based question -- I had to adjust it so that the first step was doing a dead-simple DFS. This tended to weed out a good sixth of candidates and save us both a lot of time. And this was pretty constant against education level and background.
Re:U.S. regulators accuse Palantir of bias against Asians by somedangedname on Monday September 26, 2016 @10:00PM (#12587023)
DFS == Depth First Search?
Re:U.S. regulators accuse Palantir of bias against Asians by ng12 on Monday September 26, 2016 @10:07PM (#12587037)
Yeah, given an acyclic graph print out each node's value. Passing candidates generally got it in five minutes.
Re:U.S. regulators accuse Palantir of bias against Asians by jnordwick on Monday September 26, 2016 @11:48PM (#12587321)
Sometimes I get these questions in interviews and I really don't know if I should be offended. My resume is pretty good, and I wonder who T.F. applies to these places that they have to have such simple weeder questions. Then I get all paranoid that there is some hidden complication and soon I'm producing FizzBuzz in TensorFlow:

http://joelgrus.com/2016/05/23/fizz-buzz-in-tensorflow/

Re:U.S. regulators accuse Palantir of bias against Asians by vacri on Tuesday September 27, 2016 @04:13AM (#12588099)
I think you shouldn't be offended at interview questions around skill unless you've been on the other side of the table. It's eye-opening, the range of people that apply for these positions.
Re:U.S. regulators accuse Palantir of bias against Asians by kirab on Tuesday September 27, 2016 @04:11AM (#12588091)
Should every node's value be printed out exactly once and if so, are there nodes which have two parents?

If so, I would keep the pointers in a set to mark nodes as processed but is there a more elegant solution?

Re:U.S. regulators accuse Palantir of bias against Asians by ng12 on Tuesday September 27, 2016 @11:16AM (#12590219)
I would explicitly tell them that you should revisit nodes, and give them a few examples illustrating that point -- so all they needed to do was traverse edges.
Re:U.S. regulators accuse Palantir of bias against Asians by drakonandor on Tuesday September 27, 2016 @11:00AM (#12590065)
Each node is an object and has a "checked" variable.
Re:U.S. regulators accuse Palantir of bias against Asians by dastbe on Tuesday September 27, 2016 @01:31AM (#12587627)
Do you give them a graph data structure or something that is explicitly a tree?
Re:U.S. regulators accuse Palantir of bias against Asians by dnautics on Tuesday September 27, 2016 @08:48AM (#12589180)
A acyclic graph is isomorphic to a tree, but the way you access the vertices and edges is completely different.
Re:U.S. regulators accuse Palantir of bias against Asians by palunon on Tuesday September 27, 2016 @10:08AM (#12589668)
Depends on your memory representation of the graph. If you simply use the obvious one (a node have a list of pointers to its successors), I don't see the difference except for successors[]/children[]
Re:U.S. regulators accuse Palantir of bias against Asians by dnautics on Wednesday September 28, 2016 @06:14AM (#12596562)
You're right. I mentioned acyclic graph and my mind slipped to general graphs. Although often graphs are represented as say a sparse matrix.
Re:U.S. regulators accuse Palantir of bias against Asians by sheeshkebab on Monday September 26, 2016 @11:33PM (#12587277)
was writing DFS from scratch ever needed to perform dev job or was it a thing that stumped 95% of applicants (and let you read some hacker news/email on your phone/laptop in the mean time)?
Re:U.S. regulators accuse Palantir of bias against Asians by morgante on Tuesday September 27, 2016 @03:23AM (#12587954)
If you ignore the terminology, DFS is basically just recursively walking a graph, something which actually happens all the time in most dev jobs. I'm sure I wrote a DFS long before I had heard the term.

I hate brain teaser interviews as much as the next guy, but being able to do basic operations on basic data structures is pretty much the minimum to be a developer.

Re:U.S. regulators accuse Palantir of bias against Asians by vonmoltke on Tuesday September 27, 2016 @08:40AM (#12589141)
> If you ignore the terminology, DFS is basically just recursively walking a graph, something which actually happens all the time in most dev jobs.

In ten years of full-time professional development I have never needed to recursively walk a graph. Hell, the only data structures in the software I worked on for the first six (real-time signal processing code) didn't use any data structures other than lists, arrays, and C structs. I would not be able to answer the interview question that started this subthread, despite my track record of efficient and well-designed code.

Re:U.S. regulators accuse Palantir of bias against Asians by morgante on Tuesday September 27, 2016 @08:48AM (#12589179)
Are you sure? Keep in mind that a graph doesn't always come up and slap you saying that it's a graph.

This very comment thread is a graph which is being printed depth-first.

Re:U.S. regulators accuse Palantir of bias against Asians by vonmoltke on Tuesday September 27, 2016 @10:26AM (#12589787)
I'm very sure. The signal processing code had no graph structures whatsoever.

That's certainly not the case with the NLP code I have been working on for the past 4.5, but I have never personally needed to search the (usually) trees in a structured manner. Most of our code that searches for things doesn't care about the structure of the graph during the search; it just searches a node list. Once the node is found, structure matters. There are some algorithms that use calculations like shortest path and tree height, but I didn't write the code to actually do that.

Re:U.S. regulators accuse Palantir of bias against Asians by djb_hackernews on Tuesday September 27, 2016 @11:37AM (#12590390)
Do you think you've ever had to do something as algorithmically complex as recursively walk a graph?

Sometimes these questions are used to probe the meta understanding of a candidate and using Graphs/Trees/DFS are universally understood concepts that make doing that easy.

Re:U.S. regulators accuse Palantir of bias against Asians by vonmoltke on Tuesday September 27, 2016 @12:56PM (#12591040)
Define "algorithm". In the broader definition, yes. Kalman filtering, motion compensation, track association, XY-mapping, and similar signal processing algorithms. For NLP it has been various forms of statistical modeling and general multithreaded architecture and coordination.

As for the algorithms typical of computer science, not really. Searching and sorting has not been much a part of what I have done. My experience is mainly in translating math into code, often into code with real-time deadlines.

Re:U.S. regulators accuse Palantir of bias against Asians by ng12 on Monday September 26, 2016 @11:43PM (#12587301)
It only stumped the candidates that clearly wouldn't make it through the rest of the problem. One sixth was a probably a high estimate.

DFS for an acyclic graph is about five lines of code and shows me that you A. know a programming language B. can figure out a data structure. I would argue both are needed to perform a dev job.

Re:U.S. regulators accuse Palantir of bias against Asians by ap22213 on Tuesday September 27, 2016 @02:14AM (#12587779)
I've written DFS about 1-2 times a year, on average, for the last 15 years. Why do I need to? Usually, because I need to modify or create a data structure that is kind of graph-like but not quite. If someone didn't know how to write one or at least derive it, they would confuse a lot of people, so yeah it's kind of important.
Re:U.S. regulators accuse Palantir of bias against Asians by lawnchair_larry on Tuesday September 27, 2016 @05:17AM (#12588273)
No, they'd probably look it up, skim a blog for a few minutes, then figure it out and promptly forget. This is no different than forgetting the order of the arguments to socket() and accusing that person of being incapable of writing networking code.
Re:U.S. regulators accuse Palantir of bias against Asians by ap22213 on Tuesday September 27, 2016 @10:54AM (#12590016)
The difference is that the arguments to socket() were arbitrarily defined, but DFS is an algorithm. Anyone who has taken a intro data structures course should be able to at least derive the pseudo code for DFS.
Re:U.S. regulators accuse Palantir of bias against Asians by DontGiveTwoFlux on Tuesday September 27, 2016 @12:26AM (#12587433)
Eh, I had to write a DFS the other day at work.