Bobby, that is not constant space because it uses O(N) stack space.
There are obvoius O(N^2)-time O(1)-space algorithms, and obvious O(N) time O(N) space algorithms.
This is my best guess. Assuming you have exclusive access to the list, you can reverse it, walk it, and then reverse it again. Something like this:
#include
#include
struct node {
int value;
struct node * next;
};
void print_backwards( node * head ) {
node * prev = NULL;
node * cur = head;
node * next;
while( cur ) {
next = cur->next;
cur->next = prev;
prev = cur;
cur = next;
}
cur = prev;
prev = NULL;
while( cur ) {
printf( "%d\n", cur->value );
next = cur->next;
cur->next = prev;
prev = cur;
cur = next;
}
assert( prev == head );
}
main() {
node a, b, c;
a.value = 1;
a.next = &b;
b.value = 2;
b.next = &c;
c.value = 3;
c.next = NULL;
print_backwards( &a );
}