算法
laiminghua
这个作者很懒,什么都没留下…
展开
-
数据结构-冒泡排序算法
int temp; int[] arr = new int[] { 1, 3, 8, 4, 5, 7, 10, 12 }; for (int j = 0; j { for (int i = arr.Length - 1; i > j; i--) { int a = arr[j];原创 2012-12-11 11:17:03 · 469 阅读 · 0 评论 -
数据结构-选择排序算法
int min, temp, k = 0; for (int i = 0; i { min = array[i]; for (int j = i + 1; j { if (min > array[j]原创 2012-12-11 11:17:37 · 345 阅读 · 0 评论 -
数据结构-插入排序算法
for (int i = 1; i { int curvalue = array[i]; int temp = i; while (temp > 0 && array[temp - 1] > curvalue) {原创 2012-12-11 11:18:04 · 417 阅读 · 0 评论 -
数据结构-二分查找算法
private static bool BinSearch(int val) { int mid=0; int lowerBound = 0; int upperBound=array1.Length-1; while (low原创 2012-12-11 11:18:34 · 637 阅读 · 0 评论 -
HashTable和HashMap的原理
昨天看了算法导论对散列表的介绍,今天看了一下Hashtable, HashMap这两个类的源代码,并参考了网上的一些观点,对它们的实现有了大概的理解。原来hashtable里的key-value还是用数组存储的,数组元素是Entry类型,同一数组索引下储存的实质是一个Entry链表,Entry中的next值指向下一个Entry.当把key-value放进hashtable时,会根据key的hash原创 2012-12-12 14:23:15 · 510 阅读 · 0 评论