How i can write a complete program in c++ to implement the link list operations as following?
a. Write a routine to make two lists L1 and L2 with 5 elements given by the user at run time. Or add two lists with its elements in the main function.
b.Write a routine to compute L1 ∩ L2 using only the basic list operations.
c. Print out L1, L2, and L1 ∩ L2.
For example if you have
L1 = {1, 3, 4, 6, 7}
L2 = {2, 5, 6, 7, 8}
So the
L1 ∩ L2 = {6, 7}
How i can write a complete program in c++ to implement the link list operations as following?
1. Write two Lists that each supports one integer..
2. Compare element #1 in L1 with whole elements in L2,
Compare element #2 in L1 with whole elements in L3, and so on..
3. build a new list (lets say L3) which supports one integer that save everytime you find same integer in comparation (2)
eg :
for(headL1, tailL1, next)
{
int a = currL1;
for(headL2, tailL2, next)
{
int b = currL2;
if (a == b) push to L3;
}
}
HTH,
niccie_11
peony
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment