diff --git a/02_selection_sort/php/01_selection_sort.php b/02_selection_sort/php/01_selection_sort.php new file mode 100644 index 0000000..ed30564 --- /dev/null +++ b/02_selection_sort/php/01_selection_sort.php @@ -0,0 +1,26 @@ + $list[1] ? $list[0] : $list[1]; + } + $subMax = recursiveMax(array_splice($list, 1)); + return $list[0] > $subMax ? $list[0] : $subMax; +} + +echo recursiveMax([1, 5, 10, 25, 16, 1]); // 25 diff --git a/04_quicksort/php/05_quicksort.php b/04_quicksort/php/05_quicksort.php new file mode 100644 index 0000000..8bf4317 --- /dev/null +++ b/04_quicksort/php/05_quicksort.php @@ -0,0 +1,21 @@ + $pivot; }); + return array_merge(quicksort($less), [$pivot], quicksort($greater)); + } +} + +var_dump(quicksort([10, 5, 2, 3])); // [2, 3, 5, 10]