This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int[] InsertionSort(int[] array){ | |
for(int i = 1; i<array.length; i++){ | |
int insertValue = array[i]; | |
int cursor = i-1; | |
while(cursor >= 0 && array[cursor]>insertValue){ | |
array[cursor+1] = array[cursor]; | |
cursor--; | |
} | |
array[cursor+1] = insertValue; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*布隆过滤器(Bloom Filter)是1970年由Burton Howard Bloom提出的。 | |
*它实际上是一个很长的二进制向量和一系列随机映射函数。 | |
*布隆过滤器可以用于检索一个元素是否在一个集合中。 | |
*它的优点是空间效率和查询时间都远远超过一般的算法,缺点是有一定的误识别率和删除困难。 | |
*/ | |
import java.util.BitSet; | |
public class SimpleBloomFilter { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
*Shell 排序算法是D.L Shell于1959年发明的,基本思想:先比较距离远的元素, | |
而不是像简单交换排序算法那样先比较相邻的元素,这样可以减少大量的无序情况, | |
从而减轻后续工作。被比较的元素之间的距离逐渐减少,直到减到1, | |
这时候的排序变成相邻元素的交换。 | |
shellsort函数:按递增顺序对v[0]...v[n]进行排序 | |
*/ | |
void shell_sort(int v[],int n){ | |
int gap, i, j, temp; |