Algorithms.NET
Open source library containing the most used sorting and searching algorithms.
In this library you can find the most used sorting & searching algorithms and that are must know for developers, and their implementation, these algorithms are as follows:
Sorting:
- Bubble Sort
- Insertion Sort
- Selection Sort
- Bucket Sort
- Merge Sort
- Quick Sort
- Counting Sort
Searching:
- Binary Search
- Ternary Search
- Jump Search
- Linear Search
- Exponential Search
You can play with these algorithms in Algorithms.NET.Debug
To view and compare performance of each algorithm, manipulate the code inside :
SearchingBenchmark.cs
& SortingBenchmark.cs
To run the benchmarks, comment out :
var searchingBenchmarkSummary = BenchmarkRunner.Run<SearchingBenchmark>();
or
var sortingBenchmarkSummary = BenchmarkRunner.Run<SortingBenchmark>();
Then run the project in Release Mode
Benchmark
Sorting algorithms comparison:
Note : BuiltIn Sorting algorithm uses an unstable version of QuickSort, and after .NET 4.5 it now uses Insertion sort for n<16, otherwise it starts with Quicksort and switches to Heapsort when the number of partitions (recursion depth?) exceeds 2 * Log^N. Called: Introsort, and that explains why it is the fastest.
Searching algorithms comparison:
Here is the explanation of each algorithm:
Sorting:
Searching: