Combine Lists

Create a function that combines two lists into one. For example, if list A consists of 1, 2, 3, 4 and list B consists of 5, 6, 7, 8; after calling the function, list A should consists of 1, 2, 3, 4, 5, 6, 7, 8 and list B should contain nothing.

Use the following incomplete function definition.

void combine(Node* &head1, Node* &head2) { 
    // . . .
}


Improve this page