Home > Back-end >  Topic is: will list changed merged into array circulation way, prepare the operation of singly linke
Topic is: will list changed merged into array circulation way, prepare the operation of singly linke

Time:10-05

//an array of circular manner
La void MergeList_Sq (int [], int Lb, int [] Lc)
{
Int pa, pb, PC, pa_last, pb_last;
Pa=pb=PC=0;
Pa_last=La. Length - 1;//points to the last element of the La table address
Pb_last=Lb. Length - 1;//refers to the last element of Lb table address
While (pa<=pa_last & amp; & Pb<={pb_last)
If (a [pa] <=b/pb) c=[pc++] a [pa++];
The else c [pc++] [pb++]=b;
}
While (pa<==pa_last) c [pc++] a [pa++];
While (pb<=pb_last) c [pc++] [pb++]=b;
}
} question want to ask next third from bottom a while, the back is what mean

CodePudding user response:

Through merging algorithm own reading to know the first
La and Lb is already sorted, and it is small in the former greatly in the

First while is two list also has data, compare the size and filling into Lc
After a while all mean La and Lb one already all in the Lc, they don't have to compare the rest of the, directly to the Lc just continue to put inside

First to understand 2 merge
Then don't use a computer program, the manual processing, will be how to deal with,
Want to know how to do 2 merge again to see the realization of the code
What happened, don't understand the algorithm of light on a ghost with code!
  • Related