计算机算法分析与设计第八章,西安电子科技大学计算机学院算法分析与设计 Chapter8.pdf...

本文探讨了比较排序算法的下界,强调了其最优情况下的最坏时间复杂度为O(n log n)。随后介绍了非比较排序方法,如计数排序和基数排序,展示了它们在特定场景下的高效性。通过决策树实例,直观地展示了这些算法的工作原理。
摘要由CSDN通过智能技术生成

Design and Analysis of Algorithms

Sorting in linear time

Reference:

CLRS Chapter 8

Topics:

• Lower bound for sorting

• Counting sort

• Radix sort

• Bucket sort

Huo Hongwei 1

How fast can we sort?

• All the sorting algorithms we have seen so far are

comparison sorts: only use comparisons to determine

the relative order of elements.

– E.g., insertion sort, merge sort, quicksort, heapsort.

– The best worst-case running time that we’ve seen for

comparison sorting is O(n lg n).

• Q: Is O(n lg n) the best we can do?

• A : Yes, as long as we use comparison sorts

• TODAY: Prove any comparison sort has Ω(n lg n) worst

case running time

Huo Hongwei 2

Decision-tree example

• Sort 1:2

1 2 n

2:3 1:3

123 1:3 213 2:3

132 312 231 321

• Each internal node is labelled i:j for i,j ∈ {1, 2,…, n}.

– The left subtree shows subsequent comparisons if a ≤

i

a .

j

– The right subtree shows subsequent comparisons if ai

≥ a .

j

Huo Hongwei 3

Decision-tree example

• Sort = <9, 4, 6> 1:2 9 ≥ 4

1 2 3

2:3 1:3

123 1:3

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值