3 ms·
No offense, but not knowing BFS is kind of a red flag, even if its for a front-end position. It's the most basic graph / tree traversal algorithm there is. And
by Xyik 10y ago
No offense, but not knowing BFS is kind of a red flag, even if its for a front-end position. It's the most basic graph / tree traversal algorithm there is. And you when you work with the DOM on a daily basis and use libraries that traverse for you its a good idea to have a basic understanding of whats going on under the hood. It's like saying you're a good programmer but not understanding basic concepts about memory management and whether things are stored on the stack or on the heap.
- jmathai 10y agoIt's really not a red flag. Not knowing or having BFS memorized does not indicate that one can't implement it relatively quickly by refreshing oneself on the algorithms. Unless, of course, you mean if all academic papers and material that describe BFS suddenly vanished and you had to come up with a solution yourself in 30 minutes with someone looking over your back. In that case, I agree, it's a red flag for whatever position you're interviewing for.
- Xyik 10y agoWhere do you draw the line then? You can google and stack-overflow answers to pretty much any technical interview question that has a non-subjective answer. BFS is not much more than a loop, a queue and a set to keep track of state (which nodes to visit next and which nodes have been visited). I can't think of many algorithms simpler than that to ask outside of things like fizz-buzz. If you are arguing for whether algorithms are an effective way to gauge a candidate's skill then you should state that.
- tptacek 10y agoIf I took an interview with a random developer at your firm, drawn at random, not including you, and I spontaneously asked them to implement Djikstra's shortest path algorithm from memory, what percentage of them would be able to do that? Djikstra is not only basic and extremely simple, but it's also an algorithm that everyone who takes graph theory --- or really, computer science at all --- learns. I'm guessing 10%.
- Xyik 10y agoThey all got through the interview process so I'm pretty confident about 80% of them would be able to do it and 100% of them would be able to implement BFS. Also yes it's a basic graph algorithm everyone learns, but its inherently much more complicated than BFS which is a simple traversal. It's like bubble sort vs radix sort ... which makes this kind of a loaded question.
- tptacek 10y agoNow, I didn't say BFS, did I? :) I expect they can all do BFS, because your interview process apparently requires that.
- Morgawr 10y agoThe parent was talking about BFS, it's not exactly clear to me why you're asking about Dijkstra's. The two things are entirely different and, as the parent said, it's akin to asking bubblesort vs radix sort.
- tptacek 10y agoMy point is that they are not entirely different; both are academic, simple, basic applications of the kind of graph theory freshmen learn. Described in terms of a heap, Djikstra is barely more complicated than BFS.
- Morgawr 10y agoBFS is far from academic though, it's a very common tree/graph traversal algorithm when you want to traverse in-order, like propagation of events in a UI, or printing contents of a nested data structure for debugging purposes, or searching for the top-most element in a tree that meets your criteria so you can insert a new child subtree (very common operation in nested GUI). Hell, it's not even such an alien concept for a web/frontend developer...