Sorting Algorithms in C#: Comparison and Implementations
The common sorting algorithms side by side, with time and space complexity, stability, when each one makes sense, and links to C# implementations.
The common sorting algorithms side by side, with time and space complexity, stability, when each one makes sense, and links to C# implementations.
A merge sort implementation in modern C# that sorts any comparable type, keeps equal elements in order and allocates its buffer only once.
A quick sort implementation in modern C# that works on any comparable type, avoids the classic worst case on sorted input, and keeps stack depth under control.
A stable counting sort in modern C# that handles negative numbers, explains the O(n + k) trade-off and guards against ranges too large to count.
Bubble sort in modern C# for any comparable type, with the early-exit check that makes sorted input O(n), plus an honest look at when to use it.