I knew recursion immediately and coded it up fine.
Start by clarifying the constraints: the list is immutable, and only printValue() and getNext() are available. Then present a recursive solution that uses the call stack to reverse the order, followed by iterative approaches using an explicit stack or a doubly linked list if mutation were allowed, discussing time/space tradeoffs.
Pro tip: Emphasize that recursion depth is a concern for large lists and propose an iterative solution with an explicit stack to avoid stack overflow, showing awareness of production constraints.
Confirm that the list is immutable, only printValue() and getNext() are available, and that we need to print values in reverse order without modifying the list.
Traverse to the end recursively, then print on the way back. This uses O(n) stack space and O(n) time.
Traverse the list iteratively, pushing values onto a stack, then pop and print. This also uses O(n) space but avoids recursion depth limits.
If the list were mutable, reverse it in place, print, and reverse back. This uses O(1) extra space but modifies the list, which is not allowed here.
Discuss time/space complexity: all approaches are O(n) time; recursion and stack are O(n) space; in-place reversal is O(1) space but requires mutability. Mention that recursion may cause stack overflow for large n.
AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.