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 ...
分类:
其他好文 时间:
2019-10-27 20:29:12
阅读次数:
75
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 ...
分类:
其他好文 时间:
2019-10-27 20:26:49
阅读次数:
87
235. Lowest Common Ancestor of a Binary Search Tree Easy Easy Easy Given a binary search tree (BST), find the lowest common ancestor (LCA) of two give ...
分类:
其他好文 时间:
2019-10-27 18:33:31
阅读次数:
62
lst = [11,22,33,44,55,66,77,88,99] def func(left,right,n): middle = (left + right) // 2 if left > right: return - 1 elif n > lst[middle]: left = middl... ...
分类:
其他好文 时间:
2019-10-26 22:49:24
阅读次数:
77
BinarySearchTree 二叉搜索树 ? 二叉查找树(Binary Search Tree)。搜索,插入,删除的复杂度等于树高,O(log(n))。 若它的左子树不空,则左子树上所有结点的值均小于它的根结点的值; 若它的右子树不空,则右子树上所有结点的值均大于它的根结点的值; 它的左、右子树 ...
分类:
其他好文 时间:
2019-10-26 22:34:08
阅读次数:
212
原创建时间:2018 02 06 16:48:20 $O(\log_2n)$的优秀算法 二分查找 百度百科原话 二分查找的时间复杂度是$O(log_{2}n)$ 要求 查找的序列必须采用顺序存储结构 查找的序列必须是有序排列的 思路 1. 将需要查找的序列进行排序(一般为升序排列) 2. 将序列中间 ...
分类:
其他好文 时间:
2019-10-26 20:48:50
阅读次数:
102
# 斐波那契数列1 1 2 3 5 8 13 def func(n): print(n) if n==1 or n ==2: return 1 else: return func(n-1) + func(n - 2) print(func(6)) # result:8 # 函数在执行递归的过程中,如... ...
分类:
其他好文 时间:
2019-10-26 19:06:09
阅读次数:
64
1066 Root of AVL Tree (25 分) 1066 Root of AVL Tree (25 分) 1066 Root of AVL Tree (25 分) An AVL tree is a self-balancing binary search tree. In an AVL t ...
分类:
其他好文 时间:
2019-10-25 23:15:53
阅读次数:
120
描述算法复杂度时,常用o(1), o(n), o(logn), o(nlogn)表示对应算法的时间复杂度,是算法的时空复杂度的表示。不仅仅用于表示时间复杂度,也用于表示空间复杂度。 O后面的括号中有一个函数,指明某个算法的耗时/耗空间与数据增长量之间的关系。其中的n代表输入数据的量。 比如时间复杂度 ...
分类:
编程语言 时间:
2019-10-24 21:32:36
阅读次数:
95
题目链接:https://vjudge.net/contest/332656#problem/H 题意: n个花瓶,m个操作,花瓶里面有的有花,有的是空的。 1 x y 表示从第x个位置开始查y多花,若一朵花也插不上输出"Can not put any one.",反之输出插花的左位置和右位置。 2 ...
分类:
其他好文 时间:
2019-10-23 22:01:06
阅读次数:
81