Lecture 4 Quick Sort and Randomized Quick Sort

Quick Sort

--Divide and Conquer

--Sorts “in place”

--Very practical with tuning


Divide and Conquer:

1.Divide: Partition array into 2 sub-arrays around pivot x such that elements in lower sub-array <= x <= elements in upper sub-array;

2.Conquer: Recursively sort 2 sub-arrays;

3.Combine: Trivial.





Randomized Quick sort:

--running time is independent of input ordering.

--no assumption about input distribution.

--no specific input elicit the worst-case behavior.

--the worst case determined only by random number generator.





發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章