有序线性表的归并
public class ListMethods
{
public static void mergeList(SequenceList<Integer> listA,SequenceList<Integer> listB,SequenceList<Integer>listC)
{
//线性表的归并 ,假设lista listb都是有序的 归并得到listC也是有序排列
int laLength=listA.size();
int lbLength=listB.size();
int lcLength=listC.size();
int i=0,j=0;
while (i<laLength&&j<lbLength)
{
if(listA.get(i)<listB.get(j))
{
listC.add(listA.get(i));
i++;
}
else
{
listC.add(listB.get(j));
j++;
}
}
while (i<laLength)listC.add(listA.get(i++));
while (j<lbLength)listC.add(listB.get(j++));
}
}