[新建 Feature] 搜索ing and Sorting Algorithms
- Added reference implementations for searching (linear, binary) and sorting (bubble, quicksort, merge sort) algorithms.
- Useful for interview prep and algorithmic learning.
#[Sample] JS Algorithm (Binary 搜索):
function binary搜索(arr, target) {
let left = 0, right = arr.length - 1;
while (left <= right) {
const mid = Math.floor((left + right) / 2);
if (arr[mid] === target) return mid;
if (arr[mid] < target) left = mid + 1;
else right = mid - 1;
}
return -1;
}
[新建 Feature] 搜索ing and Sorting Algorithms
#[Sample] JS Algorithm (Binary 搜索):
function binary搜索(arr, target) {
let left = 0, right = arr.length - 1;
while (left <= right) {
const mid = Math.floor((left + right) / 2);
if (arr[mid] === target) return mid;
if (arr[mid] < target) left = mid + 1;
else right = mid - 1;
}
return -1;
}