Question: In the main function, you are given a list, L, and another list, P, containing integers sorted in ascending order. The operation printLots(L,P) will print

In the main function, you are given a list, L, and another list, P, containing integers sorted in ascending order. The operation printLots(L,P) will print the elements in L that are in positions specified by P. For instance, if P = 1, 3, 4, 6, the elements in positions 1, 3, 4, and 6 in L are printed. In this case, for L=10,9,8,7,6,5,4,3, positions 1, 3, 4, and 6 in L are 9, 7, 6, 4. Write the procedure printLots(L,P). You may use only the public STL container operations. What is the running time of your procedure?

#include #include using namespace std;

template void printList(list L) { typename list < Object >::const_iterator lIter ; int start = 0; lIter = L.begin(); cout<<"{"; for (lIter=L.begin(); lIter != L.end(); lIter++) { cout<<*lIter<<" "; } cout<<"}"<

template void printLots(list List, list Position) { //Add code here. }

int main () { // constructors used in the same order as described above: list P={1,3,4,6}; list L={10,9,8,7,6,5,4,3}; printList(P); printList(L); printLots(L,P); return 0; }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!