- 1、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
- 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
- 4、该文档为VIP文档,如果想要下载,成为VIP会员后,下载免费。
- 5、成为VIP后,下载本文档将扣除1次下载权益。下载后,不支持退款、换文档。如有疑问请联系我们。
- 6、成为VIP后,您将拥有八大权益,权益包括:VIP文档下载权益、阅读免打扰、文档格式转换、高级专利检索、专属身份标志、高级客服、多端互通、版权登记。
- 7、VIP文档为合作方或网友上传,每下载1次, 网站将根据用户上传文档的质量评分、类型等,对文档贡献者给予高额补贴、流量扶持。如果你也想贡献VIP文档。上传文档
查看更多
排序的总结(Summary of sorting)
排序的总结(Summary of sorting)
******************************************************************** / /
/ *函数功能:对1 N连续数列的无序数组进行排序,例如{ 10,6,9,5,2,8,4,7,1,3 };
******************************************************************** / /
无效排序(int)
{
int len = sizeof(NUM)/ sizeof(int);
int变量;
为(int = i 0;i ;)
{
温度[数字] 1 ];
[数量] 1;
[ i ] =临时温度;
如果(数字i = i + i 1)
{
++;
}
}
}
相关知识介绍(所有定义只为帮助读者理解相关概念,并非严格定义):
1、稳定排序和非稳定排序
简单地说就是所有相等的数经过某种排序方法后,仍能保持它们在排序之前的相对次序,我们就说这种排序方法是稳定的反之,就是非稳定的。
比如一组数排序前是A1,A2,A3:A4,A5,A4,其中A2 =经过某种排序后为A1,A2,A3,A4,A5,
则我们说这种排序是稳定的,因为A2排序前在A4的前面,排序后它还是在A4的前面。假如变成A1、A4、A2、A3、A5就不是稳定的了。
2、内排序和外排序
在排序过程中,所有需要排序的数都在内存,并在内存中调整它们的存储顺序,称为内排序;
在排序过程中,只有部分数被调入内存,并借助内存调整数在外存中的存放顺序排序方法称为外排序。
3、算法的时间复杂度和空间复杂度
所谓算法的时间复杂度,是指执行算法所需要的计算工作量一个算法的空间复杂度,一般是指执行这个算法所需要的内存空间。
===============================================
功能:选择排序
输入:数组名称(也就是数组首地址)、数组中元素个数
算法思想简单描述:
在要排序的一组数中,选出最小的一个数与第一个位置的数交换;然后在剩下的数当中再找最小的与第二个位置的数交换,如此循环到倒数第二个数和最后一个数比较为止。选择排序是不稳定的。算法复杂度O(N2)--【N的平方]
===============================================
无效select_sort(int x,int n)
{
int,j,min,t;
为(i = 0;i n;i++)/ *要选择的次数:0 ~ N-2共N-1次*/
{
min =我;/ *假设当前下标为我的数最小,比较后再调整*/
为(j = i + 1;J<n;j++)/ * * /循环找出最小的数的下标是哪个
{
如果(*(x)) *(x + min))
{
Min = J; / * if the back of the front than the number of small, is to write it down the subscript.
}
}
If (min! = I) / * if min in the cycle of change, we need to exchange data.
{
T = * (x+i);
* (x+i) = * (x+min);
* (x+min) = t;
}
}
}
================================================
Function: direct insertion sort
Input: the name of the array (that is, the initial address of the array) and the number of elements in the array
The algorithm idea is described simply:
In a set of numbers to be sorted, suppose that the [n=2] numbers in the front (n-1) are already in order, and now insert the first n numbers into the ordinal numbers in front, so that the N numbers are in order. Repeat this repeatedly until all are in order. Direct insertion sorting is stable. The time complexity of the algorithm
您可能关注的文档
- 手机bga元件的维修技术与操作技能(上)(Maintenance technology and operation skills of mobile phone BGA components (Part I)).doc
- 抚顺市采煤沉陷区管理规定(Provisions of Fushun Municipality on the administration of coal mining subsidence areas).doc
- 拉萨市城市地下管线管理暂行办法(Interim Measures for the administration of urban underground pipelines in Lhasa).doc
- 拍牌攻略(Brand introduction).doc
- 拒绝批假条 管理车间主管被泼硫酸(Refuse to fake management supervisor was splashed sulfuric acid).doc
- 拓维思资料(Invensys extension data).doc
- 拍摄十八忌(Shooting eighteen bogey).doc
- 招商基础知识(Basic knowledge of investment).doc
- 招投标临时信息(Temporary information of bidding).doc
- 招商局董事长秦晓应将国有资产分散到民众手中(China Merchants board chairman Qin Xiao state-owned assets should be dispersed into the hands of the masses).doc
- 探究农田林网策略山西(Study of farmland shelterbelt strategy in Shanxi).doc
- 探索人民币国际化的路径(Explore the path of RMB internationalization).doc
- 探索风险发生规律提高税收风险管理水平(Explore the law of risk occurrence and raise the level of tax risk management).doc
- 探讨式教学在高中化学实验中的实施——宜兴中小学辅导(Implementation of inquiry teaching in senior high school chemistry experiment -- primary and secondary school guidance in Yixing).doc
- 探讨工业锅炉的节能措施(Discussion on energy saving measures for industrial boilers).doc
- 探访日本足球各个层级(Visit all levels of Japanese football).doc
- 接入网级数在铁路的应用(Application of access network series in Railway).doc
- 控制器在midi音乐制作中的运用(The application of controller in MIDI music production).doc
- 控制网平差软件介绍(Introduction to adjustment software of control network).doc
- 推介十大最具潜力的青年创业项目(Recommend the ten most promising young entrepreneurship projects).doc
最近下载
- 《复活(节选)》课件38张高中语文选择性必修上册.pptx VIP
- 复合手术室的管理课件.pptx VIP
- 《中华人民共和国节约能源法》解读与培训课件.pptx VIP
- 今年清华大学学术大咖分享国家社科申报秘籍.doc VIP
- 2025新营销5.0营销平台时代.pdf VIP
- 排球:正面双手垫球 教案.docx VIP
- 2025年17周新模式英语1Unit1-4全套教案.pdf VIP
- RocscienceSlide岩土边坡稳定性分析操作教程(非.pdf VIP
- AWS B4.0M-00焊缝机械试验方法.pdf VIP
- GB_T50795-2012:光伏发电工程施工组织设计规范.pdf VIP
文档评论(0)