mirror of
https://github.com/youngyangyang04/leetcode-master.git
synced 2026-02-02 18:39:09 +08:00
541~1382连接合并+commit之前 gitpull
This commit is contained in:
@@ -9,7 +9,7 @@
|
||||
|
||||
## 701.二叉搜索树中的插入操作
|
||||
|
||||
链接:https://leetcode-cn.com/problems/insert-into-a-binary-search-tree/
|
||||
[力扣题目链接](https://leetcode-cn.com/problems/insert-into-a-binary-search-tree/)
|
||||
|
||||
给定二叉搜索树(BST)的根节点和要插入树中的值,将值插入二叉搜索树。 返回插入后二叉搜索树的根节点。 输入数据保证,新值和原始二叉搜索树中的任意节点值都不同。
|
||||
|
||||
@@ -164,11 +164,11 @@ public:
|
||||
|
||||
## 迭代
|
||||
|
||||
再来看看迭代法,对二叉搜索树迭代写法不熟悉,可以看这篇:[二叉树:二叉搜索树登场!](https://mp.weixin.qq.com/s/vsKrWRlETxCVsiRr8v_hHg)
|
||||
再来看看迭代法,对二叉搜索树迭代写法不熟悉,可以看这篇:[二叉树:二叉搜索树登场!](https://programmercarl.com/0700.二叉搜索树中的搜索.html)
|
||||
|
||||
在迭代法遍历的过程中,需要记录一下当前遍历的节点的父节点,这样才能做插入节点的操作。
|
||||
|
||||
在[二叉树:搜索树的最小绝对差](https://mp.weixin.qq.com/s/Hwzml6698uP3qQCC1ctUQQ)和[二叉树:我的众数是多少?](https://mp.weixin.qq.com/s/KSAr6OVQIMC-uZ8MEAnGHg)中,都是用了记录pre和cur两个指针的技巧,本题也是一样的。
|
||||
在[二叉树:搜索树的最小绝对差](https://programmercarl.com/0530.二叉搜索树的最小绝对差.html)和[二叉树:我的众数是多少?](https://programmercarl.com/0501.二叉搜索树中的众数.html)中,都是用了记录pre和cur两个指针的技巧,本题也是一样的。
|
||||
|
||||
代码如下:
|
||||
|
||||
|
||||
Reference in New Issue
Block a user