摘要: 题目: 请写一个程序创建一棵二叉树,并按照一定规则,输出二叉树根节点到叶子节点的路径。 规则如下:1、从最顶端的根结点,到最下面的叶子节点,计算路径通过的所有节点的和,如果与设置的某一值的相同,那么输出这条路径上的所有节点。 2、从根节点遍历树时,请请按照左到右遍历,即优先访问左子树的节点。 二叉树 阅读全文
posted @ 2016-08-16 18:57 zhangbaochong 阅读(2284) 评论(0) 推荐(0) 编辑
摘要: 题目: Given a binary search tree, write a function kthSmallest to find the kth smallest element in it. Note: You may assume k is always valid, 1 ≤ k ≤ B 阅读全文
posted @ 2016-08-16 13:03 zhangbaochong 阅读(235) 评论(0) 推荐(0) 编辑
摘要: 题目: Given a binary tree, determine if it is a valid binary search tree (BST). Assume a BST is defined as follows: The left subtree of a node contains 阅读全文
posted @ 2016-08-16 11:48 zhangbaochong 阅读(237) 评论(0) 推荐(0) 编辑
摘要: 题目: Given a binary tree, find its minimum depth. The minimum depth is the number of nodes along the shortest path from the root node down to the neare 阅读全文
posted @ 2016-08-16 11:14 zhangbaochong 阅读(173) 评论(0) 推荐(0) 编辑
摘要: 题目: Given a binary tree, return the level order traversal of its nodes' values. (ie, from left to right, level by level). For example:Given binary tre 阅读全文
posted @ 2016-08-16 10:55 zhangbaochong 阅读(180) 评论(0) 推荐(0) 编辑