README ¶ 面试题 04.02.最小高度树 1. 题目描述 给定一个有序整数数组,元素各不相同且按升序排列,编写一个算法,创建一棵高度最小的二叉搜索树。 示例: 给定有序数组: [-10,-3,0,5,9], 一个可能的答案是:[0,-3,9,-10,null,5],它可以表示下面这个高度平衡二叉搜索树: 0 / \ -3 9 / / -10 5 标签 树 二叉搜索树 数组 分治 二叉树 2. 解题 将有序数组的中点作为树的跟来构造树。 Expand ▾ Collapse ▴ Documentation ¶ Index ¶ type TreeNode func (root *TreeNode) InOrder(Visit func(val int)) func (root *TreeNode) PostOrder(Visit func(val int)) func (root *TreeNode) PreOrder(Visit func(val int)) Constants ¶ This section is empty. Variables ¶ This section is empty. Functions ¶ This section is empty. Types ¶ type TreeNode ¶ type TreeNode struct { Val int Left *TreeNode Right *TreeNode } func (*TreeNode) InOrder ¶ func (root *TreeNode) InOrder(Visit func(val int)) func (*TreeNode) PostOrder ¶ func (root *TreeNode) PostOrder(Visit func(val int)) func (*TreeNode) PreOrder ¶ func (root *TreeNode) PreOrder(Visit func(val int)) Source Files ¶ View all Source files Tree.gogoden0402.go Click to show internal directories. Click to hide internal directories.