摘要: 问题背景:我们有一些观测数据X,这些数据假设是取值为1,...,m;我们还知道每个数据观测到的频数为: 但是我们现在无法计算B的大小。(这是一个假设,毕竟计算一串数字的和不是难事)问题: 我们需要通过仿真产生一串随机变量,并且它们的概率分布函数为:分析:如果B是可以计算的,那么(j)自然也是可以计算的。然后自然很容易随机生成服从这个概率分布的一串随机数。但是B不能计算。。。我们可以采用一个曲线救国的方案。 直观上来考虑这个问题,产生随机数时是一个一个地产生随机数,每个随机数取值为1,...,m中某一个。我们可以:1)把一个随机数看成一个状态;2)一个随机数的产生取决于前一个随机数,那么每个.. 阅读全文
posted @ 2013-07-21 16:59 wlu 阅读(2737) 评论(0) 推荐(0) 编辑
摘要: stackoverflow: http://stackoverflow.com/questions/1838304/call-the-llvm-jit-from-c-programAnother trial under llvm 3.2;In prepared IR "tst.ll", code:; ModuleID = 'tst.bc' define i32 @add1(i32 %AnArg) { EntryBlock: %0 = add ... 阅读全文
posted @ 2013-06-28 16:33 wlu 阅读(1020) 评论(0) 推荐(0) 编辑
摘要: Binary Tree Maximum Path SumGiven a binary tree, find the maximum path sum.The path may start and end at any node in the tree. For example: Given the below binary tree, 1 / \ 2 3Return 6.递归求解。maxPathSum(root)跟maxPathSum(root.left)和maxPathSum(root.right)之间的关系:root左子树的maxPath,右子树的maxP... 阅读全文
posted @ 2013-06-21 23:47 wlu 阅读(2340) 评论(0) 推荐(0) 编辑
摘要: LeetCode 跟树结构相关的题目的测试用例中大多是通过String数组来构造树。例如{2,#,3,#,4,#,5,#,6},可以构造出如下的树(将树结构逆时针选择90度显示): 6 5 4 32很直观地可以理解,输入的String数组是对树结构进行“层序”遍历得到的结果。以下代码用于构造树结构,并提供printTree用于打印树结构。package util;import java.util.LinkedList;import java.util.Queue;public class util { public static class TreeNode { int val;... 阅读全文
posted @ 2013-06-18 22:35 wlu 阅读(2727) 评论(0) 推荐(0) 编辑
摘要: Path Sum IIGiven 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 / \ 4 8 / / \ 11 13 4 / \ / \ 7 2 5 1return[... 阅读全文
posted @ 2013-06-18 20:46 wlu 阅读(243) 评论(0) 推荐(0) 编辑
摘要: 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","b"], ["a","a","b"] ]求解所有可能的回文划分。分析:p=pp(s[1...n])初始: if 阅读全文
posted @ 2013-05-01 16:56 wlu 阅读(394) 评论(0) 推荐(0) 编辑
摘要: Palindrome Partitioning IIMarGiven a string s, partition s such that every substring of the partition is a palindrome.Return the minimum cuts needed for a palindrome partitioning of s. For example, given s = "aab", Return 1 since the palindrome partitioning ["aa","b"] c 阅读全文
posted @ 2013-04-29 12:52 wlu 阅读(425) 评论(0) 推荐(0) 编辑
摘要: Dijkstra算法的MapReduce实现 阅读全文
posted @ 2012-12-11 22:24 wlu 阅读(1166) 评论(0) 推荐(0) 编辑
摘要: 在hbase客户端htable中批处理操作是通过ExecutorService实现的。ExecutorService类似于线程池,用户提交的put,delete等操作都被响应地创建了线程在ExecutorService中执行,并对各个操作的响应进行返回或异常处理。本文对ExecutorService进行初步介绍,作为hbase客户端代码学习的准备知识。 通常我们会创建一个ExecutorService对象并向其中丢一些线程,然后就任由之执行。例如下面的例子1。package java.ExecutorServiceStudy;import java.util.concurrent.Execut 阅读全文
posted @ 2012-08-10 13:45 wlu 阅读(1327) 评论(0) 推荐(0) 编辑
摘要: 引用:http://hi.baidu.com/xuelianglv/blog/item/43adb1103504ef07203f2e0c.html#0在BigTable的论文中讲到了Lease的概念。Least就好比你租房子住,签了多长的合约。如果时间长了,你可以续约(renew)。你也可能因为房子不习惯想换个地住,你就和房东说,取消住房(cancel)。当然在Hbase里,你不用交违约金。因为BigTable会同时处理很多个客户端,就好比是一个有多套房子的房东同时把不同房间租给了多个不同的客户。那它关心什么呢?我想他首先关心的是每个客户的合约(lease)什么时候到期了。在HBase里,也有 阅读全文
posted @ 2012-08-06 21:25 wlu 阅读(2370) 评论(0) 推荐(0) 编辑