RustBook
RustBook copied to clipboard
A book about Rust Data Structures and Algorithms.
// queue.rs // 队列 #[derive(Debug)] struct Queue { cap: usize, // 容量 data: Vec, // 数据容器 } impl Queue { fn new(size: usize) -> Self { Queue { cap: size,...
书写得挺好的,不过偶然发现英文版和中文版同样的内容会出现不一样的代码
https://github.com/QMHTMY/RustBook/blob/main/code/chapter05/interpolation_search.rs 不应该用上界处是否是 target来判断查找的结果 原来的代码: ```code fn interpolation_search(nums: &[i32], target: i32) -> bool { if nums.is_empty() { return false; } let mut high = nums.len() - 1; let mut low =...
7.4.2 Rust 实现二叉查找树 p175 二叉查找树删除节点的图示有误。  这幅图删除了 93 之后应该是 76 或者 94 代替 93 的位置吧。 图示的结果不满足 p168 说的要求。 > 不同于堆的左右子节点不考虑大小关系,二叉查找树左子节点键要小于父节点的键,右 子节点的键要大于父节点键。也就是 left < parent < right 这个规律,其递归地适用于所有 子树。
使用的代码为 https://github.com/QMHTMY/RustBook/blob/8c6ef29bc84672e37ca4d6b90aafccba10e9b6da/code/chapter06/heap_sort.rs 其中, `main` 函数略有不同 (删掉 `nums` 开头的 `0`) ```rust fn main() { let mut nums = [ 54, 32, 99, 18, 75, 31, 43, 56, 21, 22]; heap_sort(&mut nums);...