|
|
| 名称 |
数据结构选择器 |
| 描述 |
根据操作需求选择最优数据结构 allowed-tools: - 读取 - 写入 - 搜索 - 全局匹配 |
数据结构选择器技能
目的
根据所需操作、操作频率以及时间/空间约束选择最优数据结构。
能力
- 分析所需操作(插入、删除、查询、更新)
- 匹配到最优数据结构
- 考虑时间/空间权衡
- 为定制需求建议增强方案
- 通过复杂度分析比较替代方案
目标流程
选择框架
操作分析
- 需要哪些操作?
- 每个操作的频率/优先级如何?
- 约束条件是什么(N, Q, 时间限制)?
- 是否需要持久化?
- 是否需要范围操作?
常见选择模式
| 操作 |
最佳选择 |
| 插入、删除、搜索 |
二叉搜索树 / 哈希表 |
| 范围求和、点更新 |
树状数组 |
| 范围查询、范围更新 |
线段树 + 懒标记 |
| 合并、查找 |
并查集 |
| 添加/移除时的最小/最大值 |
多重集 / 堆 |
| 前驱/后继 |
有序集合 / 二叉搜索树 |
输入模式
{
"type": "object",
"properties": {
"operations": {
"type": "array",
"items": {
"type": "object",
"properties": {
"name": { "type": "string" },
"frequency": { "type": "string" },
"constraints": { "type": "string" }
}
}
},
"constraints": { "type": "object" },
"preferences": { "type": "array" }
},
"required": ["operations"]
}
输出模式
{
"type": "object",
"properties": {
"success": { "type": "boolean" },
"recommended": { "type": "string" },
"complexities": { "type": "object" },
"alternatives": { "type": "array" },
"augmentations": { "type": "array" },
"reasoning": { "type": "string" }
},
"required": ["success", "recommended"]
}