二叉查找树(Binary Search Tree,BST),(又:二叉搜索树,二叉排序树)它或者是一棵空树,或者是具有下列性质的二叉树: 若它的左子树不空,则左子树上所有结点的值均小于它的根结点的值; 若它的右子树不空,则右子树上所有结点的值均大于它的根结点的值; 它的左、右子树也分别为二叉排序树。...
分类:
编程语言 时间:
2015-07-19 19:27:00
阅读次数:
154
Evaluation metricsa binary classifier accuracy,specificity,sensitivety.(整个分类器的准确性,正确率,错误率)表示分类正确:True Positive:本来是正样例,分类成正样例。 True Negative:本来是负样例,分类成...
分类:
数据库 时间:
2015-07-19 17:47:33
阅读次数:
192
Given a binary search tree, write a function kthSmallest to find the kth smallest element in it.Note: You may assume k is always valid, 1 ≤ k ≤ BST's total elements.Follow up:What if the BST is modifi...
分类:
其他好文 时间:
2015-07-19 16:32:18
阅读次数:
137
#235 Lowest Common Ancestor of a Binary Search TreeGiven a binary search tree (BST), find the lowest common ancestor (LCA) of two given nodes in the B...
分类:
其他好文 时间:
2015-07-19 13:22:08
阅读次数:
90
一、概念 折半查找(Binary Search)的查找过程是:先确定待查找记录所在的范围区间,然后逐步 缩小范围直到找到或找不到记录为止。该方法的局限性在于要排序的查找表必须有序,即 如若i#include #define N 20int BinarySearch(int a[], int n,.....
分类:
其他好文 时间:
2015-07-19 13:17:11
阅读次数:
102
Lowest Common Ancestor of a Binary Search TreeTotal Accepted:7402Total Submissions:19069My SubmissionsQuestionSolutionGiven a binary search tree (BST)...
分类:
编程语言 时间:
2015-07-19 11:39:59
阅读次数:
153
Reverse bits of a given 32 bits unsigned integer.For example, given input 43261596 (represented in binary as00000010100101000001111010011100), return ...
分类:
其他好文 时间:
2015-07-19 11:38:34
阅读次数:
122
做到这个题才发现之前做的关于二叉检索树的写复杂了,其实可以直接根据二叉检索树的特点进行判断(从树根开始,某一节点的值大于待搜的两个节点则在左边找,小于待搜的两个节点则在右边找,否则返回该节点即可)。这道题倒是必须用DFS来解决。
class Solution {
public:
//DFS代码
void findNode(TreeNode* root, TreeNode* toF...
分类:
其他好文 时间:
2015-07-19 10:16:49
阅读次数:
113
Lowest Common Ancestor of a Binary TreeTotal Accepted:4228Total Submissions:15884My SubmissionsQuestionSolutionGiven a binary tree, find the lowest co...
分类:
其他好文 时间:
2015-07-19 09:57:53
阅读次数:
87
This problem is a nice application of binary search. The key lies in how to determine the correct half fortarget. Since the array has been rotated, we...
分类:
其他好文 时间:
2015-07-18 22:33:38
阅读次数:
130