|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.mhhe.clrs2e.DeterministicSelect
Implements the OrderStatistics
interface via the
deterministic Select procedure (which runs in linear time in the
worst case) from pages 189-190 of Introduction to
Algorithms, Second edition.
Field Summary | |
private com.mhhe.clrs2e.Partitioner |
part
For partitioning. |
Constructor Summary | |
DeterministicSelect()
Creates a Partitioner. |
Method Summary | |
private void |
insertionSortSubarray(java.lang.Comparable[] array,
int start,
int size)
Sorts a small subarray. |
java.lang.Comparable |
select(java.lang.Comparable[] array,
int i)
Returns the ith smallest element in an array. |
private java.lang.Comparable |
select(java.lang.Comparable[] array,
int p,
int r,
int i)
Returns the ith smallest element in a subarray array[p..r] . |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
private com.mhhe.clrs2e.Partitioner part
Constructor Detail |
public DeterministicSelect()
Method Detail |
public java.lang.Comparable select(java.lang.Comparable[] array, int i)
select
in interface OrderStatistics
array
- The array.i
- Which order statistic we want.private java.lang.Comparable select(java.lang.Comparable[] array, int p, int r, int i)
array[p..r]
.
array
- The array containing the subarray to be sorted.p
- Index of the beginning of the subarray.r
- Index of the end of the subarray.i
- Which order statistic we want.private void insertionSortSubarray(java.lang.Comparable[] array, int start, int size)
array
- The array containing the subarray to be sorted.start
- Index of the start of the subarray.size
- Number of elements in the subarray.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |