mirror of
https://github.com/krahets/hello-algo.git
synced 2025-02-02 22:43:50 +08:00
Fix a comment in binary_search_tree code
This commit is contained in:
parent
26cc480ff5
commit
817b4598d5
@ -89,7 +89,7 @@ void insert(binarySearchTree *bst, int num) {
|
||||
cur = cur->left;
|
||||
}
|
||||
}
|
||||
// 插入节点 val
|
||||
// 插入节点
|
||||
TreeNode *node = newTreeNode(num);
|
||||
if (pre->val < num) {
|
||||
pre->right = node;
|
||||
|
@ -77,7 +77,7 @@ class BinarySearchTree {
|
||||
else
|
||||
cur = cur->left;
|
||||
}
|
||||
// 插入节点 val
|
||||
// 插入节点
|
||||
TreeNode *node = new TreeNode(num);
|
||||
if (pre->val < num)
|
||||
pre->right = node;
|
||||
|
@ -63,7 +63,7 @@ class BinarySearchTree {
|
||||
else cur = cur.left;
|
||||
}
|
||||
|
||||
// 插入节点 val
|
||||
// 插入节点
|
||||
TreeNode node = new TreeNode(num);
|
||||
if (pre != null) {
|
||||
if (pre.val < num) pre.right = node;
|
||||
|
@ -70,7 +70,7 @@ void insert(int num) {
|
||||
else
|
||||
cur = cur.left;
|
||||
}
|
||||
// 插入节点 val
|
||||
// 插入节点
|
||||
TreeNode? node = TreeNode(num);
|
||||
if (pre!.val < num)
|
||||
pre.right = node;
|
||||
|
@ -74,7 +74,7 @@ class BinarySearchTree {
|
||||
else
|
||||
cur = cur.left;
|
||||
}
|
||||
// 插入节点 val
|
||||
// 插入节点
|
||||
TreeNode node = new TreeNode(num);
|
||||
if (pre.val < num)
|
||||
pre.right = node;
|
||||
|
@ -66,7 +66,7 @@ function insert(num) {
|
||||
// 插入位置在 cur 的左子树中
|
||||
else cur = cur.left;
|
||||
}
|
||||
// 插入节点 val
|
||||
// 插入节点
|
||||
let node = new TreeNode(num);
|
||||
if (pre.val < num) pre.right = node;
|
||||
else pre.left = node;
|
||||
|
@ -77,7 +77,7 @@ class BinarySearchTree:
|
||||
else:
|
||||
cur = cur.left
|
||||
|
||||
# 插入节点 val
|
||||
# 插入节点
|
||||
node = TreeNode(num)
|
||||
if pre.val < num:
|
||||
pre.right = node
|
||||
|
@ -80,7 +80,7 @@ class BinarySearchTree {
|
||||
cur = cur?.left
|
||||
}
|
||||
}
|
||||
// 插入节点 val
|
||||
// 插入节点
|
||||
let node = TreeNode(x: num)
|
||||
if pre!.val < num {
|
||||
pre?.right = node
|
||||
|
@ -71,7 +71,7 @@ function insert(num: number): void {
|
||||
cur = cur.left as TreeNode; // 插入位置在 cur 的左子树中
|
||||
}
|
||||
}
|
||||
// 插入节点 val
|
||||
// 插入节点
|
||||
let node = new TreeNode(num);
|
||||
if (pre!.val < num) {
|
||||
pre!.right = node;
|
||||
|
@ -87,7 +87,7 @@ pub fn BinarySearchTree(comptime T: type) type {
|
||||
cur = cur.?.left;
|
||||
}
|
||||
}
|
||||
// 插入节点 val
|
||||
// 插入节点
|
||||
var node = try self.mem_allocator.create(inc.TreeNode(T));
|
||||
node.init(num);
|
||||
if (pre.?.val < num) {
|
||||
|
Loading…
Reference in New Issue
Block a user