南京大学:《计算机问题求解》课程教学资源(课件讲稿)排序与选择

计算机问题求解一论题2-10 排序与选择 2016年4月21日
计算机问题求解 – 论题2-10 - 排序与选择 2016年4月21日

问题1: 你能否利用下图解释快速排 序的基本思想? [splitPoint]:pivot [first灲 [last灯 0000O000000000 for any element in for any element in this Small large this segment,the key segment,the key is not is less than pivot. To be sorted recursively less than pivot
[first] [last] for any element in this segment, the key is less than pivot. for any element in this segment, the key is not less than pivot

QUICKSORT(A,p,r) 1 ifp<r 3 g PARTITION(A,p,r) 3 QUICKSORT(A,p,q-1) 4 QUICKSORT(A,q 1,r) To sort an entire array A,the initial call is QUICKSORT(A,1,A.length) 问题2: 都是用divide-and conquer策略,这与 Mergesort有什么不同?

关键是Partition Partition过程的核心是一个循环,执行rp次。 在第飞+1次循环开始前,格局如下: k ≤x >x unrestricted 问题3: 你能否借助此图,解释利用循环不变 式如何证明这个过程的正确性?
关键是Partition Partition过程的核心是一个循环,执行r-p次。 在第k+1次循环开始前,格局如下: k

QUICKSORT(A,p,r) 1 ifp<r 2 g PARTITION(A,p,r) 3 QUICKSORT(A,p,q-1) 4 QUICKSORT(A,q+1,r) To sort an entire array A,the initial call is QUICKSORT(A,1,A.length) 问题4: 这个递归算法的时间性能递归式是什么?

和体科用银可料 C刀 品n cn logion 品n 品n 银E接装料 cn 10g10/9n 品 n C刀 4aal≤C7 间题5: ≤C刀 什么是递归树,你能香借助 O(nlgn) 这个图解释影响Quicksort 效率的因素?

In fact,any split of constn proportionality yieldson te of depthhere the costateach lvel is O(m).The running time is therefore O(ng)whenever the split has constant roportionaty. 问题⑥; 你看了这句话有什么想法?

问题7: 为什台么直观上也会觉得快速排 序的平均效率更接近最好情况, 而不是最坏情况? 直觉对于探索很重要。 “大胆假设,小心求证!
直觉对于探索很重要。 “大胆假设,小心求证!

Worst-Case Performance of Quicksort T(m)=.max,(T(q)+T(-q-1)+Θ(m) 0sgs≤n-1 g是Partition的返回值。 问题8: 你能说说解这个递 归的策略吗? Guess and verifying
Worst-Case Performance of Quicksort q是Partition的返回值。 Guess and verifying

随机快速排序的期望代价 快速排序的主要代价其实就是Partition的代价。 ■Partition的代价主要是循环中的比较操作。 Lemma 7.1 Let X be the number of comparisons performed in line 4 of PARTITION over the entire execution of QUICKSORT on an n-element array.Then the running time of QUICKSORT is O(n+X). Proof By the discussion above,the algorithm makes at most n calls to PARTI- TION,each of which does a constant amount of work and then executes the for loop some number of times.Each iteration of the for loop executes line 4
随机快速排序的期望代价 快速排序的主要代价其实就是Partition的代价。 Partition的代价主要是循环中的比较操作
按次数下载不扣除下载券;
注册用户24小时内重复下载只扣除一次;
顺序:VIP每日次数-->可用次数-->下载券;
- 南京大学:《计算机问题求解》课程教学资源(课件讲稿)常用的证明方法及其逻辑正确性.pdf
- 南京大学:《计算机问题求解》课程教学资源(课件讲稿)布尔代数.pdf
- 南京大学:《计算机问题求解》课程教学资源(课件讲稿)如何将算法告诉计算机.pdf
- 南京大学:《计算机问题求解》课程教学资源(课件讲稿)堆与堆排序.pdf
- 南京大学:《计算机问题求解》课程教学资源(课件讲稿)基本数据结构.pdf
- 南京大学:《计算机问题求解》课程教学资源(课件讲稿)分治法与递归.pdf
- 南京大学:《计算机问题求解》课程教学资源(课件讲稿)函数.pdf
- 南京大学:《计算机问题求解》课程教学资源(课件讲稿)关系及其基本性质.pdf
- 南京大学:《计算机问题求解》课程教学资源(课件讲稿)什么样的推理是正确的.pdf
- 南京大学:《计算机问题求解》课程教学资源(课件讲稿)为什么计算机能解题.pdf
- 南京大学:《计算机问题求解》课程教学资源(课件讲稿)不同的程序设计方法.pdf
- 南京大学:《计算机问题求解》课程教学资源(课件讲稿)Hashing方法.pdf
- Go To Statement Considered Harmful.pdf
- What is System Hang and How to Handle it?.pdf
- How Far We Have Progressed in the Journey? An Examination of Cross-Project Defect Prediction.pdf
- 南京大学:《计算机问题求解》课程教学资源(课件讲稿)关于问题求解的几个思考.pdf
- 南京大学:《计算机问题求解》课程教学资源(课件讲稿)随机算法的概念.pdf
- 南京大学:《计算机问题求解》课程教学资源(课件讲稿)群与拉格郎日定理.pdf
- 南京大学:《计算机问题求解》课程教学资源(课件讲稿)线性规划.pdf
- 南京大学:《计算机问题求解》课程教学资源(课件讲稿)矩阵计算.pdf
- 南京大学:《计算机问题求解》课程教学资源(课件讲稿)数据与数据结构.pdf
- 南京大学:《计算机问题求解》课程教学资源(课件讲稿)有限与无限.pdf
- 南京大学:《计算机问题求解》课程教学资源(课件讲稿)树及搜索树.pdf
- 南京大学:《计算机问题求解》课程教学资源(课件讲稿)概率分析与随机算法.pdf
- 南京大学:《计算机问题求解》课程教学资源(课件讲稿)离散概率基础.pdf
- 南京大学:《计算机问题求解》课程教学资源(课件讲稿)算法方法.pdf
- 南京大学:《计算机问题求解》课程教学资源(课件讲稿)算法正确性.pdf
- 南京大学:《计算机问题求解》课程教学资源(课件讲稿)算法的基本结构.pdf
- 南京大学:《计算机问题求解》课程教学资源(课件讲稿)算法的效率.pdf
- 南京大学:《计算机问题求解》课程教学资源(课件讲稿)组合与计数.pdf
- 南京大学:《计算机问题求解》课程教学资源(课件讲稿)计算思维引导.pdf
- 南京大学:《计算机问题求解》课程教学资源(课件讲稿)递归及其数学基础.pdf
- 南京大学:《计算机问题求解》课程教学资源(课件讲稿)集合及其运算.pdf
- 南京大学:《计算机问题求解》课程教学资源(课件讲稿)动态规划.pdf
- 南京大学:《计算机问题求解》课程教学资源(课件讲稿)贪心算法.pdf
- 南京大学:《计算机问题求解》课程教学资源(课件讲稿)用于动态等价关系的数据结构.pdf
- 南京大学:《计算机问题求解》课程教学资源(课件讲稿)B树.pdf
- 南京大学:《计算机问题求解》课程教学资源(课件讲稿)图的基本概念.pdf
- 南京大学:《计算机问题求解》课程教学资源(课件讲稿)图的计算机表示以及遍历.pdf
- 南京大学:《计算机问题求解》课程教学资源(课件讲稿)树.pdf