BST
文章平均质量分 78
liuchenjane
这个作者很懒,什么都没留下…
展开
-
450. Delete Node in a BST
450. Delete Node in a BSTGiven a root node reference of a BST and a key, delete the node with the given key in the BST. Return the root node reference (possibly updated) of the BST.Basically原创 2016-11-11 22:44:33 · 1255 阅读 · 0 评论 -
从求逆序对和mergeSort谈起(2)
应用mergeSort的思想,可以解决许多和下标有关的问题。看了有关题的提示,发现有些能用Divide and Conqure解决的,也可以用 Binary Search Tree,Segment Tree,Binary Index Tree解决。它们都可以把原始的时间复杂度为O(n2)O(n^2)的算法降低为O(nlogn)O(nlogn). 下面从求数组的逆序数对这一问题,用不同的方法去解决。原创 2017-02-21 18:51:08 · 408 阅读 · 0 评论 -
222. Count Complete Tree Nodes
Given a complete binary tree, count the number of nodes.Definition of a complete binary tree from Wikipedia: In a complete binary tree every level, except possibly the last, is completely filled, and翻译 2017-02-23 22:25:06 · 308 阅读 · 0 评论 -
二叉搜索树BST的C++实现
BST包含的功能:插入,删除,查找,查找某一结点的后续和前驱,中序遍历和前序遍历这里,用于实验的二叉树://二叉搜索树BST#include #include using namespace std;class TreeNode{ public: int key; TreeNode* left; TreeNode* right; TreeNode* p;//原创 2016-11-05 17:58:27 · 6447 阅读 · 0 评论 -
AVL树的插入操作
AVL tree (Adelson-Velskii-Landis tree)一颗AVL树是其每个节点的左子树和右子树的高度最多差1的二叉查找树。加了额外的平衡条件是为了确保整棵树的深度为O(logN)在高度为h的AVL树,最少节点数S(h)=S(h-1)+S(h-2)+1.=========================================================原创 2017-05-20 20:58:28 · 1623 阅读 · 0 评论