Hey all, I have two problem assignments that I can't seem to get:
here is the first: You are given to linked lists L, and P, containing integers sorted in ascending order. The operation printLots(L, P) will print the elements in L that are specified by P. Write printLots.
this first one I think I figured out, here it is:
Code:
void printLots( list L, list P)
{
for ( int i = 0, P.first(), L.first(); !P; ++P){
i = P() - i; //number of nodes to traverse
for ( int j = 1; (j <= i) && ( !L ); i++, ++L){
if ( !L == 0 )
break;
std::cout << L() << std::endl;
}
}
}
sorry about the sloppy code, but it is a "hand written" assignment. I'm not even sure that it compiles, but I think my logic is right.
Anyhow, here is the second one, where I don't know how to quite start:
---Given two sorted list L1, and L2, write a procedure tp compute L1 (upside down U) L2 using only the basic list operations.
any help will be appreciated,
axon