慕慕的玩具和游戏背后有很多有趣的算法话题。之前已经写三篇(如下):
第四篇的游戏是一组卡牌,称为疯狂对对碰,网上很容易买到,如下图:

这个游戏是由一组卡牌,每个卡牌上有一些图标(这里是不同国家的国旗),任何两张卡牌的国旗组合里,有且只有一个共同点(这是我们的游戏经验)。家人陪慕慕玩这个游戏的办法是,洗牌,然后每个人分同样多的牌,每次各出一张,最快发现唯一相同国旗的人,赢走两张牌。最后计赢取的牌的数目决定胜负。
Continue reading
慕慕的玩具和游戏背后有很多有趣的算法话题。之前已经写三篇(如下):
第四篇的游戏是一组卡牌,称为疯狂对对碰,网上很容易买到,如下图:

这个游戏是由一组卡牌,每个卡牌上有一些图标(这里是不同国家的国旗),任何两张卡牌的国旗组合里,有且只有一个共同点(这是我们的游戏经验)。家人陪慕慕玩这个游戏的办法是,洗牌,然后每个人分同样多的牌,每次各出一张,最快发现唯一相同国旗的人,赢走两张牌。最后计赢取的牌的数目决定胜负。
Continue readingDuring the EPIC2 year shutdown of VMware, I spent some time reading the book Algebra. Many trivial matters so the progress is slow. This is the first note on Group. This part is important and I find MIT OCW’s course Modern Algebra uses almost half of the content for group-related topics.
Continue reading2023-01-03更新:
第一题我后来想到可以用Symbolic Method求解,参考后来写的英文blog: Symbolic Method to solve a probability problem.
刷知乎刷到一个问题
https://www.zhihu.com/question/419625606

咱看了看一时间想试试看。
Continue readingQuicksort is an elegant and efficient sorting algorithm. Analysis of quick sort is a lot of fun. The core part of quick sort algorithm is partition the original array into two parts. This part of code is shown below (in java):
private void quicksort(int[] a, int lo, int hi) {
if (hi <= lo) return;
int i = lo - 1, j = hi;
int t, v = a[hi];
while (true) {
while (a[++i] < v);
while (v < a[--j])
if (j == lo) break;
if (i >= j) break;
t = a[i]; a[i] = a[j]; a[j] = t;
}
t = a[i];
a[i] = a[hi];
a[hi] = t;
quicksort(a, lo, i - 1);
quicksort(a, i + 1, hi);
}
Dynamic hash table will expand when it is full. If we simply use modulo to map hash value to the entry position, there are some properties on the data movement while expanding.
Let’s start with some questions:
If you are not familiar with Coupon collector’s problem, please first read the following page:
Six years ago when I was in graduate school, I encountered this problem. I did not want to use Indicator variable method to solve it, so I tried my best to solve it using infinite series. I came up with a complicated formula which was not accurate and I am not satisfied because this means it is wrong.

Jump consistent hash algorithm is a consistent hash algorithm that has been discussed in the previous blog Jump Consistent Hash Algorithm. After adding some new hosts in a distributed storage system, at some
My colleague asks me for a proof of the following algorithm:

is a binary square matrix whose elements are chosen from the set
. That is
. And
is an orthogonal matrix,
.
Theorem: prove that any sub matrix of
, with size
, if this sub matrix
contains only
(no
in it at all), then
.