News for hackers. Stuff that matters.
Re:Why a linked list always come between me and a great job ... by brudgers on Wednesday October 08, 2014 @09:21PM (#8430333)
It's not useless knowledge, but it's less useful than sound judgement regarding which problems require the preparation of a new design and which can be solved with off the shelf components.

Twenty-five years ago It might have been faster to write such a routine than to find it in a library. I found `Collections.reverse()` in under five minutes on StackOverflow and I suck.

Re:Why a linked list always come between me and a great job ... by davelnewton on Thursday October 09, 2014 @07:02AM (#8431624)
I think you've missed my point.

Your "sound judgement" argument is orthogonal to my "being able to reason about fundamental data structures". I doubt most people will need to manually re-write list operations. Most people will need to reason about fundamental data structures.

Ultimately I guess I just find it impossible to believe that basic coding skills are no longer relevant to a large number of commenters here, and that using a "but I can find it on teh Googs" is a reasonable response to "please write a few lines of trivial code that operate on a trivial, but fundamental, data structure".

Re:Why a linked list always come between me and a great job ... by brudgers on Thursday October 09, 2014 @08:11AM (#8431886)
Questions warrant answers commensurate with the effort invested in their construction. "How do you reverse a linked list?" is, on it's face, a waste if time. Beyond being a solved problem:

~ Single or doubly linked?

~ How is the data structure implemented (e.g. is there a header structure and to what does it point)?

~ What does "reverse" mean? mutate in place? create a new list? and if I am to mutate it in place, why?

~ Reversing a linked list is O(n). One implementation us pretty much as good as another. It doesn't really differentiate on insight into the problem.

~ Winding up in a situation where reversing a list is critical smells like bad design...a stack/queue would have been a better choice upstream than a queue/stack.

But though all that may make for interesting conversation, "with a library call" is the only professional answer to "How would you write a function to reverse a list?"

Re:Why a linked list always come between me and a great job ... by zimpenfish on Thursday October 09, 2014 @08:19AM (#8431905)
> "with a library call" is the only professional answer to "How would you write a function to reverse a list?"

Most interviewers - in my experience - would then mark you down as a smartarse and the interview will be all downhill from there.

Re:Why a linked list always come between me and a great job ... by brudgers on Thursday October 09, 2014 @08:56AM (#8432049)
I can in fact be a smartass in the presence of bullshit.[1]

I come from a field where there is an ethos of professionalism, and the answer to "How would you reinforce a strip footing?" is "With rebar."

~ Uncle Bob has a point.

~ Half of all interviewers are below average.

[1] "Bullshit" in the technical sense - when a person knowingly states something misleading or false and openly doesn't care if the person hearing those statements believes them.

Re:Why a linked list always come between me and a great job ... by zimpenfish on Thursday October 09, 2014 @09:02AM (#8432077)
I'm wholly in agreement with you. I suspect questions like this are used in lieu of a sane programming test. Although I guess they might have relevance if you have no library (embedded?) or there are weird constraints (can't think of any).
Re:Why a linked list always come between me and a great job ... by brudgers on Thursday October 09, 2014 @11:36AM (#8433006)
If the company is writing embedded systems, then purchasing a library will probably make more sense than rolling up a complete linked list implementation. If there are weird constraints to the point where reversing the linked list justifies writing special code, then any assumption that the linked list is the right data structure is worthy of doubt.

The truth is that in a few hours, looking at some of the code base and discussing it is going to give both parties a better feel for the fit of person and job than anything else. The interviewer gets a feel for how the candidate will deal with the mess that is someone else's code and build process and the candidate gets a better feel for the mess they will be dealing with.

Re:Why a linked list always come between me and a great job ... by kyllo on Thursday October 09, 2014 @02:09PM (#8434095)
How about if you are implementing a library for a new programming language?

Don't PL developers need to implement things like List.reverse() in their new languages all the time?

Rhetorical question, because I know the answer is yes.

Here's an example for Julia: https://github.com/JuliaLang/DataStructures.jl/blob/master/s...

    function reverse{T}(l::LinkedList{T})
        l2 = nil(T)
        for h in l
            l2 = cons(h, l2)
        end
        l2
    end
(Note that this algorithm is not an in-place reversal, so it wouldn't have worked for the OP's interview.)
Re:Why a linked list always come between me and a great job ... by brudgers on Thursday October 09, 2014 @02:28PM (#8434218)
Can you imagine someone hiring for such a position using such poor pre-interview screening that reversing a list made sense as an interview?

The premise of your remark indicates the absurdity of the claim of relevance. An interview for a position responsible for writing a new language in a language sufficiently low level to require a new `list.reverse` would invariably require implementation of a list type as well...what language includes <List> without a reverse?

Re:Why a linked list always come between me and a great job ... by kyllo on Thursday October 09, 2014 @02:42PM (#8434313)
Do I think that it makes sense? No. I agree with you there. Can I imagine it? Absolutely. It's just how the industry does hiring.

It's pretty well known that Google's hiring process for SDEs is designed to select for skilled computer scientists--the type of people who could do something like implement a stdlib for a new PL if needed. Then, since they can afford to hire only great all-around CS people, they can just allocate people to projects after the hiring decision is made. Of course not every SDE job at Google requires that level of CS skill, and it's massively wasteful to put most people on projects below their skill level, but they can afford to hire that way just because they're Google.

As a side effect, other companies hiring developers are likely to just cargo-cult whatever Google is doing.

Re:Why a linked list always come between me and a great job ... by zimpenfish on Thursday October 09, 2014 @10:52AM (#8432681)
> Most people will need to reason about fundamental data structures.

I've had to use linked lists precisely twice in the last 10 years and both times were because I'd been forced down to C for API reasons. Even then I just used the BSD macros and didn't give it a second thought. When on earth would I ever need to reason about them?

Re:Why a linked list always come between me and a great job ... by smeyer on Wednesday October 08, 2014 @09:40PM (#8430393)
But they want to find out about both kinds of knowledge, your sound judgement on problems and your ability to prepare designs by reasoning about data structures and such. If they only asked questions where the correct answer in production is to come up with a new design, they'd have to ask pretty difficult interview questions. Instead, they ask questions that are simpler and common enough to be implemented by libraries to test your design skills, and your ability to determine when to use off the shelf components should be tested somewhere else. It's quite common to ask more general questions about problem solving and evaluation to get at those sorts of things.
Re:Why a linked list always come between me and a great job ... by brudgers on Thursday October 09, 2014 @09:18AM (#8432144)
It seems to me that data-structures are the wrong level of abstraction for software engineering positions that aren't using C or an equivalent portable assembly language.

In most situations what matters is datatypes, not data structures. That is, queues and stacks, are the important abstractions...and reversing a linked list in non-trivial cases means that:

~ Either a queue was used instead of a stack

~ or vice versa

~ or perhaps a dequeue should have been used.

Does it matter if an ordered bag is layed out in memory sequentially or with links until profiling justifies refactoring? And when you're in Java, refactoring largely going to be a matter of swapping out one set of library calls for another congruent set...and hopefully, all this happens behind an interface.

Using off the shelf components when it makes engineering sense is a hallmark of professionalism. Reinventing linked list functions is, in most situations, a indicator that a person needs close supervision.

Re:Why a linked list always come between me and a great job ... by davelnewton on Thursday October 09, 2014 @10:44AM (#8432638)
I think this misses the point.