How to write the bubble algorithm and quick algorithm (using arrays)? how to write the bubble algorithm and quick algorithm (using arrays )??????
Reply to discussion (solution)
View the data structure.
Why don't I take the initiative to find the answer but wait for someone else to answer you? You can find a bunch of code under Baidu's 'php sorting algorithm Daquan '.
Okay, I'm wrong.
Function insert_sort ($ arr ){
$ Count = count ($ arr );
For ($ I = 1; $ I <$ count; $ I ++ ){
$ Tmp = $ arr [$ I];
$ J = $ I-1;
While ($ arr [$ j]> $ tmp ){
$ Arr [$ j + 1] = $ arr [$ j];
$ Arr [$ j] = $ tmp;
$ J --;
}
}
Return $ arr;
}
$ J. why --
Why?
Because the future is unknown, the security that has passed
Because the future is unknown, the security that has passed
Look for the data structure and take a look at the definitions of these two algorithms. then, try to tap into the code according to your own understanding, and finally look at other people's code to see whether they understand the same as others, this helps you.
Grace has been taught