树的遍历
_Gray
这个作者很懒,什么都没留下…
展开
-
1135 Is It A Red-Black Tree (30 分)
There is a kind of balanced binary search tree named red-black tree in the data structure. It has the following 5 properties: (1) Every node is either red or black. (2) The root is black. (3) Every...原创 2019-01-23 21:00:54 · 199 阅读 · 1 评论 -
988. 从叶结点开始的最小字符串
给定一颗根结点为 root 的二叉树,书中的每个结点都有一个从 0 到 25 的值,分别代表字母 'a' 到 'z':值 0 代表 'a',值 1 代表 'b',依此类推。 找出按字典序最小的字符串,该字符串从这棵树的一个叶结点开始,到根结点结束。 (小贴士:字符串中任何较短的前缀在字典序上都是较小的:例如,在字典序上 "ab" 比 "aba" 要小。叶结点是指没有子结点的结点。) 示...原创 2019-02-09 01:32:47 · 271 阅读 · 0 评论 -
1110 Complete Binary Tree (25 分)
Given a tree, you are supposed to tell if it is a complete binary tree. Input Specification: Each input file contains one test case. For each case, the first line gives a positive integer N (≤20) wh...原创 2019-02-21 15:01:31 · 169 阅读 · 0 评论 -
1143 Lowest Common Ancestor (30 分)
The lowest common ancestor (LCA) of two nodes U and V in a tree is the deepest node that has both U and V as descendants. A binary search tree (BST) is recursively defined as a binary tree which has ...原创 2019-02-04 09:40:14 · 151 阅读 · 0 评论 -
1066 Root of AVL Tree (25 分)
An AVL tree is a self-balancing binary search tree. In an AVL tree, the heights of the two child subtrees of any node differ by at most one; if at any time they differ by more than one, rebalancing is...原创 2019-01-29 10:26:53 · 114 阅读 · 0 评论 -
1130 Infix Expression (25 分)
Given a syntax tree (binary), you are supposed to output the corresponding infix expression, with parentheses reflecting the precedences of the operators. Input Specification: Each input file contai...原创 2019-01-22 18:33:02 · 137 阅读 · 0 评论 -
1127 ZigZagging on a Tree (30 分)
Suppose that all the keys in a binary tree are distinct positive integers. A unique binary tree can be determined by a given pair of postorder and inorder traversal sequences. And it is a simple stand...原创 2019-01-22 16:39:18 · 203 阅读 · 0 评论 -
1115 Counting Nodes in a BST (30 分)
A Binary Search Tree (BST) is recursively defined as a binary tree which has the following properties: The left subtree of a node contains only nodes with keys less than or equal to the node's key. ...原创 2019-01-16 21:46:41 · 106 阅读 · 0 评论 -
1123 Is It a Complete AVL Tree (30 分)
An AVL tree is a self-balancing binary search tree. In an AVL tree, the heights of the two child subtrees of any node differ by at most one; if at any time they differ by more than one, rebalancing is...原创 2019-01-21 21:57:39 · 164 阅读 · 0 评论 -
1119 Pre- and Post-order Traversals (30 分)
Suppose that all the keys in a binary tree are distinct positive integers. A unique binary tree can be determined by a given pair of postorder and inorder traversal sequences, or preorder and inorder ...原创 2019-01-21 18:34:46 · 525 阅读 · 0 评论 -
1138 Postorder Traversal (25 分)
Suppose that all the keys in a binary tree are distinct positive integers. Given the preorder and inorder traversal sequences, you are supposed to output the first number of the postorder traversal se...原创 2019-01-24 20:09:36 · 144 阅读 · 0 评论 -
1155 Heap Paths (30 分)
In computer science, a heap is a specialized tree-based data structure that satisfies the heap property: if P is a parent node of C, then the key (the value) of P is either greater than or equal to (i...原创 2019-02-25 15:32:49 · 167 阅读 · 0 评论