Table of Contents

Class StringSort

Namespace
AlgorithmsSW.String
Assembly
AlgorithmsSW.dll

A class that provides string sorting algorithms.

public static class StringSort
Inheritance
StringSort
Inherited Members

Methods

Accumulate<T>(IReadonlyRandomAccessList<T>)

Accumulates the counts of the sorted items.

public static IRandomAccessList<T> Accumulate<T>(IReadonlyRandomAccessList<T> sortedCounts) where T : INumber<T>

Parameters

sortedCounts IReadonlyRandomAccessList<T>

The counts of the sorted items.

Returns

IRandomAccessList<T>

An array of the accumulated counts of the sorted items.

Type Parameters

T

The type of the items being sorted.

Accumulate<T>(T[])

public static T[] Accumulate<T>(T[] sortedCounts) where T : INumber<T>

Parameters

sortedCounts T[]

Returns

T[]

Type Parameters

T

CountOccurrences<T>(IEnumerable<T>, IComparer<T>)

Counts the occurrences of each unique string in a given collection.

public static Counter<T> CountOccurrences<T>(this IEnumerable<T> list, IComparer<T> comparer)

Parameters

list IEnumerable<T>

The collection of strings to count.

comparer IComparer<T>

The comparer to use for comparing the strings.

Returns

Counter<T>

A Counter<T> object where each unique item is associated with its count.

Type Parameters

T

The type of the items in the collection.

CountSortWithQueues<T>(IRandomAccessList<T>, IComparer<T>)

[ExerciseReference(5, 1, 7)]
public static void CountSortWithQueues<T>(IRandomAccessList<T> list, IComparer<T> comparer)

Parameters

list IRandomAccessList<T>
comparer IComparer<T>

Type Parameters

T

CountSort<T>(IRandomAccessList<T>, IComparer<T>)

[ExerciseReference(5, 1, 1)]
public static void CountSort<T>(IRandomAccessList<T> list, IComparer<T> comparer)

Parameters

list IRandomAccessList<T>
comparer IComparer<T>

Type Parameters

T

LeastSignificantDigitSort(IRandomAccessList<string>, int, Alphabet)

Sorts an array of strings using the Least Significant Digit (LSD) radix sort algorithm, considering only a specified number of leading characters in each string.

[AlgorithmReference(5, 1)]
[ExerciseReference(5, 1, 12)]
public static void LeastSignificantDigitSort(IRandomAccessList<string> list, int leadingCharsToSort, Alphabet alphabet)

Parameters

list IRandomAccessList<string>

The array of strings to be sorted. This algorithm assumes all the strings are of length at least leadingCharsToSort.

leadingCharsToSort int

The number of leading characters to consider during sorting.

alphabet Alphabet

The alphabet used in the strings.

Remarks

This algorithm assumes that the integer values are smaller than the radix. This can be used indirectly to sort strings of any Alphabet provided they are converted to and from integer arrays.

LeastSignificantDigitSort(IRandomAccessList<string>, int, int)

Sorts an array of strings using the Least Significant Digit (LSD) radix sort algorithm, considering only a specified number of leading characters in each string.

[AlgorithmReference(5, 1)]
public static void LeastSignificantDigitSort(IRandomAccessList<string> list, int leadingCharsToSort, int radix)

Parameters

list IRandomAccessList<string>

The array of strings to be sorted. This algorithm assumes all the strings are of length at least leadingCharsToSort.

leadingCharsToSort int

The number of leading characters to consider during sorting.

radix int

The radix of the alphabet used to present the strings.

Remarks

This algorithm assumes that the character integer value is smaller than the radix. So for example, this implementation cannot be used to sort binary strings made from 0s and 1s.

LeastSignificantDigitSort(int[][], int, int)

Sorts an array of strings using the Least Significant Digit (LSD) radix sort algorithm, considering only a specified number of leading characters in each string.

[AlgorithmReference(5, 1)]
public static void LeastSignificantDigitSort(int[][] list, int leadingCharsToSort, int radix)

Parameters

list int[][]

The array of strings to be sorted. This algorithm assumes all the strings are of length at least leadingCharsToSort.

leadingCharsToSort int

The number of leading characters to consider during sorting.

radix int

The radix of the alphabet used to present the strings.

Remarks

This algorithm assumes that the integer values are smaller than the radix. This can be used indirectly to sort strings of any Alphabet provided they are converted to and from integer arrays.

MostSignificantDigitSort(IRandomAccessList<string>)

Sorts an array of strings using the Most Significant Digit (MSD) radix sort algorithm.

[AlgorithmReference(5, 2)]
public static void MostSignificantDigitSort(IRandomAccessList<string> list)

Parameters

list IRandomAccessList<string>

The array of strings to be sorted.

Quicksort3Way(IRandomAccessList<int[]>)

[ExerciseReference(5, 1, 14)]
public static void Quicksort3Way(IRandomAccessList<int[]> list)

Parameters

list IRandomAccessList<int[]>

Quicksort3Way(IRandomAccessList<string>)

Sorts an array of strings using three-way quicksort.

public static void Quicksort3Way(IRandomAccessList<string> list)

Parameters

list IRandomAccessList<string>

The list of strings to be sorted.

Radix2Insertion(IRandomAccessList<int>, int)

[ExerciseReference(5, 1, 15)]
public static void Radix2Insertion(IRandomAccessList<int> list, int leadingCharsToSort = 16)

Parameters

list IRandomAccessList<int>
leadingCharsToSort int

Radix4Insertion(IRandomAccessList<int>, int)

[ExerciseReference(5, 1, 15)]
public static void Radix4Insertion(IRandomAccessList<int> list, int leadingCharsToSort = 16)

Parameters

list IRandomAccessList<int>
leadingCharsToSort int

RadixSort(IRandomAccessList<int>, int)

public static void RadixSort(IRandomAccessList<int> list, int maxElement)

Parameters

list IRandomAccessList<int>
maxElement int

RadixSort2(IRandomAccessList<int>, int)

public static void RadixSort2(IRandomAccessList<int> list, int maxElement)

Parameters

list IRandomAccessList<int>
maxElement int