Given a linked list. Write a C program to reverse it.
Anónimo
All the solutions mentioned above require Theta(N) auxiliary space. To do it with O(1) space in O(N) time, just keep track of the next node's next field. So if the linked list is A -> B -> C -> D, when you're at A, record the fact that C is B's descendent somewhere. Then change the field to be A <- B. Now go to C and record it's descendent. Use the same process until you reach end of list.