Reverse List X34491


Statement
 

pdf   zip   main.cc

html

Consider the following struct for a doubly linked list.

struct list_node { int m_value; list_node* m_previous = nullptr; list_node* m_next = nullptr; };

Implement the function

list_node* reverse(list_node* head);

that reverses in-place the given list, without dynamic memory allocations, and returns a pointer to its new head.

Observation You only need to submit the required classes; your main program will be ignored. Strictly obey the type definitions of the statement.

Information
Author
Xanadu Trading
Language
English
Official solutions
C++
User solutions
C++