This commit is contained in:
ubuntu
2026-03-26 15:33:47 +09:00
parent fff89a2d9b
commit 69253957ee
13 changed files with 357 additions and 0 deletions

View File

@@ -0,0 +1,33 @@
sequenceDiagram
participant M as Main (index.js)
participant QS as QuickSort (quickSort.js)
M->>M: 定义测试数组 testArrays
M->>QS: quickSort([], false)
QS-->>M: 返回 []
M->>M: console.log 输出空数组结果
M->>QS: quickSort([42], false)
QS-->>M: 返回 [42]
M->>M: console.log 输出单元素结果
M->>QS: quickSort([3,6,8,10,1,2,1], false)
QS->>QS: 选取 pivot = arr[middle]
QS->>QS: 分区为 left, middle, right
QS->>QS: quickSort(left, false) 递归
QS->>QS: quickSort(right, false) 递归
QS-->>M: 返回升序排序结果
M->>M: console.log 输出升序结果
M->>QS: quickSort([3,6,8,10,1,2,1], true)
QS->>QS: 选取 pivot = arr[middle]
QS->>QS: 分区为 left(>pivot), middle, right(<pivot)
QS->>QS: quickSort(left, true) 递归
QS->>QS: quickSort(right, true) 递归
QS-->>M: 返回降序排序结果
M->>M: console.log 输出降序结果
M->>QS: quickSort([1,2,3,4,5], false)
QS-->>M: 返回已排序数组
M->>M: console.log 输出已排序数组结果