摘要: new & delete expression1. IntroductionA new expression allocates and constructs an object of a specified type.A new[] expression allocates and constru... 阅读全文
posted @ 2014-10-03 21:49 Acjx 阅读(1670) 评论(0) 推荐(2) 编辑
摘要: OOP之类和对象 1. this指针的引入 每个成员函数都有一个额外的隐含的形参,这个参数就是this指针,它指向调用对象的地址。默认情况下,this的类型是指向类类型非常量版本的常量指针。可以表示成如下伪代码形式: /* 假设现在有一个类Sales_data,以及其非常量Sales_data类型... 阅读全文
posted @ 2014-09-26 10:05 Acjx 阅读(5109) 评论(2) 推荐(5) 编辑
摘要: 1. Convert Expression to Reverse Polish Notation http://www.lintcode.com/en/problem/convert-expression-to-polish-notation/ Given an expression string array, return the Polish notation of this e... 阅读全文
posted @ 2015-09-05 20:57 Acjx 阅读(969) 评论(0) 推荐(0) 编辑
摘要: 1 Same Tree https://leetcode.com/problems/same-tree/ Given two binary trees, write a function to check if they are equal or not. Two binary trees are considered equal if they are structurall... 阅读全文
posted @ 2015-08-30 19:06 Acjx 阅读(672) 评论(0) 推荐(0) 编辑
摘要: 1. 预处理过程 预处理主要用来事先生成程序在运行过程中可能用到的数据,以便加速处理时间。 预处理的过程主要生成程序所需的三个文件:网页库文件,网页位置信息文件和倒排索引文件。 网页库文件 其中网页库文件ripepage.lib主要是以格式化的数据存储大量的网页信息,每个网页的格式化数据为: id url title content 网页位置信... 阅读全文
posted @ 2015-08-19 22:17 Acjx 阅读(1026) 评论(0) 推荐(0) 编辑
摘要: 该Project原来的应用场景是对电商网站中输入一个错误的商品名称进行智能纠错,比如iphoae纠错为iphone。以下介绍的这个版本对其作了简化,项目源代码地址参见我的github:https://github.com/jianxinzhou/MyProject_1/tree/uint32 。 该Project的主要思想是利用字符串编辑距离来实现拼写纠错。每当客户端来一个查询词,服务器返回与其... 阅读全文
posted @ 2015-08-18 19:33 Acjx 阅读(1628) 评论(0) 推荐(1) 编辑
摘要: 前段时间在看一本01年出的旧书《effective Tcp/Ip programming》,这个算法专题中断了几天,现在继续写下去。 Introduction 对于单向链表(singly linked list),每个节点有⼀个next指针指向后一个节点,还有一个成员变量用以储存数值;对于双向链表(Doubly LinkedList),还有一个prev指针指向前一个节点。与数组类似,搜索链表需... 阅读全文
posted @ 2015-08-17 22:37 Acjx 阅读(1914) 评论(0) 推荐(0) 编辑
摘要: What is it? TIME-WAIT状态的主要作用在于TCP连接的拆除阶段。拆除一个TCP连接通常需要交换4个segment,如下图所示: Host1上的应用程序关闭了自己这一端的连接,使得TCP向Host 2发送了一个FIN。Host 2对这个FIN进行ACK,并将这个FIN作为一个EOF传送给应用程序(假设Host 2上的应用程序有一个挂起的read操作)。经过一段时间后,Hos... 阅读全文
posted @ 2015-08-14 21:52 Acjx 阅读(878) 评论(0) 推荐(0) 编辑
摘要: 待看的一些文章 1. 性能调优攻略 http://coolshell.cn/articles/7490.html 2. 内存的存储管理--段式和页式管理的区别 http://blog.sina.com.cn/s/blog_4c6403ed01000bbb.html 3. Linux信号相关笔记http://blog.csdn.net/dr8737010/article/details/16... 阅读全文
posted @ 2015-08-13 14:52 Acjx 阅读(396) 评论(0) 推荐(0) 编辑
摘要: BST 以下BST的定义来自于Wikipedia: Binary Search Tree, is a node-based binary tree data structure which has the following properties: The left subtree of a node contains only nodes with keys less ... 阅读全文
posted @ 2015-08-10 17:32 Acjx 阅读(1260) 评论(0) 推荐(1) 编辑
摘要: 1. Palindrome Partitioning https://leetcode.com/problems/palindrome-partitioning/ Given a string s, partition s such that every substring of the partition is a palindrome. Return all possibl... 阅读全文
posted @ 2015-08-07 21:59 Acjx 阅读(3687) 评论(2) 推荐(0) 编辑
摘要: 基础知识 二分非递归写法: int binary_search(const int a[], const int size, const int val) { int lower = 0; int upper = size-1; /* invariant: if a[i]==val for any i, then lower >1; if (val ==... 阅读全文
posted @ 2015-08-04 20:00 Acjx 阅读(1131) 评论(0) 推荐(0) 编辑
摘要: 给定一个等概率随机产生1~M的随机函数rand1ToM如下: public int rand1ToM(int m) { return (int) (Math.random() * m) + 1; } 除此之外不能使用任何额外的随机机制。有两个输入参数分别为m和n,请用rand1ToM(m)实现等概率随机产生1~n的随机函数rand1ToN。 Solution 在做这道题之前,我们先... 阅读全文
posted @ 2015-08-01 13:56 Acjx 阅读(361) 评论(0) 推荐(0) 编辑
摘要: https://leetcode.com/problems/kth-largest-element-in-an-array/ Find the kth largest element in an unsorted array. Note that it is the kth largest element in the sorted order, not the kth distinc... 阅读全文
posted @ 2015-07-25 16:25 Acjx 阅读(606) 评论(0) 推荐(0) 编辑
摘要: 1. Introduction We now turn to the process control provided by the UNIX System. This includes the creation of new processes, program execution, and process termination. We also look at the various... 阅读全文
posted @ 2015-07-23 18:02 Acjx 阅读(836) 评论(0) 推荐(0) 编辑
摘要: 1 End-to-end Protocols(端到端协议) 传输层协议往往是主机对主机(host-to-host)或者说是端到端(end-to-end)。通常希望传输层协议可以提供如下service: 1. 保证资料可以成功传输给对方。例如TCP,就是一个非常可靠的protocol,在做文件传输时,必须保证100%正确,因此往往使用TCP。 2. 保证封包原来的顺序。在做文件传输时,资料比较... 阅读全文
posted @ 2015-06-23 22:34 Acjx 阅读(1224) 评论(0) 推荐(0) 编辑
摘要: 1 Introduction 所谓的InternetWorking就是将很多网络连接起来,那么在这种连接的网络下我们该如何传送封包呢? 2 IP and Routers 1 IP Datagram Header Format IP Address:目前IP地址均是32个bit,称为IPV4。未来会使用IPV6,128个bit。 Identification:Router本身将封包收下... 阅读全文
posted @ 2015-06-22 22:08 Acjx 阅读(1029) 评论(0) 推荐(1) 编辑
摘要: 首先来看什么是最长公共子序列:给定两个序列,找到两个序列中均存在的最长公共子序列的长度。子序列需要以相关的顺序呈现,但不必连续。例如,“abc”, “abg”, “bdf”, “aeg”, ‘”acefg”等都是“abcdefg”的子序列。因此,一个长度为n的序列拥有2^n中可能的子序列(序列中的每一个元素只有选或者不选两种可能,因此是2^n)。 Example: LCS for input ... 阅读全文
posted @ 2015-06-18 22:24 Acjx 阅读(370) 评论(0) 推荐(0) 编辑
摘要: 在 Dynamic Programming | Set 1 (Overlapping Subproblems Property) 和 Dynamic Programming | Set 2 (Optimal Substructure Property) 中我们已经讨论了重叠子问题和最优子结构性质,现在我们来看一个可以使用动态规划来解决的问题:最长上升子序列(Longest Increasing S... 阅读全文
posted @ 2015-06-18 21:45 Acjx 阅读(340) 评论(0) 推荐(0) 编辑
摘要: 正如我们在 Dynamic Programming | Set 1 (Overlapping Subproblems Property) 中讨论的那样,当一个问题具有以下2种性质时,建议使用动态规划来求解: 1 重叠子问题(Overlapping Subproblems) 2 最优子结构(Optimal Substructure) 我们已经在 Dynamic Programming | Se... 阅读全文
posted @ 2015-06-18 21:04 Acjx 阅读(460) 评论(0) 推荐(0) 编辑
摘要: 动态规划是这样一种算法范式:将复杂问题划分为子问题来求解,并且将子问题的结果保存下来以避免重复计算。如果一个问题拥有以下两种性质,则建议使用动态规划来求解。 1 重叠子问题(Overlapping Subproblems) 2 最优子结构(Optimal Substructure) 1 重叠子问题 类似于分治法,动态规划将子问题的解合并。当多次需要用到子问题的解时,应当考虑使用动态规划。在... 阅读全文
posted @ 2015-06-18 20:36 Acjx 阅读(619) 评论(0) 推荐(0) 编辑
摘要: http://www.lintcode.com/en/problem/longest-increasing-continuous-subsequence-ii/# Give you an integer matrix (with row size n, column size m),find the longest increasing continuous subsequence i... 阅读全文
posted @ 2015-05-26 16:03 Acjx 阅读(1949) 评论(0) 推荐(0) 编辑