![](https://img-blog.csdnimg.cn/20201014180756780.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
pat甲级(树类型题)
qq_41698081
这个作者很懒,什么都没留下…
展开
-
1043 Is It a Binary Search Tree (判断是否是二叉搜索树,且以后序遍历方式输出二叉搜索树)
1043 Is It a Binary Search Tree (25 分)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...原创 2019-06-05 19:53:02 · 826 阅读 · 0 评论 -
1090 Highest Price in Supply Chain 1106 Lowest Price in Supply Chain(dfs树的遍历)
1106 Lowest Price in Supply Chain (25 分)A supply chain is a network of retailers(零售商), distributors(经销商), and suppliers(供应商)-- everyone involved in moving a product from supplier to customer.Start...原创 2019-08-13 15:33:45 · 94 阅读 · 0 评论 -
pat甲级1099 build a Binary Search Tree
1099 Build A Binary Search Tree (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...原创 2019-06-12 09:48:47 · 142 阅读 · 0 评论 -
1130 Infix Expression 中序遍历中缀表达括号的运用
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 Specific...原创 2019-06-10 22:14:47 · 388 阅读 · 0 评论 -
1115 Counting Nodes in a BST(构建搜索二叉树)
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 le...原创 2019-06-10 22:05:01 · 150 阅读 · 0 评论 -
1119. Pre- and Post-order Traversals(前序后序 转中序)
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 t...原创 2019-06-10 21:51:07 · 479 阅读 · 1 评论 -
pat甲级 1004 countleaves (二维向量容器存储树结构 + dfs + bfs)
1004 Counting Leaves (30 分)A family hierarchy is usually presented by a pedigree tree. Your job is to count those family members who have no child.Input Specification:Each input file contains on...原创 2019-06-09 12:07:54 · 117 阅读 · 0 评论 -
1102 Invert a Binary Tree(构建二叉树,并将二叉树反转中序层序输出)
1102 Invert a Binary Tree (25 分)The following is from Max Howell @twitter:Google: 90% of our engineers use the software you wrote (Homebrew), but you can't invert a binary tree on a whiteboard so...原创 2019-06-09 11:13:22 · 260 阅读 · 0 评论 -
1079 Total Sales of Supply Chain (25 分)(深度优先搜索树的遍历(二维向量矩阵))
1079 Total Sales of Supply Chain (25 分)A supply chain is a network of retailers(零售商), distributors(经销商), and suppliers(供应商)-- everyone involved in moving a product from supplier to customer.Starti...原创 2019-06-07 10:47:23 · 148 阅读 · 0 评论 -
关于已知二叉树的先序中序推出后序,或者后序中序推出先序遍历
/**根据中序遍历 先序遍历构建 输出后序遍历后序遍历为左右根 递归的返回条件中序遍历中 左子树和右子树1. 过i将中序遍历中的树分为左子树和右子树 (i为中序遍历的根节点(需要输出的结点(每棵树都是自己的根结点))2.确定左子树的start,与 end范围,同时通过先序数组找到此时的根节点(上一个根结点+1)3.确定右子树的start,与 end范围, /...原创 2019-06-06 19:12:29 · 250 阅读 · 0 评论 -
1064 Complete Binary Search Tree (运用搜索二叉树BST的中序遍历输出层序遍历)
1064 Complete Binary Search Tree (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 key...原创 2019-06-06 18:27:33 · 276 阅读 · 0 评论 -
1138 Postorder Traversal (前序 中序转后序)
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 num...原创 2019-06-12 22:03:46 · 108 阅读 · 0 评论 -
1127 ZigZagging on a Tree (将层序遍历按z型输出, 2种方法,1.下标法构建满足题意的层序条件 2.构建树 BFS遍历层序)
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 s...原创 2019-06-12 21:57:40 · 400 阅读 · 0 评论 -
1020. Tree Traversals 后序中序转层序
Suppose that all the keys in a binary tree are distinct positive integers. Given the postorder and inorder traversal sequences, you are supposed to output the level order traversal sequence of the cor...原创 2019-06-05 20:35:27 · 127 阅读 · 0 评论 -
1086 Tree Traversals Again(中序 先序栈 构建 后序二叉树)
1086 Tree Traversals Again (25 分)An inorder binary tree traversal can be implemented in a non-recursive way with a stack. For example, suppose that when a 6-node binary tree (with the keys numbered ...原创 2019-08-12 19:29:32 · 135 阅读 · 0 评论