有关二叉搜索树的题目

二叉搜索树的特点

 

 

二叉搜索树的构建

验证二叉搜索树:中序遍历为一个有序数组98,501,530,700

二叉搜索树的增加/删除701

增加节点:

    func gender (root *TreeNode)*TreeNode{
        if root == nil{
            root = new(TreeNode)
            root.Val = val
            return root
        }
        if root.Val > val{
           root.Left =  gender(root.Left)
        }
        if root.Val < val{
           root.Right = gender(root.Right)
        }
        return root
    }
    gender(root)
 
删除与构建操作都是一个难点
posted @ 2021-03-12 14:42  爱晒太阳的懒猫。。  阅读(52)  评论(0编辑  收藏  举报