Class QuickSortCharsSorter
An implementation of ICharsSorter which uses QuickSort to sort the input.
Inheritance
Implements
Inherited Members
Namespace: MoreStructures.Strings.Sorting
Assembly: MoreStructures.dll
Syntax
public class QuickSortCharsSorter : ICharsSorter
Remarks
ADVANTAGES
The algorithm uses the QuickSort implementation of LINQ to sort strings, seen as lists of chars.
Being based on a comparison-based sorting algorithm, unlike the Counting Sort implementation, it doesn't
leverage a linear runtime.
However, its runtime only depends on the size of the input, and it doesn't depend on the size of the alphabet.
Because of that, it is suitable for scenarios of large alphabets, or where there is no upper bound on the
number of distinct chars in the input, other than the size of the alphabet.
For example: when the input string to be sorted is an unconstrained Unicode string.
ALGORITHM
- It uses the LINQ-provided QuickSort, to sort the
- Then, it selects the indexes from the sorted sequence of
COMPLEXITY
- The execution of the QuickSort has a runtime of O(n * log(n)).
- Output is not produced in-place, but a new list of n items is created.
- Therefore, Time Complexity is O(n * log(n)) and Space Complexity is O(n).
Constructors
| Improve this Doc View SourceQuickSortCharsSorter(Nullable<Char>)
Declaration
public QuickSortCharsSorter(char? maybeTerminator)
Parameters
Type | Name | Description |
---|---|---|
System.Nullable<System.Char> | maybeTerminator | The char, if any, to be treated as terminator char when comparing chars of the input.
If not specified, |
Remarks
Methods
| Improve this Doc View SourceSort(String)
Declaration
public IList<int> Sort(string input)
Parameters
Type | Name | Description |
---|---|---|
System.String | input |
Returns
Type | Description |
---|---|
IList<System.Int32> |