We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 070559a commit efaab21Copy full SHA for efaab21
package/Sort/MergeSort.php
@@ -60,6 +60,7 @@ public function mSort(&$arr, $left, $right)
60
*/
61
public function mergeArray(&$arr, $left, $center, $right)
62
{
63
+ echo '| '.$left.' - '.$center.' - '.$right.' - '.implode(',',$arr).PHP_EOL;
64
//设置两个起始位置标记
65
$a_i = $left;
66
$b_i = $center + 1;
@@ -92,4 +93,29 @@ public function mergeArray(&$arr, $left, $center, $right)
92
93
//do some test:
94
new mergeSort([4, 7, 6, 3, 9, 5, 8]);
95
96
+/*
97
98
+| 0 - 0 - 1 - 4,7,6,3,9,5,8
99
+| 2 - 2 - 3 - 4,7,6,3,9,5,8
100
+| 0 - 1 - 3 - 4,7,3,6,9,5,8
101
+| 4 - 4 - 5 - 3,4,6,7,9,5,8
102
+| 4 - 5 - 6 - 3,4,6,7,5,9,8
103
+| 0 - 3 - 6 - 3,4,6,7,5,8,9
104
+
105
+array(7) {
106
+ [0] =>
107
+ int(3)
108
+ [1] =>
109
+ int(4)
110
+ [2] =>
111
+ int(5)
112
+ [3] =>
113
+ int(6)
114
+ [4] =>
115
+ int(7)
116
+ [5] =>
117
+ int(8)
118
+ [6] =>
119
+ int(9)
120
+}
121
+ */
0 commit comments