3 ms·
I wouldn't consider reversing a linked list a data structures question, it's a coding question. Everyone knows what a linked list is and that you have to iterat
by ernestipark 15y ago
I wouldn't consider reversing a linked list a data structures question, it's a coding question. Everyone knows what a linked list is and that you have to iterate through it and flip the "arrows". The tricky part is being able to maintain all the pointers and know how to order your operations and handle any edge cases. That's what questions like these are supposed to check for, can you actually articulate into code a solution that you understand on a high level in your head.
- araneae 15y agoIt's absolutely a data structure question. You have to know what functions are available to you from within the data structure. For instance, in a singly linked list you only have the function "getNext()" and "getHead()"; in a doubly linked list, you have additionally have the function "getPrev()" and "getTail()". If parent asked me this question in an interview I'd probably jokingly say "well, you didn't specify doubly or singly, so I'd just call getTail and then getPrev until I was done!" And then I'd write a recursive function for a singly linked list because everyone likes recursion. How could you possibly answer this question if you didn't know what a linked list was? If you never took a data structures class, you probably used "lists" but you have no idea what the bare bones construction is. Just using lists doesn't mean you know how to write one from scratch.
- RexM 15y agoIf for some reason you don't know what a linked list is, you can always ask. I think it's about admitting when you don't know something just as much as it's about being able to reason through the problem and give a correct answer. All else equal, I'd much rather hire someone who didn't know what a linked list was, but asked and answered correctly, than someone who pretended to know and limped their way through the problem, even if they did eventually give a correct answer.
- arghnoname 15y agoLinked lists are so fundamental, not knowing what they are is a big red flag. Anyone with even a modicum of curiosity about this field, college educated or not, should know what a linked list is, its complexity, and how it is structured.
- ernestipark 15y agoI meant it's not a data structures question in that it doesn't ask anything particularly prodding into understanding deeply something intricate about a data structure. I assume any CS student knows what a linked-list is and can figure out that it has a getNext() function. It's more about coding than understanding a linked list.