树
xiao1guaishou
这个作者很懒,什么都没留下…
展开
-
PAT1099 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 less than the node’s key. The right...原创 2019-07-28 23:49:12 · 79 阅读 · 0 评论 -
LeetCode 450. 删除二叉搜索树中的节点
题目: 给定一个二叉搜索树的根节点 root 和一个值 key,删除二叉搜索树中的 key 对应的节点,并保证二叉搜索树的性质不变。返回二叉搜索树(有可能被更新)的根节点的引用。 一般来说,删除节点可分为两个步骤: 首先找到需要删除的节点; 如果找到了,删除它。 说明: 要求算法时间复杂度为 O(h),h 为树的高度。 root = [5,3,6,2,4,null,7] key = 3 ...原创 2019-07-29 20:59:40 · 125 阅读 · 0 评论 -
PAT A1094 The Largest Generation (25 分)
题目 A family hierarchy is usually presented by a pedigree tree where all the nodes on the same level belong to the same generation. Your task is to find the generation with the largest population. Inp...原创 2019-07-25 21:40:25 · 97 阅读 · 0 评论 -
PAT A1062
题目 A supply chain is a network of retailers(零售商), distributors(经销商), and suppliers(供应商)-- everyone involved in moving a product from supplier to customer. Starting from one root supplier, everyone o...原创 2019-07-25 22:03:47 · 207 阅读 · 0 评论 -
PAT A1004 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 one test case. Each case st...原创 2019-07-25 23:19:11 · 83 阅读 · 0 评论 -
PAT A1066 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, rebalanci...原创 2019-07-31 19:56:20 · 127 阅读 · 0 评论