4 ms·
C'mon man. A linked list. edit: To use one, you need a mental model of how they work, so you should be able to write one. Not a great one... just one that work
by hughw 10y ago
C'mon man. A linked list.
edit: To use one, you need a mental model of how they work, so you should be able to write one. Not a great one... just one that works.
- Sharlin 10y agoA linked list is one of those things everybody thinks is trivial to write until they actually try to write one that supports all the normal operations and actually works in all corner cases.
- robotresearcher 10y agoWhich is one of the reasons why we give it has homework in college. Not because you're going to do it in the workplace, but because (a) you see how the implementation entails the big-O behaviour you learned about, and (b) it's simple but tricky, thus training you to consider every aspect carefully. Aspect (b) is why people ask about it in interview questions. You are not expected to remember the details, you are expected to think about them as you go.
- NotSammyHagar 10y agoWhat are all those corner cases and hard problems? I routinely ask interview subjects to write code to manage a linked list (it was a small part of a problem in a previous job), and I've been asked to write a ll class. Writing a linked list is like hiring someone to be a professional driver, and you want to make sure they know that you can change tires, and that one should adjust mirrors to be able to see behind the car.
- ahallock 10y agoI suppose you're right, but really, in what context do you need to do this? I've never had to do this in over 15 years of software development. I remember learning LLs in college, and it's good foundational knowledge -- it teaches you how to solve problems. I'm not saying we shouldn't learn these core concepts and algorithms, just that some people want to feel better about themselves and make others feel inferior when they can't remember something at a moment's notice, especially something they haven't used in over a decade.
- hughw 10y agoI might need you to build something listy on disk, and I would say, "you can give the records two-element headers and make it work like a doubly linked list"... you would know exactly how to do that.
- hughw 10y agoI had to do something like this a year or so ago -- built a malloc in js for managing WebGL memory blocks.