摘要: Sort with Swap(0, i) Given any permutation of the numbers {0, 1, 2,..., N−1}, it is easy to sort them in increasing order. But what if Swap(0, *) is t 阅读全文
posted @ 2021-05-24 17:43 onlyblues 阅读(194) 评论(0) 推荐(0)
摘要: Insert or Merge According to Wikipedia: Insertion sort iterates, consuming one input element each repetition, and growing a sorted output list. Each i 阅读全文
posted @ 2021-05-05 08:24 onlyblues 阅读(138) 评论(0) 推荐(0)
摘要: 写在前面:最近好久没有写blog了,这是因为前段时间在准备计算机转专业的笔试。哎,笔试成绩不容乐观啊,虽然现在还没有公布笔试成绩,但很担心自己没有60分,没有机会去面试。笔试的程序设计题型非常出乎意料,竟然有四道程序设计大题,而且还是在纸上写代码!我非常不习惯,这是因为我几乎都是在IDE码代码,而且 阅读全文
posted @ 2021-04-30 21:38 onlyblues 阅读(344) 评论(0) 推荐(0)
摘要: 并查集(union-find disjoint sets)是一种十分精巧和简洁的数据结构,主要用于处理不相交集合的合并问题。正如它的名字一样,并查集的主要的操作有合并(union)与查找(find)。一些算法也会用到并查集,比如求最小生成树的Kruskal算法。下面先通过举例说明并查集的基本概念。 阅读全文
posted @ 2021-04-16 19:15 onlyblues 阅读(4810) 评论(1) 推荐(0)
摘要: 六度空间 “六度空间”理论又称作“六度分隔(Six Degrees of Separation)”理论。这个理论可以通俗地阐述为:“你和任何一个陌生人之间所间隔的人不会超过六个,也就是说,最多通过五个人你就能够认识任何一个陌生人。”如图1所示。 图1 六度空间示意图 “六度空间”理论虽然得到广泛的认 阅读全文
posted @ 2021-04-14 17:05 onlyblues 阅读(1670) 评论(0) 推荐(1)
摘要: Saving James Bond - Hard Version This time let us consider the situation in the movie "Live and Let Die" in which James Bond, the world's most famous 阅读全文
posted @ 2021-04-13 19:14 onlyblues 阅读(221) 评论(0) 推荐(1)
摘要: Saving James Bond - Easy Version This time let us consider the situation in the movie "Live and Let Die" in which James Bond, the world's most famous 阅读全文
posted @ 2021-04-10 19:05 onlyblues 阅读(144) 评论(0) 推荐(0)
摘要: 前言 我们知道,要构造Huffman Tree,每次都要从堆中弹出最小的两个权重的节点,然后把这两个权重的值相加存放到新的节点中,同时让这两个节点分别成为新节点的左右儿子,再把新节点插入到堆中。假设节点个数为n,则重复n-1次后,最后堆中的那个节点就是Huffman Tree的根。 用堆实现当然可以 阅读全文
posted @ 2021-04-08 09:41 onlyblues 阅读(530) 评论(0) 推荐(0)
摘要: Huffman Codes In 1953, David A. Huffman published his paper "A Method for the Construction of Minimum-Redundancy Codes", and hence printed his name in 阅读全文
posted @ 2021-04-08 07:51 onlyblues 阅读(284) 评论(0) 推荐(0)
摘要: File Transfer We have a network of computers and a list of bi-directional connections. Each of these connections allows a file transfer from one compu 阅读全文
posted @ 2021-04-05 13:07 onlyblues 阅读(375) 评论(0) 推荐(0)
Web Analytics