- 博客(80)
- 资源 (2)
- 收藏
- 关注
转载 B(B-)树, B+树,B*树,红黑树
二叉搜索树 1.所有非叶子结点至多拥有两个儿子(Left和Right); 2.所有结点存储一个关键字; 3.非叶子结点的左指针指向小于其关键字的子树,右指针指向大于其关键字的子树; 如: B树的搜索,从根结点开始,如果查询的关键字与结点的关键字相等,那么就命中;
2014-10-29 16:14:35 779
转载 B-树和B+树的应用:数据搜索和数据库索引
B-树1 .B-树定义B-树是一种平衡的多路查找树,它在文件系统中很有用。定义:一棵m 阶的B-树,或者为空树,或为满足下列特性的m 叉树:⑴树中每个结点至多有m 棵子树;⑵若根结点不是叶子结点,则至少有两棵子树;⑶除根结点之外的所有非终端结点至少有[m/2] 棵子树;⑷所有的非终端结点中包含以下信息数据: (n,A0,K1,A
2014-10-29 16:11:03 617
原创 微软经典面试题及答案
第一题 . 五个海盗抢到了100颗宝石,每一颗都一样大小和价值连城。他们决定这么分: 抽签决定自己的号码(1、2、3、4、5) 首先,由1号提出分配方案,然后大家表决,当且仅当超过半数的人同意时,按照他的方案进行分配,否则将被扔进大海喂鲨鱼,如果1号死后,再由2号提出分配方案,然后剩下的4人进行表决,当且仅当超过半数的人同意时,按照他的方案进行分配,否则将被扔入大海喂鲨鱼,依此类推
2014-10-21 12:16:03 1550
转载 后缀树
http://www.cppblog.com/superKiki/archive/2010/10/29/131786.aspx 在pongba的讨论组上看到一道Amazon的面试题:找出给定字符串里的最长回文。例子:输入XMADAMYX。则输出MADAM。这道题的流行解法是用后缀树(Suffix Tree)。这坨数据结构最酷的地方是用它能高效解决一大票复杂的字符串编程问题: 在文
2014-10-17 13:34:59 721
原创 leetcode Maximum Product Subarray(*)
Find the contiguous subarray within an array (containing at least one number) which has the largest product.For example, given the array [2,3,-2,4],the contiguous subarray [2,3] has the larges
2014-10-10 15:06:33 596
转载 牛顿法
牛顿法至少有两个应用方向,1、求方程的根,2、最优化。牛顿法涉及到方程求导,下面的讨论均是在连续可微的前提下讨论。1、求解方程。并不是所有的方程都有求根公式,或者求根公式很复杂,导致求解困难。利用牛顿法,可以迭代求解。原理是利用泰勒公式,在x0处展开,且展开到一阶,即f(x) = f(x0)+(x-x0)f'(x0)求解方程f(x)=0,即f(x0)+(x-x0)*
2014-09-29 14:31:19 1031
原创 PAT 1010
#include using namespace std;long long int toD(string str,long long int radix){ long long int num=0; for(int i=0;i<str.length();i++){ if(str[i]>='a'&&str[i]<='z'){ num=nu
2014-08-30 21:03:18 541
转载 虚函数 与 纯虚函数 区别
首先:强调一个概念定义一个函数为虚函数,不代表函数为不被实现的函数。定义他为虚函数是为了允许用基类的指针来调用子类的这个函数。定义一个函数为纯虚函数,才代表函数没有被实现。定义纯虚函数是为了实现一个接口,起到一个规范的作用,规范继承这个类的程序员必须实现这个函数。1、简介假设我们有下面的类层次:[cpp] view plaincopy
2014-08-23 16:20:25 540
原创 多态 和 重载的区别
多态是基于对抽象方法的覆盖来实现的,用统一的对外接口来完成不同的功能。重载也是用统一的对外接口来完成不同的功能。那么两者有什么区别呢?重载,是指允许存在多个同名方法,而这些方法的参数不同。重载的实现是:编译器根据方法不同的参数表,对同名方法的名称做修饰。对于编译器而言,这些同名方法就成了不同的方法。它们的调用地址在编译期就绑定了。多态:是指子类重新定义父类的虚方法(virtua
2014-08-20 09:57:04 959
转载 C/S B/S区别
C/S结构,即Client/Server(客户机/服务器)结构,是大家熟知的软件系统体系结构,通过将任务合理分配到Client端和Server端,降低了系统的通讯开销,可以充分利用两端硬件环境的优势。早期的软件系统多以此作为首选设计标准。。 B/S结构,即Browser/Server(浏览器/服务器)结构,是随着Internet技术的兴起,对C/S结构的一种变化或者改进的结构。在这种结
2014-08-19 08:59:43 1044
转载 C++拷贝构造函数详解
一. 什么是拷贝构造函数首先对于普通类型的对象来说,它们之间的复制是很简单的,例如:[c-sharp] view plaincopyint a = 100; int b = a; 而类对象与普通对象不同,类对象内部结构一般较为复杂,存在各种成员变量。下面看一个类对象拷贝的简单例子。
2014-08-17 14:08:22 535
原创 leetcode Palindrome Partitioning(*)
Given a string s, partition s such that every substring of the partition is a palindrome.Return all possible palindrome partitioning of s.For example, given s = "aab",Return [ ["aa","
2014-08-14 20:13:53 528
原创 leetcode Populating Next Right Pointers in Each Node(*)
Given a binary tree struct TreeLinkNode { TreeLinkNode *left; TreeLinkNode *right; TreeLinkNode *next; }Populate each next pointer to point to its next right node.
2014-08-13 20:49:28 490
原创 leetcode Linked List Cycle(I II)(*)
Given a linked list, determine if it has a cycle in it.Follow up:Can you solve it without using extra space?
2014-08-12 20:26:10 421
原创 leetcode Reorder List(*)
Given a singly linked list L: L0→L1→…→Ln-1→Ln,reorder it to: L0→Ln→L1→Ln-1→L2→Ln-2→…You must do this in-place without altering the nodes' values.For example,Given {1,2,3,4}, reorder it t
2014-08-12 20:15:59 469
原创 leetcode LRU Cache(**)
Design and implement a data structure for Least Recently Used (LRU) cache. It should support the following operations: get and set.get(key) - Get the value (will always be positive) of the key if
2014-08-06 20:49:34 602
原创 leetcode Best Time to Buy and Sell Stock(I~III)(*)
I:Say you have an array for which the ith element is the price of a given stock on day i.If you were only permitted to complete at most one transaction (ie, buy one and sell one share of the
2014-08-05 20:51:35 596
转载 编程之美4.7蚂蚁爬杆扩展问题附猎人抓狐狸(必胜策略)
4.7节讲的是一根长27cm的木棍上,在5个点上有5只蚂蚁,蚂蚁在开始的时候朝任意方向出发,只能掉头或者往前走。让任意两只蚂蚁碰头时,它们同时掉头朝反方向走。假设蚂蚁的速度都是一秒一厘米,求蚂蚁都离开木棍的最短时间和最长时间。 穷举很麻烦,书上的思路非常精巧,即把蚂蚁碰头后掉头走,看做两个蚂蚁相遇后擦肩而过。这样就可以把蚂蚁的运动看做是独立的,是否碰头并不重要。代码也很简单,不过书上
2014-08-05 11:29:17 2278
原创 leetcode Next Permutation(*)
Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers.If such arrangement is not possible, it must rearrange it as the lowest possible
2014-07-28 19:38:50 594
原创 leetcode Length of Last Word (*)
Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.If the last word does not exist, return 0.Note: A word is
2014-07-28 18:52:30 513
原创 leetcode Valid Sudoku(*)
Determine if a Sudoku is valid, according to: Sudoku Puzzles - The Rules.The Sudoku board could be partially filled, where empty cells are filled with the character '.'.A partially fille
2014-07-26 20:45:17 512
原创 leetcode Insertion Sort List(*)
Sort a linked list using insertion sort. 插入排序,仿照数组的插入排序,
2014-07-26 20:25:41 505
原创 leetcode Sort List(**)
Sort a linked list in O(n log n) time using constant space complexity.
2014-07-26 19:59:16 472
原创 leetcode Symmetric Tree(*)
Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center).For example, this binary tree is symmetric: 1 / \ 2 2 / \ / \3 4 4 3But the f
2014-07-24 19:54:10 523
原创 leetcode Count and Say(*)
The count-and-say sequence is the sequence of integers beginning as follows:1, 11, 21, 1211, 111221, ...1 is read off as "one 1" or 11.11 is read off as "two 1s" or 21.21 is read off as
2014-07-24 19:10:18 474
原创 leetcode Max Points on a Line(*)
Given n points on a 2D plane, find the maximum number of points that lie on the same straight line. 求
2014-07-24 18:55:34 485
原创 leetcode Evaluate Reverse Polish Notation(*)
Evaluate the value of an arithmetic expression in Reverse Polish Notation.Valid operators are +, -, *, /. Each operand may be an integer or another expression.Some examples: ["2", "1", "+", "3"
2014-07-15 21:27:11 428
转载 梯度下降法
回归(regression)、梯度下降(gradient descent)前言:上次写过一篇关于贝叶斯概率论的数学,最近时间比较紧,coding的任务比较重,不过还是抽空看了一些机器学习的书和视频,其中很推荐两个:一个是 stanford的machine learning公开课,在verycd可下载,可惜没有翻译。不过还是可以看。另外一个是prml-pattern recognit
2014-06-18 10:35:17 726
原创 LeetCode Divide Two Integers(***)
Divide two integers without using multiplication, division and mod operator.
2014-06-17 15:38:40 516
原创 CareerCup Chapter 9 Sorting and Searching
You are given two sorted arrays, A and B, and A has a large enough buffer at the end to hold B. Write a method to merge B into A in sorted order.
2014-06-14 17:43:54 1420
原创 LeetCode Palindrome Partitioning II(***)
Given a string s, partition s such that every substring of the partition is a palindrome.Return the minimum cuts needed for a palindrome partitioning ofs.For example, given s = "aab",Retur
2014-06-13 21:56:48 543
原创 LeetCode Longest Palindromic Substring
Given a string S, find the longest palindromic substring inS. You may assume that the maximum length of S is 1000, and there exists one unique longest palindromic substring.
2014-06-13 20:09:51 472
原创 LeetCode Remove Nth Node From End of List
Given a linked list, remove the nth node from the end of list and return its head.For example, Given linked list: 1->2->3->4->5, and n = 2. After removing the second node from the end, the l
2014-06-13 19:24:58 603 1
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人