From b9d3cb1e2c2399250f2cd1f5a8467ed52ee95398 Mon Sep 17 00:00:00 2001 From: Yudong Jin Date: Fri, 17 May 2024 18:43:01 +0800 Subject: [PATCH] Update binary_search_tree.zig --- codes/zig/chapter_tree/binary_search_tree.zig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codes/zig/chapter_tree/binary_search_tree.zig b/codes/zig/chapter_tree/binary_search_tree.zig index a7a1d03e91..bfc4a6e590 100644 --- a/codes/zig/chapter_tree/binary_search_tree.zig +++ b/codes/zig/chapter_tree/binary_search_tree.zig @@ -34,7 +34,7 @@ pub fn BinarySearchTree(comptime T: type) type { fn buildTree(self: *Self, nums: []T, i: usize, j: usize) !?*inc.TreeNode(T) { if (i > j) return null; // 将数组中间节点作为根节点 - var mid = i + (j - i) / 2; + var mid = i + (j - i) / 2; var node = try self.mem_allocator.create(inc.TreeNode(T)); node.init(nums[mid]); // 递归建立左子树和右子树