码迷,mamicode.com
首页 >  
搜索关键字:recover binary searc    ( 12422个结果
折半查找
给定一个整数X和整数A0,A1,…,AN-1,后者已经预先排序并在内存中,求下标i使得Ai = X , 如果X不在数据中则返回i = -1 。明显的解法是从左往右扫描,花费线性时间。但是这个算法没有用到该表已经排序这个事实。折半检索(binary search,二分法检索)策略:/** * Perf...
分类:其他好文   时间:2014-07-16 23:25:47    阅读次数:233
Leetcode Balanced Binary Tree
Given a binary tree, determine if it is height-balanced.For this problem, a height-balanced binary tree is defined as a binary tree in which the depth...
分类:其他好文   时间:2014-06-28 10:07:19    阅读次数:208
文件处理
#include "my_file.h" //将文件内容拷贝到指定文件 int mycopy(const char *filename) {  ifstream infile(filename, ios::binary);  ofstream outfile("TRACE.txt", ios::binary);    if (!infile.is_open() || !outfile...
分类:其他好文   时间:2014-06-28 08:46:56    阅读次数:199
LeetCode——Path Sum II
Given a binary tree and a sum, find all root-to-leaf paths where each path's sum equals the given sum. For example: Given the below binary tree and sum = 22, 5 / ...
分类:其他好文   时间:2014-06-28 07:31:28    阅读次数:214
【LeetCode】 Maximum Depth of Binary Tree
Maximum Depth of Binary TreeGiven a binary tree, find its maximum depth.The maximum depth is the number of nodes along the longest path from the root ...
分类:其他好文   时间:2014-06-27 23:13:24    阅读次数:218
Summary: Binary Search
Iterative ways: 1 int binarySearch (int[] a, int x) { 2 int low = 0; 3 int high = a.length - 1; 4 int mid; 5 6 while (low x) {12 ...
分类:其他好文   时间:2014-06-27 22:27:06    阅读次数:361
剑指offer (39) 二叉树深度
题目:输入一棵二叉树的根节点,求该树的深度题解分析:二叉树具有天然的递归性,首先应该想递归解法/** * Definition for binary tree * struct TreeNode { * int val; * TreeNode *left; * TreeNod...
分类:其他好文   时间:2014-06-27 15:58:59    阅读次数:206
Tcpdump MySQL Query
在MySQL线上环境我们一般只打开了binary log,slow log,有时我们需要查看general log呢?因为该log记录所有的请求,打开该日志肯定给磁盘造成很大压力,IO能力有所下降,所以该日志线上一般不打开的,这就到tcpdump闪亮登场了。tcpdump用法也不算复杂,输出就比较复...
分类:数据库   时间:2014-06-27 13:48:17    阅读次数:385
LeetCode——Sum Root to Leaf Numbers
Given a binary tree containing digits from 0-9 only, each root-to-leaf path could represent a number. An example is the root-to-leaf path 1->2->3 which represents the number 123. Find the tota...
分类:其他好文   时间:2014-06-27 09:53:29    阅读次数:208
Leetcode Validate Binary Search Tree
Given a binary tree, determine if it is a valid binary search tree (BST). Assume a BST is defined as follows: The left subtree of a node contains only nodes with keys less than the node's key....
分类:其他好文   时间:2014-06-27 09:15:12    阅读次数:196
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!