@ -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
TreeNode *node = new TreeNode(num);
if (pre->val < num)
@ -63,7 +63,7 @@ class BinarySearchTree {
else cur = cur.left;
TreeNode node = new TreeNode(num);
if (pre != null) {
if (pre.val < num) pre.right = node;
@ -70,7 +70,7 @@ void insert(int num) {
cur = cur.left;
TreeNode? node = TreeNode(num);
if (pre!.val < num)
pre.right = node;
@ -74,7 +74,7 @@ class BinarySearchTree {
if (pre.val < num)
@ -66,7 +66,7 @@ function insert(num) {
// 插入位置在 cur 的左子树中
let node = new TreeNode(num);
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
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 的左子树中
if (pre!.val < num) {
pre!.right = node;
@ -87,7 +87,7 @@ pub fn BinarySearchTree(comptime T: type) type {
cur = cur.?.left;
var node = try self.mem_allocator.create(inc.TreeNode(T));
node.init(num);
if (pre.?.val < num) {