You are asked to write
2
methods. Why are you providing 3 ones?
Quote:
public void concatenazione(Lista L,Lista L2) {
Nodo p=head;
while(p.getLink()!=null) {
p=p.setLink(p);
p=p.getLink();
}
}
This should be more similar to
public void concatenazione(Lista L2)
{
Nodo p = head;
Nodo q = L2.getHead();
while(p.getLink()!=null)
p = p.getLink();
while (q != null)
{
p.setLink(qcopy);
p = qcopy;
q = q.getLink();
}
}
The second method should, in just one list traversing, produce the expected output. That is, while traversing the input list, if the item is equal to the passed one, than its postion should be added to the output list.