- 博客(11)
- 资源 (1)
- 收藏
- 关注
转载 骆驼和玉米 [No. 80]
一个骆驮运玉米从A地到B地, 骆驮一次最多运1000个玉米,A地距离B地有1000米远. 而骆驮每走1米就要吃一个玉米.现在有3000个玉米.现在要从A运到B. 问到B地最多还能剩下多少个玉米?wantalcs给出的答案是: class Program{ private static readonly int _maxLoad = 1000; //单次运载上限 pr
2010-07-15 09:21:00 2246
原创 Selection sort and its implementation
selection sort and its implementation.
2010-07-21 07:20:00 566
原创 Counting sort
The running time of counting sort is O(n), and usually, the running time of sorting algorithms will be either O(n^2) or O(n lgn), the reason why counting sort is O(n) is that it doesn't have the comp
2010-07-18 07:38:00 807
原创 快速排序算法递归和非递归实现 [# 29]
Quick sort algorithm is quite like the merge sort, cause both of them use the idea of divide-and-conquer, but be aware, quick sort doesn't conquer it subproblems, cause when the problem is divided int
2010-07-18 04:56:00 900
原创 堆排序(Heap Sort)算法的实现
堆排序算法思想非常简单,先把一个数组看成一个heap, 在下面的实现中,我使用的是max heap, 也就是说根总是比叶子大。所以我们第一步就是建立max heap。建立完毕以后,很明显这个heap的root就是最大的,把最大的根放在数组的最后一个位置,把数组长度缩小一个位置,这样最大的那个数就不会再参与到下次的排序当中,这时,除了根以外,heap的其它部分都保持max heap的特性,所以我们需
2010-07-17 02:07:00 1813
原创 归并排序(Merge sort)算法
Merge sort 算法的思想就是把数组分成更小的数组,合并的时候再排序。由于是二分,所以总的时间为 T(n) = 2 T(n/2) + \theta (n) = O(n * lgn)。public void mergeSort(int[] array, int start, int end) { if (start < end) { int mid = start + (end
2010-07-15 07:07:00 2111
原创 二分查找算法(Binary Search)的实现
用二分查找在已排序的数组中查看该数组是否含有一个特定的值是非常快速的,时间复杂度为O(lgn). 二分查找思想很简单,但是实现的时候会在边界条件上出现一些意想不到的问题。 现贴出自己写的程序,供大家参考。第一个实现是基于迭代方式:/// /// implement Binary Search algorithm through iteration approach./// ///
2010-07-15 03:09:00 11937
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人