Skip to content

📚 📈 Plug-and-play class-library project of standard Data Structures and Algorithms in C#

License

Notifications You must be signed in to change notification settings

derKosi/C-Sharp-Algorithms

 
 

                                          o---o    |   |                                 
                                         /       --O---O--                               
                                        O          |   |                                 
                                         \       --O---O--                               
                                          o---o    |   |                                 


              O    o       o--o    o--o   o---o   o-O-o  o--O--o  o   o  o     o   o--o 
             / \   |      o       o    o  |   |     |       |     |   |  |\   /|  |     
            o---o  |      |  o-o  |    |  O--Oo     |       |     O---O  | \o/ |   o--o 
            |   |  |      o    |  o    o  |  \      |       |     |   |  |     |      | 
            o   o  O---o   o--o    o--o   o   \o  o-O-o     o     o   o  o     o  o---o 

A plug-and-play library of classic data structures and algorithms in C#

Build Status Release License Stars

.NET 10 Tests Data Structures Algorithms


⚡ Quick Start

# Clone the repository
git clone https://github.com/aalhour/C-Sharp-Algorithms.git
cd C-Sharp-Algorithms

# Build and test
dotnet build
dotnet test

Requirements: .NET 10.0 SDK or later


📖 About

This project started as interview prep and evolved into a comprehensive reference implementation of classic computer science data structures and algorithms. Every component is:

  • Educational — Clear, readable implementations with documentation
  • Tested — 623+ unit tests ensuring correctness
  • Modular — Use only what you need

Project Structure

Project Description
Algorithms Sorting, searching, graph algorithms, and more
DataStructures Lists, trees, heaps, hash tables, graphs
UnitTest Comprehensive test coverage

📦 Data Structures

Lists & Collections
Structure Description
ArrayList Dynamic array with auto-resizing
Stack LIFO collection
Queue FIFO collection
SLinkedList Singly-linked list
DLinkedList Doubly-linked list
SkipList Probabilistic balanced structure
CircularBuffer Fixed-size circular queue
Heaps & Priority Queues
Structure Description
BinaryMinHeap Min-heap using binary tree
BinaryMaxHeap Max-heap using binary tree
BinomialMinHeap Binomial heap (min)
MinPriorityQueue Priority queue (min)
KeyedPriorityQueue Key-value priority queue
Hash Tables
Structure Description
ChainedHashTable Separate chaining collision resolution
CuckooHashTable Cuckoo hashing
OpenScatterHashTable Linear probing
OpenAddressingHashTable Open addressing with double hashing

Hashing Functions: PrimeHashingFamilyUniversalHashingFamily

Trees

Search Trees

Structure Description
BinarySearchTree Classic BST (Map version)
AugmentedBinarySearchTree BST with subtree counts
TernarySearchTree For string keys

Self-Balancing Trees

Structure Description
AVLTree Height-balanced BST
RedBlackTree Color-balanced BST (Map version)
BTree B-tree for disk-based storage

Prefix Trees

Structure Description
Trie Prefix tree for strings
TrieMap Associative prefix tree
Graphs
Type Sparse Dense
Undirected UndirectedSparseGraph UndirectedDenseGraph
Undirected Weighted UndirectedWeightedSparseGraph UndirectedWeightedDenseGraph
Directed DirectedSparseGraph DirectedDenseGraph
Directed Weighted DirectedWeightedSparseGraph DirectedWeightedDenseGraph

Also: CliqueGraph

Sorted Collections
Structure Description
SortedList Always-sorted list
SortedDictionary Sorted key-value store

🔧 Algorithms

Sorting (16 algorithms)
Algorithm Type Complexity
QuickSort Divide & Conquer O(n log n) avg
MergeSort Divide & Conquer O(n log n)
HeapSort Selection O(n log n)
InsertionSort Insertion O(n²)
SelectionSort Selection O(n²)
BubbleSort Exchange O(n²)
ShellSort Insertion O(n log² n)
CombSort Exchange O(n²)
CountingSort Non-comparison O(n + k)
LSD RadixSort Non-comparison O(nk)
BucketSort Distribution O(n + k)
BSTSort Tree-based O(n log n)
CycleSort In-place O(n²)
GnomeSort Exchange O(n²)
OddEvenSort Exchange O(n²)
PigeonHoleSort Distribution O(n + k)
Graph Algorithms

Traversal

Shortest Paths

Applications

Trees, Strings & Numeric

Tree Traversal

String Algorithms

Numeric

Visualization

Searching

🚀 Roadmap

See TODO.md for planned additions. Highlights:

  • Data Structures: Bloom Filters, Fibonacci Heaps, Disjoint Sets, Suffix Trees
  • Algorithms: A* Search, Minimum Spanning Trees, String Matching (KMP, Boyer-Moore)

🤝 Contributing

Contributions welcome! Please read the Contribution Guidelines first.


📄 License

This project is licensed under the MIT License.

About

📚 📈 Plug-and-play class-library project of standard Data Structures and Algorithms in C#

Resources

License

Code of conduct

Contributing

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C# 100.0%