我是靠谱客的博主 开放小蝴蝶,这篇文章主要介绍python实现二叉查找数的查找最小值、最大值操作,现在分享给大家,希望可以做个参考。

本文用python3实现二叉查找树的查找最小值、最大值的操作。

查找最小值

    def get_min(self):
        if self.root is None:
            return None
        node = self.root
        while node.left:
            node = node.left
        return node.val

查找最大值

    def get_max(self):
        if self.root is None:
            return None
        node = self.root
        while node.right:
            node = node.right
        return node.val

 

最后

以上就是开放小蝴蝶最近收集整理的关于python实现二叉查找数的查找最小值、最大值操作的全部内容,更多相关python实现二叉查找数内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(108)

评论列表共有 0 条评论

立即
投稿
返回
顶部