C++ help! Write a function merge that merges two lists into one, alternating ele- ments from each list until the end of one of the lists has been reached, then append- ing the remaining elements of the other list. For example, merging the lists containing A B C and D E F G H should yield the list A D B E C F G H. However, do not create a third list; insert values of the second list into the first list. Your function should not fail when one (or both) of the lists is (are) empty. Write and test your merge function in a main function. Please help. Thanks a ton! Solution hey heres the code , when you said \'lists\' I used STL, if you think I need to implement linked lists using struct then post comment. #include <iostream> #include <list> using namespace std; void merge(list<char>,list<char>); // Simple example uses type int int main() { list<char> L; /*list 1 elements A B C */ L.push_front(\'A\'); L.push_back(\'B\'); L.push_back(\'C\'); list<char> K; /*list 2 elements D E F G H */ K.push_back(\'D\'); K.push_back(\'E\'); K.push_back(\'F\'); K.push_back(\'G\'); K.push_back(\'H\'); cout << endl; /*Calling merge function */ merge(L,K); return 0; } void merge(list<char> A,list<char>B) { list<char>::iterator i; list<char>::iterator k; /*here it will go through loop to merge second list with first list*/ i=A.begin(); for(k=B.begin(); k!=B.end(); ++k) { if(i!=A.end() && k!=B.end()) { if((++i)!=A.end()) A.insert(i,*k);Â Â /*insert function of list is used to insert element at position mentioned in first argument i (here we first incremented i and then we check if its not end of list then insert element)*/ else A.push_back(*k); } else if(i==A.end() || k!=B.end()) { A.push_back(*k); } else break; } cout<<endl; for(i=A.begin(); i != A.end(); ++i) cout << *i << \" \"; } Output : A D B E C F G H .