From 31735193a78a27bca5deda3bf2a2223c7b540a10 Mon Sep 17 00:00:00 2001 From: lidy <191685963@qq.com> Date: Fri, 18 Feb 2022 11:41:14 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E6=A0=BC=E5=BC=8F=E4=BC=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Algorithm/ShuffleExp.php | 2 -- Algorithm/SortHelper/SortHelper.php | 1 - Algorithm/insertSort.php | 4 +-- Algorithm/mergeSort.php | 40 +---------------------------- Algorithm/quickSort.php | 2 -- Algorithm/quickSort2.php | 2 -- Algorithm/quickSort3.php | 2 -- Algorithm/selectSort.php | 3 +-- ArrayInfo/ArrayBase.php | 3 --- 9 files changed, 3 insertions(+), 56 deletions(-) diff --git a/Algorithm/ShuffleExp.php b/Algorithm/ShuffleExp.php index 9d5ef54..8ca94ff 100644 --- a/Algorithm/ShuffleExp.php +++ b/Algorithm/ShuffleExp.php @@ -92,5 +92,3 @@ class ShuffleExpRun{ $shuff = new ShuffleExpRun(100000,10,5); $shuff->ShuffleExpRun(); - -?> \ No newline at end of file diff --git a/Algorithm/SortHelper/SortHelper.php b/Algorithm/SortHelper/SortHelper.php index 23e4331..9e1eeb6 100644 --- a/Algorithm/SortHelper/SortHelper.php +++ b/Algorithm/SortHelper/SortHelper.php @@ -32,4 +32,3 @@ class SortHelper{ $arr[$j] = $temp; } } -?> \ No newline at end of file diff --git a/Algorithm/insertSort.php b/Algorithm/insertSort.php index f482588..4ef792e 100644 --- a/Algorithm/insertSort.php +++ b/Algorithm/insertSort.php @@ -38,6 +38,4 @@ foreach ($sortarr as $value) { } echo $str; $endtime = intval(microtime(true) * 1000); -echo '排序耗时:'.($endtime - $start).'ms'."\n"; - -?> \ No newline at end of file +echo '排序耗时:'.($endtime - $start).'ms'."\n"; \ No newline at end of file diff --git a/Algorithm/mergeSort.php b/Algorithm/mergeSort.php index 88e0b50..6c2e17f 100644 --- a/Algorithm/mergeSort.php +++ b/Algorithm/mergeSort.php @@ -82,42 +82,6 @@ function mergeData(&$arr, $l, $mid, $r){ for($i = $l; $i <= $r; $i++){ $arr[$i] = $temparr[$i]; } - - - /** - * 写法2: - */ - /** - * 每次开辟一个新数组($aux)存放待归并的数组,方便后面进行归并使用 - */ - // $aux = []; - // for ($i = $l; $i <= $r; $i++) { - // //解决偏移量的问题 - // $aux[$i - $l] = $arr[$i]; - // } - - - // 初始化,i指向左半部分的起始索引位置l;j指向右半部分起始索引位置mid+1 - // $i = $l; - // $j = $mid + 1; - // for ($k = $l; $k <= $r; $k++) { - - // if ($i > $mid) { // 如果左半部分元素已经全部处理完毕 - // $arr[$k] = $aux[$j - $l]; - // $j++; - // }elseif($j > $r) { // 如果右半部分元素已经全部处理完毕 - // $arr[$k] = $aux[$i - $l]; - // $i++; - // }elseif($aux[$i - $l] < $aux[$j - $l]) { // 左半部分所指元素 < 右半部分所指元素 - // $arr[$k] = $aux[$i - $l]; - // $i++; - // }else{ // 左半部分所指元素 >= 右半部分所指元素 - // $arr[$k] = $aux[$j - $l]; - // $j++; - // } - // } - // print_r($arr); - // exit; } $start = microtime(true); @@ -127,6 +91,4 @@ $endtime = microtime(true); echo '排序耗时:'.($endtime - $start) .'毫秒'."\n"; for ($i=0; $i < count($arr); $i++) { echo $arr[$i].', '; -} - -?> \ No newline at end of file +} \ No newline at end of file diff --git a/Algorithm/quickSort.php b/Algorithm/quickSort.php index e89d2dd..c140436 100644 --- a/Algorithm/quickSort.php +++ b/Algorithm/quickSort.php @@ -67,5 +67,3 @@ quickSort($arr); for ($i=0; $i < count($arr); $i++) { echo $arr[$i].', '; } - -?> \ No newline at end of file diff --git a/Algorithm/quickSort2.php b/Algorithm/quickSort2.php index f48901e..a1dd3f7 100644 --- a/Algorithm/quickSort2.php +++ b/Algorithm/quickSort2.php @@ -86,5 +86,3 @@ quickSort($arr); for ($i=0; $i < count($arr); $i++) { echo $arr[$i].', '; } - -?> \ No newline at end of file diff --git a/Algorithm/quickSort3.php b/Algorithm/quickSort3.php index cd9d81a..71438d1 100644 --- a/Algorithm/quickSort3.php +++ b/Algorithm/quickSort3.php @@ -62,5 +62,3 @@ quickSort($arr); for ($i=0; $i < count($arr); $i++) { echo $arr[$i].', '; } - -?> \ No newline at end of file diff --git a/Algorithm/selectSort.php b/Algorithm/selectSort.php index 9ba51c7..90c68f6 100644 --- a/Algorithm/selectSort.php +++ b/Algorithm/selectSort.php @@ -34,5 +34,4 @@ $sortarr = [100,4,5,6,7,2,44,59,67,57,45,71,82,85,98,94]; $sort_arr = selectSort($sortarr); for ($i=0; $i < count($sort_arr); $i++) { echo $sort_arr[$i].', '; -} -?> \ No newline at end of file +} \ No newline at end of file diff --git a/ArrayInfo/ArrayBase.php b/ArrayInfo/ArrayBase.php index 4cbf349..dcc7283 100644 --- a/ArrayInfo/ArrayBase.php +++ b/ArrayInfo/ArrayBase.php @@ -233,6 +233,3 @@ class ArrayBase return $str; } } - - - -- Gitee