严蔚敏 数据结构第十章 内部排序的具体代码(c++,附测试数据)(Yan Yumin data structure of the tenth chapter of the internal sorting of the specific code (c++, attached to test data)).doc
- 1、本文档共23页,可阅读全部内容。
- 2、有哪些信誉好的足球投注网站(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
严蔚敏数据结构第十章内部排序的具体代码(c,附测试数据)(YanYumindatastructureofthetenthchapteroftheinternalsortingofthespecificcode(c,attachedtotestdata))
严蔚敏 数据结构第十章 内部排序的具体代码(c++,附测试数据)(Yan Yumin data structure of the tenth chapter of the internal sorting of the specific code (c++, attached to test data))
Test data: / * generated EXE file, directly to the test data can be pasted into the DOS window!
Ten 32
1187653245782036, 2894 32
1187653245782036, 2894
1187653245782036, 2894
Ten 32
1187653245782036, 2894
Thirty-six
* /
#includeiostream
#define MAXSIZE / / 20 order table length
#define LT (a, b) (a b)
#define EQ (a, b) (a = b)
#define LQ (a, b) (a b)
Using namespace std;
Typedef int KeyType; / / keyword in this chapter are as integer
Typedef char* InfoType;
Typedef struct {
KeyType key;
InfoType otherinfo;
}RedType; / / record type
Typedef struct {
RedType r[MAXSIZE+1]; unit //0 used as sentry
Int length;
}SqList; / / the order of the table type
//*******************************************
/ / direct insertion sort
Void InsertSort (SqList, L) {
/ / sorted in non descending order from the table, after the forward sequence comparison
Int, I, j;
For (I = 2; I L.length; + + I)
If LT (L.r[i].key, L.r[i-1].key) {
L.r[0]=L.r[i];
For (J = I-1; LT (L.r[0].key, L.r[j].key); --j)
L.r[j+1]=L.r[j];
L.r[j+1]=L.r[0];
}//if
}
//***********************
/ / binary insertion sort
Void BInsertSort (SqList, L) {
Int, I, j;
Int, high, low, m;
For (i=2; i=L.length; ++i) {
L.r[0]=L.r[i];
Low=1; high=i-1; / / search range from 1 to I-1
While (low=high) {
M= (low+high) /2;
If LT (L.r[0].key, L.r[m].key) high=m-1;
Else low=m+1; / / to find the number of L.r[0].key =L.r[m].key, which is different with the binary search. Its also the reason why high+1 is taken underneath
}//while bisearch
For (j=i-1; j=high+1; --j) L.r[j+1]=L.r[j];
After the end of high+1 / / bisearch position for insertion position
L.r[high+1]=L.r[0];
}//for
}//BInsertSort
//*********************************
Typedef int SortData;
Void Swap (SortData, a, SortData, b) {
SortData temp;
Temp=a;
A=b;
B=temp;
}
//************************************
您可能关注的文档
- --华安盛道管理网 如何在单件装配企业推行精益生产(How to Huaan shendall management network, the implementation of lean production in assembly enterprises).doc
- --华安盛道管理网 定置管理(Huaan Shengdao management network management).doc
- 03判断推理---演绎推理(03 judgment reasoning deductive reasoning).doc
- 12秋《经济法概论》作业3(12 autumn, introduction to economic law, assignment 3).doc
- 2007年感动中国十大人物(2007 moved China's ten great men).doc
- 1959年资料5 中医对泄泻的认识和治疗(Understanding and treatment of traditional Chinese medicine on diarrhea in 1959 5).doc
- 2010年咨询师项目决策分析与评价精选练习及解析(Selection, practice and analysis of consultants' project decision analysis and evaluation in 2010).doc
- 2011初级士基础知识(2011 basic knowledge of Junior School).doc
- 2011年西医综合考研傲视宝典(2011 Western comprehensive examination disdain for the book).doc
- 2011年高考语文试题分类汇编—名篇名句默写(2011 college entrance exam of Chinese famous famous dictation assembly - Classification).doc
- 北师大版小学数学三年级上册《寄书》教学设计.docx
- 统编版(部编版)语文二年级上册《雪孩子》教学设计.docx
- 统编版(部编版)语文二年级上册《八角楼上》教学设计.docx
- 北师大版小学数学三年级上册《长方形周长》教学设计.docx
- 北师大版小学数学三年级上册《丰收了》教学设计.docx
- 统编版(部编版)语文二年级上册《夜宿山寺》教学设计.docx
- 统编版(部编版)语文二年级上册《风娃娃》教学设计.docx
- 统编版(部编版)语文二年级上册《朱德的扁担》教学设计.docx
- 统编版(部编版)语文二年级上册《难忘的泼水节》教学设计.docx
- 统编版(部编版)语文二年级上册《纸船和风筝》教学设计.docx
文档评论(0)