Sorting algorithms/Quicksort: Difference between revisions

m
Removed dependency on C# 9 init methods from properties.
m (Guarded against Arithmetic Overflow.)
m (Removed dependency on C# 9 init methods from properties.)
Line 1,776:
 
=={{header|C sharp|C#}}==
Note that Array.Sort and ArrayList.Sort both use an unstable implementation of the quicksort algorithm.
<lang csharp>//
// The Tripartite conditional enables Bentley-McIlroy 3-way Partitioning.
Line 1,795 ⟶ 1,794:
 
#region Properties
public Int32 InsertionLimit { get; init; }
private T[] Samples { get; init; }
private Int32 Left { get; set; }
private Int32 Right { get; set; }
Line 1,857 ⟶ 1,856:
 
/// <summary>Estimate the median value of entries[Left:Right]</summary>
/// <remarks>TheA sample median is used as an estimate the true median.</remarks>
private T pivot(T[] entries) {
var length = Right + 1 - Left;
Line 1,869 ⟶ 1,868:
 
InsertionSort<T>.Sort(Samples, 0, samples - 1);
var middle =return Samples[samples / 2];
return Samples[middle];
}
 
159

edits