3 ms·
“It depends on how often the data will change. A linked list will be good for [situation x], but a vector might give better performance in [situation y].” I’d
by blowski 9y ago
“It depends on how often the data will change. A linked list will be good for [situation x], but a vector might give better performance in [situation y].”
I’d give more points for that answer because it shows a deep understanding.
- reificator 9y agoI'd agree with that in the general case, but in the situation as given I think there's not much benefit to using a linked list. Perhaps ergonomics, but that's subjective and relative to the codebase in question, and I tend to prefer the ergonomics of a vector personally. If you have an example of why a linked list would be a better choice in a given situation, I'd love to learn more. Here's an example performance graph, but I encourage you to try it yourself if you're curious: https://www.codeproject.com/KB/cpp/340797/linux_insert1.png https://www.codeproject.com/KB/cpp/340797/linux_insert1.png
- blowski 9y agoI’ll assume you’re right as I have no knowledge in this area. My suggestion was just how I would handle the question in an interview.
- reificator 9y agoI'm in a much more dangerous position: I have a little knowledge in that area.
- jhasse 9y agoHe wanted to explain his answer, but the interviewer cut him off :/
- bradknowles 9y agoThe only “correct” answer here is “linked list”. Any other answer is officially “wrong”. I’ve had interviews like that. If the fundamental basis for the question is wrong, and the person asking the question doesn’t understand the material in front of them, then it doesn’t matter. What’s annnoying to me is when companies keep contacting me about job openings they have, but where the interview process works like this. There’s a reason why I don’t work at companies like that, and I no longer respond to invitations from companies like that. I won’t name any names here, but I don’t think anyone here would be surprised.