Class MiddleIndexPivotSelectionStrategy
A IPivotSelectionStrategy always picking the index of the window in the middle.
Inheritance
Implements
Inherited Members
Namespace: MoreStructures.Lists.Sorting.QuickSort
Assembly: MoreStructures.dll
Syntax
public class MiddleIndexPivotSelectionStrategy : IPivotSelectionStrategy
Remarks
Time and Space Complexity are O(1).
Like for StartIndexPivotSelectionStrategy and EndIndexPivotSelectionStrategy, it makes
quicksort run in quadratic time on pathological input configurations.
However, unlike StartIndexPivotSelectionStrategy and EndIndexPivotSelectionStrategy,
the pathological scenarios are much more unlikely to happen in the wild, and usually have to be manually crafted.
To further reduce the possibility of phatological scenarios, and make sure that the resulting quicksort doesn't
behave consistently bad on the same input, setup a IShuffleStrategy in the
RecursiveQuickSort instance, different from IdentityShuffleStrategy.
Methods
| Improve this Doc View SourceSelect<T>(IList<T>, IComparer<T>, Int32, Int32)
Declaration
public int Select<T>(IList<T> list, IComparer<T> comparer, int start, int end)
Parameters
Type | Name | Description |
---|---|---|
IList<T> | list | |
IComparer<T> | comparer | |
System.Int32 | start | |
System.Int32 | end |
Returns
Type | Description |
---|---|
System.Int32 |
Type Parameters
Name | Description |
---|---|
T |
Remarks
This specific implementation always picks the end
index.