🧮 二分查找 (Binary Search)
难度 / Difficulty: 简单 (Easy)
分类 / Category: 查找 (Search)
时间复杂度 / Time Complexity: O(log n)
空间复杂度 / Space Complexity: O(1)
📖 算法简介 / Introduction
二分查找是一种在有序数组中查找目标元素的搜索算法,每次将搜索范围缩小一半。
Binary search finds the target in a sorted array by halving the search range each time.
💡 算法原理 / Principle
在有序数组中,取中间元素与目标比较:根据大小关系排除一半,逐步缩小范围直到找到目标或区间为空。
In a sorted array, compare the middle element with the target. Based on the comparison, eliminate half of the range each time until the target is found or the range is empty.
🎯 适用场景 / Scenarios
排序数组搜索, 确定性问题, 近似查找
Sorted array search, Deterministic problems, Approximate search
🔄 扩展阅读 / Further Reading
- 建议在 LeetCode 或 HackerRank 上刷相关题目
- 对比其他同类型算法的性能差异
- 理解算法背后的数据结构设计思想
| *本文由 AI 自动生成 | Generated by AI* |