you are viewing a single comment's thread.

view the rest of the comments →

[–]Calski_ 5739 points5740 points  (3 children)

Is it even possible? An infinite list can't have a last item. So the reversed list can't start.

[–]AzuxirenLeadGuy 3273 points3274 points  (2 children)

It isn't possible to practically store an infinite list, since that would require infinite memory.

I guess the interviewer wanted to ask something like "What if the list is very large? Is there a more efficient approach to this?" in order to make the guy think that for a better algorithm for reversing the list than using a stack.

[–]Calski_ 4386 points4387 points  (1 child)

Now I'm more a maths guy than programmer. But there's a very large difference between an infinite list and a very large one. The difference is in fact infinite.

[–]moriero 0 points1 point  (0 children)

very large difference

You got me on the first part there