PHP quick sort problem

WBOY
Release: 2016-09-27 14:18:06
Original
1079 people have browsed it

As shown in the picture: PHP quick method, two writing methods in the loop, the above one is OK, the following one will report errors;

PHP quick sort problem

Error screenshot:

PHP quick sort problem

Reply content:

As shown in the picture: PHP quick method, two writing methods in the loop, the above one is OK, the following one will report errors;

PHP quick sort problem

Error screenshot:

PHP quick sort problem

Did you think

<code>if ($v > $mid) {
    $rightArr[] = $v;
}
if ($v < $mid) {
    $leftArr[] = $v;
}</code>
Copy after login

and

<code>if ($v < $mid) {
    $leftArr[] = $v;
} else {
    $rightArr[] = $v;
}</code>
Copy after login

Does it mean the same thing?

Don’t you consider the situation where $v == $mid?

Related labels:
php
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template