| | 1 | | namespace MoreStructures.Lists.Sorting.QuickSort; |
| | 2 | |
|
| | 3 | | /// <summary> |
| | 4 | | /// A <see cref="IPivotSelectionStrategy"/> always picking the highest index of the window. |
| | 5 | | /// </summary> |
| | 6 | | /// <remarks> |
| | 7 | | /// Time and Space Complexity are O(1). |
| | 8 | | /// <br/> |
| | 9 | | /// Like for <see cref="StartIndexPivotSelectionStrategy"/>, it makes quicksort run in quadratic time on pathological |
| | 10 | | /// input configurations, e.g. when window is already sorted in descending order. |
| | 11 | | /// <br/> |
| | 12 | | /// To avoid phatological scenarios with this <see cref="IPivotSelectionStrategy"/>, setup a |
| | 13 | | /// <see cref="IShuffleStrategy"/> in the <see cref="RecursiveQuickSort"/> instance, different from |
| | 14 | | /// <see cref="IdentityShuffleStrategy"/>. |
| | 15 | | /// </remarks> |
| | 16 | | public class EndIndexPivotSelectionStrategy : IPivotSelectionStrategy |
| | 17 | | { |
| | 18 | | /// <inheritdoc path="//*[not(self::remarks)]"/> |
| | 19 | | /// <remarks> |
| | 20 | | /// This specific implementation always picks the <paramref name="end"/> index. |
| | 21 | | /// </remarks> |
| 601 | 22 | | public int Select<T>(IList<T> list, IComparer<T> comparer, int start, int end) => end; |
| | 23 | | } |