[moz] feat: 三种排序算法实现最大值查找 #117

Open
opened 2026-06-21 22:23:00 +00:00 by pangtong-fujunshi · 0 comments
Member

任务

实现三种排序算法,从一堆数字中找到最大值。

算法要求

  1. 冒泡排序法:通过冒泡排序排好序后取最后一个元素
  2. 快速选择法:使用快速选择的 partition 思路直接找最大值
  3. 线性扫描法:一次遍历找最大值

输入

一个数字列表(int 或 float),例如 [3, 1, 4, 1, 5, 9, 2, 6]

输出

列表中的最大值,例如 9

验收标准

  1. 三个函数签名:
    • def find_max_bubble(nums: list[int | float]) -> int | float
    • def find_max_quickselect(nums: list[int | float]) -> int | float
    • def find_max_linear(nums: list[int | float]) -> int | float
  2. 空列表返回 None
  3. 单元素列表返回该元素
  4. 含负数、浮点数的列表正确处理
  5. 附带单元测试(每种算法至少 5 个 test case)
  6. 代码放在 src/algorithms/ 目录
  7. 三种算法的结果一致性测试(同输入三法结果相同)
## 任务 实现三种排序算法,从一堆数字中找到最大值。 ## 算法要求 1. **冒泡排序法**:通过冒泡排序排好序后取最后一个元素 2. **快速选择法**:使用快速选择的 partition 思路直接找最大值 3. **线性扫描法**:一次遍历找最大值 ## 输入 一个数字列表(int 或 float),例如 `[3, 1, 4, 1, 5, 9, 2, 6]` ## 输出 列表中的最大值,例如 `9` ## 验收标准 1. 三个函数签名: - `def find_max_bubble(nums: list[int | float]) -> int | float` - `def find_max_quickselect(nums: list[int | float]) -> int | float` - `def find_max_linear(nums: list[int | float]) -> int | float` 2. 空列表返回 `None` 3. 单元素列表返回该元素 4. 含负数、浮点数的列表正确处理 5. 附带单元测试(每种算法至少 5 个 test case) 6. 代码放在 `src/algorithms/` 目录 7. 三种算法的结果一致性测试(同输入三法结果相同)
pangtong-fujunshi added the type/feat label 2026-06-21 22:23:00 +00:00
Sign in to join this conversation.