我是靠谱客的博主 强健彩虹,这篇文章主要介绍前序中序遍历重建二叉搜索树Reconstrunct Binary Tree from Preorder and Inorder前序中序遍历重建二叉搜索树,现在分享给大家,希望可以做个参考。
Reconstrunct Binary Tree from Preorder and Inorder
前序中序遍历重建二叉搜索树
问题描述
给定一个二叉树前序遍历和中序遍历结果,重建这个二叉树。
测试样例
# Input:
preorder = ['a', 'b', 'd', 'e', 'c', 'f', 'g']
inorder = ['d', 'b', 'e', 'a', 'f', 'c', 'g']
# Output:
abcdefg
# 该二叉树为
# a
# /
# b c
# / /
# d e f g
内容首发于微信公众号IT信息教室,如果您想学习更多AI相关的技能,欢迎搜索关注或微信扫描下方二维码关注~~
最后
以上就是强健彩虹最近收集整理的关于前序中序遍历重建二叉搜索树Reconstrunct Binary Tree from Preorder and Inorder前序中序遍历重建二叉搜索树的全部内容,更多相关前序中序遍历重建二叉搜索树Reconstrunct内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复