refactor: Replace 结点 with 节点 (#452)

* Replace 结点 with 节点
Update the footnotes in the figures

* Update mindmap

* Reduce the size of the mindmap.png
This commit is contained in:
Yudong Jin
2023-04-09 04:32:17 +08:00
committed by GitHub
parent 3f4e32b2b0
commit 1c8b7ef559
395 changed files with 2056 additions and 2056 deletions

View File

@@ -7,7 +7,7 @@ const inc = @import("include");
// 层序遍历
fn levelOrder(comptime T: type, mem_allocator: std.mem.Allocator, root: *inc.TreeNode(T)) !std.ArrayList(T) {
// 初始化队列,加入根
// 初始化队列,加入根
const L = std.TailQueue(*inc.TreeNode(T));
var queue = L{};
var root_node = try mem_allocator.create(L.Node);
@@ -18,16 +18,16 @@ fn levelOrder(comptime T: type, mem_allocator: std.mem.Allocator, root: *inc.Tre
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.?;
queue.append(tmp_node); // 左子点入队
queue.append(tmp_node); // 左子点入队
}
if (node.right != null) {
var tmp_node = try mem_allocator.create(L.Node);
tmp_node.data = node.right.?;
queue.append(tmp_node); // 右子点入队
queue.append(tmp_node); // 右子点入队
}
}
return list;
@@ -50,7 +50,7 @@ pub fn main() !void {
// 层序遍历
var list = try levelOrder(i32, mem_allocator, root.?);
defer list.deinit();
std.debug.print("\n层序遍历的点打印序列 = ", .{});
std.debug.print("\n层序遍历的点打印序列 = ", .{});
inc.PrintUtil.printList(i32, list);
_ = try std.io.getStdIn().reader().readByte();