100+ algorithms & data structures generically implemented in C#
C#
1,376
1,187 commits
updated Sep 9, 2026
This is a maintained, curiosity-driven personal project that was originally not intended to be a library. Issues and pull requests for bug fixes, new algorithms, and data structures are welcome. Feel free to fork and modify the project to fit your needs.
Various important computer science algorithms generically implemented in C#.
Install by nuget
For beta releases on beta branch
Install-Package Advanced.Algorithms -Pre
For stable releases on stable branch
Install-Package Advanced.Algorithms
Supports
Requires the .NET 10 SDK.
Note: It is observed that among the implementations here, in practice, with the exclusion of UpdateKey (decrement/increment) operation, regular Binary Heap & d-ary Heap outperforms other in theory superiors. Likely because it doesn't have pointer juggling overhead and hey arrays are faster!
TODO: Support multi-dimentional segment tree & binary indexed tree.
TODO: implement trie compression.
Note: On a decent desktop, in given implementations here for +ive random input integers, the clear winner is counting sort (~0.1 seconds to sort 1 million integers) followed by Radix Sort (~0.4 seconds). Merge Sort, Heap Sort, Quick Sort & Bucket Sort are all winners for +ive & -ive random integer inputs. Tree sort has pointer juggling overhead on backing Red-Black Tree, so performs 8 times slower than Merge Sort in practice. Bubble Sort, Insertion Sort, Selection Sort & Shell Sort are among the worst for random input as observed from results.
100+ algorithms & data structures generically implemented in C#
C#
1,376
1,187 commits
updated Sep 9, 2026
This is a maintained, curiosity-driven personal project that was originally not intended to be a library. Issues and pull requests for bug fixes, new algorithms, and data structures are welcome. Feel free to fork and modify the project to fit your needs.
Various important computer science algorithms generically implemented in C#.
Install by nuget
For beta releases on beta branch
Install-Package Advanced.Algorithms -Pre
For stable releases on stable branch
Install-Package Advanced.Algorithms
Supports
Requires the .NET 10 SDK.
Note: It is observed that among the implementations here, in practice, with the exclusion of UpdateKey (decrement/increment) operation, regular Binary Heap & d-ary Heap outperforms other in theory superiors. Likely because it doesn't have pointer juggling overhead and hey arrays are faster!
TODO: Support multi-dimentional segment tree & binary indexed tree.
TODO: implement trie compression.
Note: On a decent desktop, in given implementations here for +ive random input integers, the clear winner is counting sort (~0.1 seconds to sort 1 million integers) followed by Radix Sort (~0.4 seconds). Merge Sort, Heap Sort, Quick Sort & Bucket Sort are all winners for +ive & -ive random integer inputs. Tree sort has pointer juggling overhead on backing Red-Black Tree, so performs 8 times slower than Merge Sort in practice. Bubble Sort, Insertion Sort, Selection Sort & Shell Sort are among the worst for random input as observed from results.