Update 0701.二叉搜索树中的插入操作.md

添加代码高亮
This commit is contained in:
sss1h
2024-02-27 20:26:57 +08:00
committed by GitHub
parent a518db03dd
commit 6fdcc59aec

View File

@ -59,7 +59,7 @@
代码如下:
```
```cpp
TreeNode* insertIntoBST(TreeNode* root, int val)
```
@ -69,7 +69,7 @@ TreeNode* insertIntoBST(TreeNode* root, int val)
代码如下:
```
```cpp
if (root == NULL) {
TreeNode* node = new TreeNode(val);
return node;
@ -88,7 +88,7 @@ if (root == NULL) {
代码如下:
```
```cpp
if (root->val > val) root->left = insertIntoBST(root->left, val);
if (root->val < val) root->right = insertIntoBST(root->right, val);
return root;
@ -120,7 +120,7 @@ public:
那么递归函数定义如下:
```
```cpp
TreeNode* parent; // 记录遍历节点的父节点
void traversal(TreeNode* cur, int val)
```