diff --git a/chapter_computational_complexity/time_complexity.md b/chapter_computational_complexity/time_complexity.md index 096f62580..28793b49f 100755 --- a/chapter_computational_complexity/time_complexity.md +++ b/chapter_computational_complexity/time_complexity.md @@ -2548,7 +2548,7 @@ $$ 对数阶常出现于基于分治策略的算法中,体现了“一分为多”和“化繁为简”的算法思想。它增长缓慢,是仅次于常数阶的理想的时间复杂度。 -!!! tip +!!! tip "$O(\log n)$ 的底数是多少?" 准确来说,“一分为 $m$”对应的时间复杂度是 $O(\log_m n)$ 。而通过对数换底公式,我们可以得到具有不同底数的、相等的时间复杂度: diff --git a/chapter_tree/binary_search_tree.md b/chapter_tree/binary_search_tree.md index 222765e33..bd92c61ed 100755 --- a/chapter_tree/binary_search_tree.md +++ b/chapter_tree/binary_search_tree.md @@ -1333,33 +1333,7 @@ comments: true === "Dart" ```dart title="binary_search_tree.dart" - /* 插入节点 */ - void insert(int num) { - // 若树为空,直接提前返回 - if (_root == null) return; - TreeNode? cur = _root; - TreeNode? pre = null; - // 循环查找,越过叶节点后跳出 - while (cur != null) { - // 找到重复节点,直接返回 - if (cur.val == num) return; - pre = cur; - // 插入位置在 cur 的右子树中 - if (cur.val < num) - cur = cur.right; - // 插入位置在 cur 的左子树中 - else - cur = cur.left; - } - // 插入节点 - TreeNode? node = TreeNode(num); - if (pre!.val < num) - pre.right = node; - else - pre.left = node; - } - - /* 删除节点 */ + /* 删除节点 */ void remove(int num) { // 若树为空,直接提前返回 if (_root == null) return;