收藏 分销(赏)

第10章排序练习题答案.doc

上传人:a199****6536 文档编号:2281118 上传时间:2024-05-24 格式:DOC 页数:6 大小:111.55KB
下载 相关 举报
第10章排序练习题答案.doc_第1页
第1页 / 共6页
第10章排序练习题答案.doc_第2页
第2页 / 共6页
第10章排序练习题答案.doc_第3页
第3页 / 共6页
第10章排序练习题答案.doc_第4页
第4页 / 共6页
第10章排序练习题答案.doc_第5页
第5页 / 共6页
点击查看更多>>
资源描述

1、these precious and worth cherishing. Second, scientific research situation, grasp the opportunities and challenges of transformation and upgrading of full completion of the Thirteen-Five development tasks, start is crucial. Focused grand blueprint, must to history of thinking views trend, put associ

2、ate times forward of pulse, stepped on associate economic law of drums, find associate transformation upgrade of path, in grasp macro trend in the advance science development; to strategy of vision conspiracy to global, always tight buckle national macro policy oriented, accurate grasp County love a

3、ctual, based overall caught opportunities, and PCT thought, ensure County economic social development always along right track continued forward; to precision of measures seeking breakthrough, tightly pegged focus task and bottleneck restricted, Science and identify practical and effective measures,

4、 advance breakthrough, ensuring all tasks carry out to the letter; based on scientific assessment and strict implementation, persist in combining routine supervision and centralized supervision, accurate assessment Township departments, strictly cash rewards, prompted the departments own implementat

5、ion at all levels. In working to advance, to truly grasp the Guide, seize the opportunity, finding a position and play to our strengths and take the initiative, ensure that the start of the new year tree, new performance. Grasp the Guide, is to dock in policy measures to seize the initiative. Accura

6、te grasp of the Central Government, provinces and cities to speed up the development of new policies and new initiatives with a high degree of policy acumen to capture opportunities to accelerate development. Follow-up to promote the transformation and upgrading of the five great ideas offer a great

7、 chance. Five large development philosophy is the Party Central Committee with a view to promote economic transformation and upgrading, complete the building of a well-off society in major decisions and arrangements, is the development of a profound change. County-wide at all levels should conscient

8、iously study and implement, implement the five ideas, green development, open development, on which to share advantages, and actively explore new path of innovative and coordinated development, changing the concept of leading the transformation of development mode of development, promote the develop

9、ment of quality improvement. Floor supply side structural reform implementation provides an effective strategy for improving the quality of development. Supply side structural reform is future full deepening reform of plays, to according to macro policy to stability, and industry policy to associate

10、, and micro policy to live, and reform policy to real, and social policy to backing of requirements, keen grasp Central, and provinces release out of new signal, combined County love actual accurate docking, full grasp to capacity, and to inventory, and to lever, and drop cost, and fill short Board

11、five big focus task implementation, prompted County economic transformation upgrade, and continued upgrade. Poverty第10章排序练习题答案一、填空题1. 大多数排序算法都有两个基本的操作: 比较 和 移动 。2. 在对一组记录(54,38,96,23,15,72,60,45,83)进行直接插入排序时,当把第7个记录60插入到有序表时,为寻找插入位置至少需比较 3 次。 3. 在插入和选择排序中,若初始数据基本正序,则选用 插入 ;若初始数据基本反序,则选用 选择 。正序时两种方法移

12、动次数均为0,但比较次数量级不同,插入法:n-1即O(n),选择法:O(n2)反序时两种方法比较次数量级相同,均为O(n2),但移动次数不同,插入法:O(n2),选择法:3(n-1)即O(n)4. 在堆排序和快速排序中,若初始记录接近正序或反序,则选用 堆排序 ;若初始记录基本无序,则最好选用 快速排序 。5. 对于n个记录的集合进行冒泡排序,在最坏的情况下所需要的时间是 O(n2) 。若对其进行快速排序,在最坏的情况下所需要的时间是 O(n2) 。6. 对于n个记录的集合进行归并排序,所需要的平均时间是 O(nlog2n) ,所需要的附加空间是 O(n) 。7 对于n个记录的表进行2路归并排

13、序,整个归并排序需进行 log2n 趟(遍)。8. 设要将序列(Q, H, C, Y, P, A, M, S, R, D, F, X)中的关键码按字母序的升序重新排列,则:冒泡排序一趟扫描的结果是 H C Q P A M S R D F X Y ;二路归并排序一趟扫描的结果是 H Q C Y A P M S D R F X;快速排序一趟扫描的结果是 F H C D P A M Q R S Y X ;堆排序初始建堆的结果是 Y S X R P C M H Q D F A 。(大根堆)9. 在堆排序、快速排序和归并排序中,若只从存储空间考虑,则应首先选取 堆排序 方法,其次选取 快速排序方法,最后

14、选取归并排序方法;若只从排序结果的稳定性考虑,则应 选取归并排序方法;若只从平均情况下最快考虑,则应选取快速排序方法;若只从最坏情况下最快并且要节省内存考虑,则应选取堆排序方法。二、单项选择题( C )1 排序方法中,从未排序序列中依次取出元素与已排序序列(初始时为空)中的元素进行比较,将其放入已排序序列的正确位置上的方法,称为. 归并排序 . 冒泡排序 . 插入排序 . 选择排序( D )2从未排序序列中挑选元素,并将其依次插入已排序序列(初始时为空)的一端的方法,称为. 冒泡排序 . 归并排序 . 插入排序 . 选择排序( B )3对个不同的排序码进行冒泡排序,在下列哪种情况下比较的次数最

15、多。. 从小到大排列好的 . 从大到小排列好的 . 元素无序 . 元素基本有序( D )4对个不同的排序码进行冒泡排序,在元素无序的情况下比较的次数为. n+1 . n . n-1 . n(n-1)/2( C )5快速排序在下列哪种情况下最易发挥其长处。. 被排序的数据中含有多个相同排序码 . 被排序的数据已基本有序. 被排序的数据完全无序 . 被排序的数据中的最大值和最小值相差悬殊( B )6 对有n个记录的表作快速排序,在最坏情况下,算法的时间复杂度是AO(n) BO(n2) CO(nlog2n) DO(n3)( C )7若一组记录的排序码为(46, 79, 56, 38, 40, 84)

16、,则利用快速排序的方法,以第一个记录为基准得到的一次划分结果为. 38, 40, 46, 56, 79, 84 . 40, 38, 46 , 79, 56, 84 . 40, 38,46, 56, 79, 84 . 40, 38, 46, 84, 56, 79( D )8下列关键字序列中, 是堆。. 16, 72, 31, 23, 94, 53 . 94, 23, 31, 72, 16, 53 . 16, 53, 23, 94,31, 72 . 16, 23, 53, 31, 94, 72( B )9堆是一种 排序。. 插入 .选择 . 交换 . 归并( C )10堆的形状是一棵 . 二叉排序

17、树 .满二叉树 . 完全二叉树 . 平衡二叉树( B )11若一组记录的排序码为(46, 79, 56, 38, 40, 84),则利用堆排序的方法建立的初始堆为. 79, 46, 56, 38, 40, 84 . 84, 79, 56, 38, 40, 46 . 84, 79, 56, 46, 40, 38 . 84, 56, 79, 40, 46, 38 ( C )12 下述几种排序方法中,要求内存最大的是. 插入排序 .快速排序 . 归并排序 . 选择排序三、简答题设待排序的关键码序列为12, 2, 16, 30, 28, 10, 16*, 20, 6, 18, 试分别写出使用以下排序方

18、法每趟排序后的结果。(1) 直接插入排序 (2)起泡排序(3) 直接选择排序 (4) 快速排序 (5) 二路归并排序(6)堆排序(1)直接插入排序12 2 16 30 28 10 16* 20 6 18 2 12 16 30 28 10 16* 20 6 18 2 12 16 30 28 10 16* 20 6 18 2 12 16 30 28 10 16* 20 6 18 2 12 16 28 30 10 16* 20 6 18 2 10 12 16 28 30 16* 20 6 18 2 10 12 16 16* 28 30 20 6 18 2 10 12 16 16* 20 28 30

19、6 18 2 6 10 12 16 16* 20 28 30 18 2 6 10 12 16 16* 18 20 28 30(2)起泡排序2 12 16 28 10 16* 20 6 18 30 2 12 16 10 16* 20 6 18 28 30 2 12 10 16 16* 6 18 20 28 30 2 10 12 16 6 16* 18 20 28 30 2 10 12 6 16 16* 18 20 28 30 2 10 6 12 16 16* 18 20 28 30 2 6 10 12 16 16* 18 20 28 302 6 10 12 16 16* 18 20 28 30

20、(3)直接选择排序2 12 16 30 28 10 16* 20 6 18 2 6 16 30 28 10 16* 20 12 18 2 6 10 30 28 16 16* 20 12 18 2 6 10 12 28 16 16* 20 30 18 2 6 10 12 16 28 16* 20 30 18 2 6 10 12 16 16* 28 20 30 28 2 6 10 12 16 16* 18 20 30 28 2 6 10 12 16 16* 18 20 28 30 2 6 10 12 16 16* 18 20 28 30(4)快速排序12 12 2 16 30 28 10 16*

21、20 6 18 6 6 2 10 12 28 30 16* 20 16 18 28 2 6 10 12 28 30 16* 20 16 18 18 2 6 10 12 18 16 16* 20 28 30 16* 2 6 10 12 16* 16 18 20 28 30 2 6 10 12 16* 16 18 20 28 30左子序列递归深度为1,右子序列递归深度为3。(5)二路归并排序12 2 16 30 28 10 16* 20 6 18 2 12 16 30 10 28 16 * 20 6 18 2 12 16 30 10 16 * 20 28 6 18 2 10 12 16 16* 2

22、0 28 30 6 18 2 6 10 12 16 16* 18 20 28 30(6)堆排序第一步,形成初始大根堆(详细过程略),第二步做堆排序。1221620103016*28618302816102016*182126初始排序 不是大根堆 形成初始大根堆1228162102016*18630282016101216*182306交换1与10对象 从1到9重新形成堆620162101216*182830201816101216*623028交换1与9对象 从1到8重新形成堆2181620101216*6283018121610216*12203028交换1与8对象 从1到7重新形成堆16*

23、121620102186283016*1216102186203028交换1与7对象 从1到6重新形成堆1012162016*2186283016121016*2186203028交换1与6对象 从1到5重新形成堆612102016*2181628301261016*21816203028交换1与5对象 从1到4重新形成堆126102016*1218162830106216*121816203028交换1与4对象 从1到3重新形成堆26102016*1218162830621016*121816203028交换1与3对象 从1到2重新形成堆26102016*1218162830261016*121816203028交换1与2对象 得到结果母亲通情达理,也鼓励他儿子奋勇杀敌,岳飞参军时,岳飞母亲在他背上刺上了“精忠报国”四个醒目大字,后来,英勇奋战的岳飞建立起了属于自己的部落岳家军,他们不屈不挠,喊着愤慨激昂慷慨的口号奋勇杀5

展开阅读全文
相似文档                                   自信AI助手自信AI助手
猜你喜欢                                   自信AI导航自信AI导航
搜索标签

当前位置:首页 > 考试专区 > 中考

移动网页_全站_页脚广告1

关于我们      便捷服务       自信AI       AI导航        获赠5币

©2010-2024 宁波自信网络信息技术有限公司  版权所有

客服电话:4008-655-100  投诉/维权电话:4009-655-100

gongan.png浙公网安备33021202000488号   

icp.png浙ICP备2021020529号-1  |  浙B2-20240490  

关注我们 :gzh.png    weibo.png    LOFTER.png 

客服