Skip to content

Commit

Permalink
Update binary_search_tree.zig
Browse files Browse the repository at this point in the history
  • Loading branch information
krahets authored May 17, 2024
1 parent 838b93b commit b9d3cb1
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion codes/zig/chapter_tree/binary_search_tree.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
// 递归建立左子树和右子树
Expand Down

0 comments on commit b9d3cb1

Please sign in to comment.