ridesoft/quicksort

PHP 实现的快速排序

1.0.0 2016-02-28 17:00 UTC

This package is not auto-updated.

Last update: 2024-09-14 19:04:00 UTC


README

Coverage Status Latest Stable Version Total Downloads Latest Unstable Version License

PHP 实现的 快速排序 算法:快速排序是一种基于“分而治之”范式的有效排序算法

  • 是基于比较的最佳算法
  • 最佳情况:Θ(n log n)
  • 最坏情况:Θ(n^2)

快速排序与 PHP 用于所有 排序函数 的算法相同,因此最好使用 PHP 核心库。此库仅具有学术目的

安装

使用 composer 安装

"require": {
        "ridesoft/quicksort: "~1.0.0"
    }

使用

<?php

use Ridesoft\Algorithm\Quicksort\QuicksortArray;

$quicksortArray = new QuicksortArray([5, 7, 200, 300, 1, 2, 90, 7, 2000, 69, 50, 30, 9, 11]);
$sortedArray = $quicksortArray->getSortedArray()

$sortedArray 现在是:[1, 2, 5, 7, 7, 9, 11, 30, 50, 69, 90, 200, 300, 2000]