2009年8月12日
摘要: [代码]两者的差别在于前一种实现方案:是逐渐将大数“沉底”,而第二种实现方案,是逐渐将小数“上浮”。验证主函数如下#include<iostream>using namespace std;void main(){ void BubbleSort(int *A ,int n); int a[6]={3,7,4,5,4,9}; Bubble... 阅读全文
posted @ 2009-08-12 18:58 finallyly 阅读(215) 评论(0) 推荐(0) 编辑
摘要: Describe a (nlgn)-time algorithm that, given a set S of integers and another integer x, determings whether or not there exist two elements in S whose sum is exactly x.汉语:描述一个nlgn复杂度的算法:给定一个n个数字的集合,和另一... 阅读全文
posted @ 2009-08-12 14:27 finallyly 阅读(214) 评论(1) 推荐(0) 编辑
摘要: int BinarySerach(A, begin,end,elem)l<-begin;h<-end;while l<=hmid=(l+h)/2;if A[mid]=elemthenreturn mid;if A[mid]>elem then h=mid-1 else h=mid+1return NILBinarySearch(A,begin,end,elem)l<-... 阅读全文
posted @ 2009-08-12 11:01 finallyly 阅读(1761) 评论(0) 推荐(0) 编辑
摘要: #include<iostream>using namespace std;#define NIL 1000;void main(){ int BinarySearch(int *A,int begin,int end ,int elem);int A[8]={1,3,5,7,8,10,12,14};int index=BinarySearch(A,0,7,10);cout<&l... 阅读全文
posted @ 2009-08-12 10:36 finallyly 阅读(457) 评论(0) 推荐(0) 编辑
摘要: 这几天,由于项目工作需要暂停,所以我就抽空开始学《算法导论》。认为这是一本很不错的书,不仅介绍了各种算法,而且给出了算法的由来(它的发明者是如何想到它的),以及效率的数学计算,当然还包含了算法的数学基础。我觉得这本书应该很耐看。它不向目前的一些国内的算法教材,只是罗列些经典算法,让你应用的时候可以想到去套这些算法。 昨天晚上和大师兄说了我正在学算法导论的事情。本以为大师兄会很支持,结果大师兄说,其... 阅读全文
posted @ 2009-08-12 10:25 finallyly 阅读(1887) 评论(0) 推荐(0) 编辑