随笔分类 - Algorithm
摘要:1 using System; 2 using System.Collections.Generic; 3 using System.Linq; 4 using System.Text; 5 using System.Threading.Tasks; 6 7 namespace B...
阅读全文
摘要:1 using System; 2 using System.Collections.Generic; 3 using System.Linq; 4 using System.Text; 5 using System.Threading.Tasks; 6 7 namespace S...
阅读全文
摘要:1 using System; 2 using System.Collections.Generic; 3 using System.Linq; 4 using System.Text; 5 using System.Threading.Tasks; 6 7 namespace S...
阅读全文
摘要:1 using System; 2 using System.Collections.Generic; 3 using System.Linq; 4 using System.Text; 5 using System.Threading.Tasks; 6 7 namespace Cocktail...
阅读全文
摘要:1 using System; 2 using System.Collections.Generic; 3 using System.Linq; 4 using System.Text; 5 using System.Threading.Tasks; 6 7 namespace R...
阅读全文
摘要:1 using System; 2 using System.Collections.Generic; 3 using System.Linq; 4 using System.Text; 5 using System.Threading.Tasks; 6 7 namespace ShellSor...
阅读全文
摘要:通俗的插排是对一个整型数组进行升序排序,可以看出每个元素插入到队列中经过两个步骤:先是挨个比较,找到自己所在的位置;然后把后面的数据全部移位,然后把元素插入。要把数据插入,移位是必不可少了。那么,挨个比较倒是可以优化,因为要插入的队列已经是排序好的,我们可以使用二分法来减少比较的次数。二分法的时间复...
阅读全文
摘要:说明:很简答的优化,却有很多人容易在面试时候栽在这个简单的问题上。“冒泡排序”在面试中是很容易被问到的排序算法,也是最简单的排序算法,当被问到,“冒泡排序怎么优化?”,很多人就懵了,冒泡还能优化?答案是可以的。但是,在对50000个随机数进行测试中,发现,优化的冒泡和一般的冒泡在性能上几乎一样。于是...
阅读全文
摘要:一. 快速排序的基本思想快速排序使用分治的思想,通过一趟排序将待排序列分割成两部分,其中一部分记录的关键字均比另一部分记录的关键字小。之后分别对这两部分记录继续进行排序,以达到整个序列有序的目的。二.快速排序的三个步骤1) 选择基准:在待排序列中,按照某种方式挑出一个元素,作为 "基准"(pivot...
阅读全文
摘要:http://blog.csdn.net/yexinghai/article/details/4649923
阅读全文
摘要:堆(英语:heap),是计算机科学中一类特殊的数据结构的统称。堆通常是一个可以被看做一棵树的数组对象。在队列中,调度程序反复提取队列中第一个作业并运行,因为实际情况中某些时间较短的任务将等待很长时间才能结束,或者某些不短小,但具有重要性的作业,同样应当具有优先权。堆即为解决此类问题设计的一种数据结构...
阅读全文
摘要:1 public static void SelectSort(int[] arr) 2 { 3 int min, temp; 4 for (int i = 0; i < arr.Length; i++) 5 ...
阅读全文
摘要:1 using System; 2 using System.Collections.Generic; 3 using System.Linq; 4 using System.Text; 5 using System.Threading.Tasks; 6 7 namespace Sort 8 {...
阅读全文