mirror of
https://github.com/krahets/hello-algo.git
synced 2026-04-14 10:20:40 +08:00
1. Add build script for Java.
2. Add height limitation for code blocks in extra.css. 3. Fix "节点" to "结点".
This commit is contained in:
@@ -10,7 +10,7 @@ pub fn AVLTree(comptime T: type) type {
|
||||
return struct {
|
||||
const Self = @This();
|
||||
|
||||
root: ?*inc.TreeNode(T) = null, // 根节点
|
||||
root: ?*inc.TreeNode(T) = null, // 根结点
|
||||
mem_arena: ?std.heap.ArenaAllocator = null,
|
||||
mem_allocator: std.mem.Allocator = undefined, // 内存分配器
|
||||
|
||||
@@ -59,7 +59,7 @@ pub fn AVLTree(comptime T: type) type {
|
||||
// 更新结点高度
|
||||
self.updateHeight(node);
|
||||
self.updateHeight(child);
|
||||
// 返回旋转后子树的根节点
|
||||
// 返回旋转后子树的根结点
|
||||
return child;
|
||||
}
|
||||
|
||||
@@ -73,7 +73,7 @@ pub fn AVLTree(comptime T: type) type {
|
||||
// 更新结点高度
|
||||
self.updateHeight(node);
|
||||
self.updateHeight(child);
|
||||
// 返回旋转后子树的根节点
|
||||
// 返回旋转后子树的根结点
|
||||
return child;
|
||||
}
|
||||
|
||||
@@ -132,7 +132,7 @@ pub fn AVLTree(comptime T: type) type {
|
||||
self.updateHeight(node); // 更新结点高度
|
||||
// 2. 执行旋转操作,使该子树重新恢复平衡
|
||||
node = self.rotate(node);
|
||||
// 返回子树的根节点
|
||||
// 返回子树的根结点
|
||||
return node;
|
||||
}
|
||||
|
||||
@@ -171,7 +171,7 @@ pub fn AVLTree(comptime T: type) type {
|
||||
self.updateHeight(node); // 更新结点高度
|
||||
// 2. 执行旋转操作,使该子树重新恢复平衡
|
||||
node = self.rotate(node);
|
||||
// 返回子树的根节点
|
||||
// 返回子树的根结点
|
||||
return node;
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ fn hierOrder(comptime T: type, mem_allocator: std.mem.Allocator, root: *inc.Tree
|
||||
while (queue.len > 0) {
|
||||
var queue_node = queue.popFirst().?; // 队列出队
|
||||
var node = queue_node.data;
|
||||
try list.append(node.val); // 保存结点
|
||||
try list.append(node.val); // 保存结点值
|
||||
if (node.left != null) {
|
||||
var tmp_node = try mem_allocator.create(L.Node);
|
||||
tmp_node.data = node.left.?;
|
||||
|
||||
Reference in New Issue
Block a user