|
|
|
|
|
by StrawberryFrog
5365 days ago
|
|
> implement an algorithm that finds the value of the element in the middle of a linked list I'm struggling to think of the last time I had to use a linked list for anything. I'd be tempted to give the troll answer: put the elements into a List<T> already, divide list.Count by 2.... Sure if it's doubly linked then you can walk it from both ends and meet in the middle, then think about how to handle the case where there are an even number of elements, but do you really want a serious answer about linked lists in .Net? |
|
From a recruiting point of view, this kind of questions are indicators. They are easy to verify and they are correlated with some other, more relevant skills.
First, knowing your 101 Data structures is correlated to your Computer Science general knowledge. What relevance does it have? It depends on the job description. There are jobs that merely require churning out bland CRUD application code, and it does not make much of a difference if you know this stuff. But, in general, for anything that has strong performance requirements, it might be a concern.
By example, if you let me feed the troll, your solution shows a mix of cleverness, (potential) ignorance and unawareness of the high level goal.. that I might be concerned you would produce something like...
class SortedList extends List{ //... add(E element){ parent.add(element); qsort(this); } //... }
On the other hand, Linked lists also give you a hint of the ability of the candidate to manipulate pointers/references. This may or may not be relevant, again, depending on how often do expect to use this skill in your code base. A trivial solution would let you at least know that the person pays attention to detail and does not leave a mess behind. A more sophisticated approach gives you more information about actual expertise (like, if you know about cycle detection, this is a piece of cake).