get pointer to the node which will be the last node of the final list
Node * last_node ; if ( head1 -> prev -> data < head2 -> prev -> data ) last_node = head2 -> prev ; else last_node = head1 -> prev ;