DOI QR코드

DOI QR Code

Quicksort Using Range Pivot

범위 피벗 퀵정렬

  • Lee, Sang-Un (Dept. of Multimedia Science, Gangneung-Wonju National University)
  • 이상운 (강릉원주대학교 멀티미디어공학과)
  • Received : 2012.01.04
  • Accepted : 2012.02.15
  • Published : 2012.04.30

Abstract

Generally, Quicksort selects the pivot from leftmost, rightmost, middle, or random location in the array. This paper suggests Quicksort using middle range pivot $P_0$ and continually divides into 2. This method searches the minimum value $L$ and maximum value $H$ in the length n of list $A$. Then compute the initial pivot key $P_0=(H+L)/2$ and swaps $a[i]{\geq}P_0$,$a[j]<P_0$ until $i$=$j$ or $i$>$j$. After the swap, the length of list $A_0$ separates in two lists $a[1]{\leq}A_1{\leq}a[j]$ and $a[i]{\leq}A_2{\leq}a[n]$ and the pivot values are selected by $P_1=P_0/2$, $P_2=P_0+P_1$. This process repeated until the length of partial list is two. At the length of list is two and $a$[1]>$a$[2], swaps as $a[1]{\leftrightarrow}a[2]$. This method is simpler pivot key process than Quicksort and improved the worst-case computational complexity $O(n^2)$ to $O(n{\log}n)$.

퀵정렬은 피벗값을 최좌측, 최우측, 중간 값 또는 랜덤하게 결정하는 방법을 적용하고 있다. 본 논문은 범위 중간값을 $P_0$피벗값으로 결정하고 계속적으로 양분하는 퀵정렬 방법을 제안하였다. 제안된 방법은 길이가 $n$인 리스트 $A$$i$=1, $j$=$n$에서 최소값 $L$과 최대값 $H$를 탐색하여 초기 피벗 키 값으로 $P_0=(H+L)/2$로 설정하고 $i$=$j$ 또는 $i$>$j$가 될 때까지 $a[i]{\geq}P_0$, $a[j]<P_0$를 교환하는 방식을 적용하였다. 피벗값에 따라 값의 교환이 완료되면 리스트 $A_0$는2개의 부분리스트 $a[1]{\leq}A_1{\leq}a[j]$$a[i]{\leq}A_2{\leq}a[n]$으로 분할되며 이 경우 피벗 키는 $P_1=P_0/2$, $P_2=P_0+P_1$으로 설정된다. 이러한 과정을 분할된 리스트의 길이가2일 때까지 수행되며, 리스트 길이가 2이고, $a$[1]>$a$[2]이면 $a[1]{\leftrightarrow}a[2]$로 교환한다. 제안된 방법은 퀵정렬에 비해 빠르며, 최악의 경우 수행 복잡도 $O(n^2)$$O(n{\log}n)$으로 향상시켰다.

Keywords

References

  1. T. H. Cormen, C. E. Leiserson, R. L. Rivest, and C. Stein, "Introduction to Algorithms, Chapter 7. Quicksort", 2nd Ed., pp. 145-164, MIT Press, 2005.
  2. D. B. Ring, "A Comparison of Sorting Algorithms", http://www.devx.com/vb2themax/Article/19900, 2003.
  3. S. Nilson, "The Fastest Sorting Algorithm?", http://drdobs.com/architecture-and-design/184404062, Dr. Dobb's Journal, Vol. 311, pp. 38-45, 2000.
  4. R. Sedgewick, "Algorithms in C, Parts 1-4: Fundamentals, Data Structures, Sorting, Searching", 3rd Ed., Addison-Wesley, 1998.
  5. Wikipedia, "Quicksort," http://en.wikipedia.org/ wiki/ Quicksort, 2011.

Cited by

  1. 3-점 평균 피벗 퀵정렬 vol.14, pp.6, 2012, https://doi.org/10.7236/jiibc.2014.14.6.295