🧮 插入排序 (Insertion Sort)
难度 / Difficulty: 简单 (Easy)
分类 / Category: 排序 (Sorting)
时间复杂度 / Time Complexity: O(n²)
空间复杂度 / Space Complexity: O(1)
📖 算法简介 / Introduction
插入排序类似于打牌时整理手牌的过程,将每个元素插入到已排序序列的适当位置。
Insertion sort works like arranging playing cards - insert each element into its correct position in the sorted portion.
💡 算法原理 / Principle
从第二个元素开始,将每个元素与已排序序列从后向前比较,找到合适位置插入。适合近乎有序的数据。
Starting from the second element, insert each element into its correct position in the sorted portion.
🎯 适用场景 / Scenarios
近乎有序数据, 小规模数据, 在线排序
Nearly sorted data, Small datasets, Online sorting
🔄 扩展阅读 / Further Reading
- 建议在 LeetCode 或 HackerRank 上刷相关题目
- 对比其他同类型算法的性能差异
- 理解算法背后的数据结构设计思想
| *本文由 AI 自动生成 | Generated by AI* |