Question:
How would you reverse a linked list? Have looked in books at school library, and in tutorial. Hope you can point me in the right direction. Thank you for your time.
Answer:
The only way to directly traverse a linked list in reverse is to have the links arranged this way. Normally, this involves a doubly linked list. While a simple linked list only contains a pointer to the next node, a doubly linked list contains both a pointer to the next node and to the previous node. A doubly linked list also requires a Tail pointer that points to the last node in the list. This way, you can traverse the list from either the start or the end.Although doubly linked lists require a little more work to insert and delete nodes, they are very common when that degree of flexibility is required.