Earlier quoted context omitted.
Then why is tortoise and the hair credited to Floyd if it’s so trivial?
Attribution in science works in mysterious ways, and I don't claim to know how it works. In any case, I didn't say “trivial”. If you can only derive trivial things, then you shouldn't be a computer scientist.
Linked List Problems (2002) [pdf]
71–80 of 113 posts
Re: Linked List Problems (2002) [pdf]
#72Earlier quoted context omitted.
Yeah, until you need to remove an element from the middle in constant time - this is sometimes useful for things like the implementation of an LRU cache.
If you iterate over the list within an order of magnitude as often as you remove an element from the middle, an array will still be faster despite not having constant time removal, no matter the size of the list. To restate, if you have a workload where you iterate over your collection ~500 times, and remove an element from the middle ~1000 times, an array will usually outperform a linked list on a modern computer, n…
Re: Linked List Problems (2002) [pdf]
#73Earlier quoted context omitted.
As others have said, this is actually a, perhaps the best, canonical example of a terrible interview question [1]. [1] https://news.ycombinator.com/item?id=7953725
I liken these questions to a problem with a fancy car. If you have the exact tool it's trivial but if not damn near impossible. And a horrible interview question. It shows only that the interviewee has heard the question before or not.
I am no programmer, and I managed to implement it not too long ago all on my own. It took no more than 10 minutes from idea to working implementation.
Re: Linked List Problems (2002) [pdf]
#74Earlier quoted context omitted.
Attribution in science works in mysterious ways, and I don't claim to know how it works. In any case, I didn't say “trivial”. If you can only derive trivial things, then you shouldn't be a computer scientist.
Are you suggesting computer scientists should be able to derive non trivial results on job interviews? Really?
Re: Linked List Problems (2002) [pdf]
#75Earlier quoted context omitted.
I liken these questions to a problem with a fancy car. If you have the exact tool it's trivial but if not damn near impossible. And a horrible interview question. It shows only that the interviewee has heard the question before or not.
Who couldn't figure out the idea behind tortoise and the hare? Maybe not the implementation, but the concept is probably the simplest way of going about it. I am no programmer, and I managed to implement it not too long ago all on my own. It took no more than 10 minutes from idea to working implementation.
Re: Linked List Problems (2002) [pdf]
#76One of my all-time favourites is this: suppose you have a linked list that eventually cycles: that is, the link of one of the nodes in the list points to a previous node in the list, but not necessarily the first node. Write a function to compute the cycle length of the cycle. Now if it was just a simple circular list, this would be trivial: set a pointer to a node, and move another pointer a node at a time until the…
Is that so?
Re: Linked List Problems (2002) [pdf]
#77"Just say no to linked lists!" https://youtu.be/fHNmRkzxHWs?t=2099
He says because of cache misses due to each element being allocated individually. But then working with references is bad in general? If your vector stores references to objects it's bad? Your object fields point to strings - bad too. Should we ditch Lisp and Java? Note, data should not be continuous to stay in cache. Cache is more like paged virtual memory, it consists of cache lines. Before subscribing to the "neve…
Likewise Java has primitive types, arrays and eventually will get value types, because they already feel the pressure in FinTech of not having them.
Re: Linked List Problems (2002) [pdf]
#78"Just say no to linked lists!" https://youtu.be/fHNmRkzxHWs?t=2099
Although they are so many things that are taught, that should never be used in the real world.
Re: Linked List Problems (2002) [pdf]
#79Earlier quoted context omitted.
I mostly agree with this, however if the job requires a C.S. degree or equivalent and you assume all qualified candidates have been exposed to this, then perhaps it can be a useful question for testing how well you can explain a solution. Just look at how varied and complicated some of the explanations are for this out there. Some take mathematical approaches, others (me) try to boil it down to a few intuitive senten…
Unless you're interviewing Dijkstra, it's a ridiculous question to ask. Anyone who's heard it before knows the answer instantly (I knew the answer before I even finished reading the description) and anyone unfamiliar with it will likely flail.
Not saying it’s a good interview question, just that most good programmers shoukd be able to come up with some form of answer if they understand linked lists.
Re: Linked List Problems (2002) [pdf]
#80Earlier quoted context omitted.
How does one, then, get an insight into the candidate's problem-solving ability in general?
By working with them on a number of non-trivial problems over the course of some time, usually measurable in weeks or months at least.