- find the k-th smallest key in a list
** quickselect(index j)
http://m.blog.naver.com/babobigi/220527978173
- modification of quicksort
- θ(n) average-case time complexity
1. start with an unsorted list I of n input items
2. choose a pivot item v from I
3.
Partition I into unsorted lists
I1, I2 and Iv like quicksort
4. If (j<=|I1|){
Recursively find the item with index j in I1;
Return it;
}else if(j<=|I1|+|Iv|){
Return the pivot v;
}else{
Recursively find the item with index j-|I1|-|Iv| in I2;
Return it;
}
'프로그래밍 > 자료구조' 카테고리의 다른 글
MST (0) | 2016.12.18 |
---|---|
graph (0) | 2016.12.18 |
sorting (0) | 2016.12.18 |
Bionomial heap (0) | 2016.12.18 |
splay tree (0) | 2016.12.17 |