Introduction_to_Algorithms_7
2017-03-17 20:39
162 查看
第七章 快速排序
伪代码:
PARTITION(A, p, r) 1 x = A[r] 2 i = p - 1 3 for j = p to r - 1 4 if A[j] <= x 5 i = i+1 6 exchange A[i] with A[j] 7 exchange A[i+1] with A[r] 8 return i+1 QUICKSORT(A, p, r) 1 if p < r 2 q = PARTITION(A, p, r) 3 QUICKSORT(A, p, q - 1) 4 QUICKSORT(A, q+1, r) p i j r 2 1 3|8 7|5 6|4 2,1,3是小于等于key的部分 8,7是大于key的部分 5,6是尚未处理的部分 4是key
c语言实现
代码详见: github相关文章推荐
- 5. Probabilistic Analysis and Randomized Algorithms——Introduction to Algorithms Third Edition
- introduction to algorithms 菜鸟笔记 sort algorithms
- Ex 9.3-8 of Introduction to algorithms
- Ex 10.4-3 of introduction to algorithms
- Solution for exercise 1.3-7 in Introduction to Algorithms
- introduction to algorithms 菜鸟笔记 binfindtree
- MIT Introduction to Algorithms 学习笔记(五)
- Introduction to Algorithms, Second Edition _ONE (Adding)
- Ex 9.3-8 of Introduction to algorithms
- 算法导论题解(我的答案,欢迎指正) introduction to algorithms
- introduction to algorithms sorting lesson_4 quick sorting
- introduction to algorithms data structure lesson_1 stack
- Introduction_to_Algorithms_Appendix_C
- Introduction_to_Algorithms_chap2
- introduction to algorithms 菜鸟笔记 rbtree(红黑树)
- An Introduction to Bioinformatics Algorithms - III - Chapter5 Greedy Algorithm
- Ex5.1-3 of Introduction to Algorithms
- Introduction to Algorithms:exercise2.1_4
- Introduction to Algorithms
- MIT 6.046J / 18.410J 2001秋季课程:算法导论(Introduction to Algorithms, Fall 2001)第一课