网站大量收购独家精品文档,联系QQ:2885784924

各种排序算法(国外英语资料).doc

  1. 1、本文档共42页,可阅读全部内容。
  2. 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
  3. 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  4. 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
各种排序算法(国外英语资料)

各种排序算法(国外英语资料) The various internal sorting sorting methods: bubble sort, quick sort, simple selection sort, binary insertion sort, Hill sort, heap sort, merge sort (non recursive algorithm), radix sort (1) bubble sort #includestdio.h #includemalloc.h #define OK 1 #define ERROR 0 #define LIST_INIT_SIZE 100 #define LISTINCREMENT 10 #define ElemType int Typedef struct { Int *elem; Int length; Int listsize; }SqList; Int InitList_Sq (SqList L) { L.elem= (ElemType*) malloc (LIST_INIT_SIZE*sizeof (ElemType)); If (... L.elem) return ERROR; L.length=0; L.listsize=LIST_INIT_SIZE; Return OK; } Int Load_Sq (SqList L) { Int i; If (L.length==0) printf (The, List, is, empty, \n); Else { Printf (The List / / is:); For (i=0; iL.length; i++) Printf (%d, L.elem[i]); Printf (\n); } Return OK; } Int, main () { SqList L; Int, I, J, t, f=0; InitList_Sq (L); Scanf (%d, L.length); For (i=0; iL.length; i++) { Scanf (%d, L.elem[i]); } For (i=L.length-1; i=0; i--) { For (j=0; ji; j++) { If (L.elem[j]L.elem[j+1]) { T=L.elem[j]; L.elem[j]=L.elem[j+1]; L.elem[j+1]=t; F=1; } } If (f==1) {Load_Sq (L); f=0;} } Load_Sq (L); } (2) quick sort #includestdio.h #includemalloc.h #define OK 1 #define ERROR 0 #define LIST_INIT_SIZE 100 #define LISTINCREMENT 10 #define ElemType int Typedef struct { Int *elem; Int length; Int listsize; }SqList; Int InitList_Sq (SqList L) { L.elem= (ElemType*) malloc (LIST_INIT_SIZE*sizeof (ElemType)); If (... L.elem) return ERROR; L.length=0; L.listsize=LIST_INIT_SIZE; Return OK; } Int Load_Sq (SqList L) { Int i; If (L.length==0) printf (The, List, is, empty, \n); Else { Printf (The List / / is:); For (i=1; i=L.length; i++) Printf (%d, L.elem[i]); Printf (\n); } Return OK; } Int Partition (SqList, L, int, low, int, high) { Int key; L.elem[0]=L.elem[low]; Key=L.elem[low]; While (lowhigh) { While (lowhighL.elem[high]=key) --high; L.elem[low]=L.elem[high]; While (lowhighL.elem[low]=key) ++low; L.elem[high]=L.elem[low]; } L.elem[low]=L.elem[0]; Load_Sq (L); Return low; } Void QSo

您可能关注的文档

文档评论(0)

f8r9t5c + 关注
实名认证
内容提供者

该用户很懒,什么也没介绍

版权声明书
用户编号:8000054077000003

1亿VIP精品文档

相关文档