README
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
<p align="center">
<strong>A plug-and-play library of classic data structures and algorithms in C#</strong>
</p>
<p align="center">
<a href="https://github.com/aalhour/C-Sharp-Algorithms/actions"><img src="https://img.shields.io/github/actions/workflow/status/aalhour/C-Sharp-Algorithms/build_and_test.yml?style=for-the-badge&logo=github&label=build" alt="Build Status" /></a>
<a href="https://github.com/aalhour/C-Sharp-Algorithms/releases"><img src="https://img.shields.io/github/v/release/aalhour/C-Sharp-Algorithms?style=for-the-badge&logo=github" alt="Release" /></a>
<a href="LICENSE"><img src="https://img.shields.io/github/license/aalhour/C-Sharp-Algorithms?style=for-the-badge" alt="License" /></a>
<a href="https://github.com/aalhour/C-Sharp-Algorithms/stargazers"><img src="https://img.shields.io/github/stars/aalhour/C-Sharp-Algorithms?style=for-the-badge&logo=github" alt="Stars" /></a>
</p>
<p align="center">
<img src="https://img.shields.io/badge/.NET-10.0-512BD4?style=flat-square&logo=dotnet" alt=".NET 10" />
<img src="https://img.shields.io/badge/tests-623%20passing-brightgreen?style=flat-square" alt="Tests" />
<img src="https://img.shields.io/badge/data%20structures-35+-blue?style=flat-square" alt="Data Structures" />
<img src="https://img.shields.io/badge/algorithms-40+-blue?style=flat-square" alt="Algorithms" />
</p>
---
⚡ Quick Start
Clone the repository
git clone https://github.com/aalhour/C-Sharp-Algorithms.git
cd C-Sharp-AlgorithmsBuild and test
dotnet build
dotnet testRequirements: .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
<details>
<summary><strong>Lists & Collections</strong></summary>
| 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 |
</details>
<details>
<summary><strong>Heaps & Priority Queues</strong></summary>
| 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 |
</details>
<details>
<summary><strong>Hash Tables</strong></summary>
| Structure | Description |
|-----------|-------------|
| ChainedHashTable | Separate chaining collision resolution |
| CuckooHashTable | Cuckoo hashing |
| OpenScatterHashTable | Linear probing |
| OpenAddressingHashTable | Open addressing with double hashing |
Hashing Functions: PrimeHashingFamily ・ UniversalHashingFamily
</details>
<details>
<summary><strong>Trees</strong></summary>
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 |
</details>
<details>
<summary><strong>Graphs</strong></summary>
| Type | Sparse | Dense |
|------|--------|-------|
| Undirected | UndirectedSparseGraph | UndirectedDenseGraph |
| Undirected Weighted | UndirectedWeightedSparseGraph | UndirectedWeightedDenseGraph |
| Directed | DirectedSparseGraph | DirectedDenseGraph |
| Directed Weighted | DirectedWeightedSparseGraph | DirectedWeightedDenseGraph |
Also: CliqueGraph
</details>
<details>
<summary><strong>Sorted Collections</strong></summary>
| Structure | Description |
|-----------|-------------|
| SortedList | Always-sorted list |
| SortedDictionary | Sorted key-value store |
</details>
---
🔧 Algorithms
<details>
<summary><strong>Sorting</strong> (16 algorithms)</summary>
| 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) |
</details>
<details>
<summary><strong>Graph Algorithms</strong></summary>
Traversal
- Depth-First Search
- Breadth-First Search
Shortest Paths
- Dijkstra — Single-source, non-negative weights
- Dijkstra All-Pairs — All pairs shortest paths
- Bellman-Ford — Handles negative weights
- BFS Shortest Paths — Unweighted graphs
Applications
- Cycle Detection
- Topological Sort
- Connected Components
- Bipartite Coloring
</details>
<details>
<summary><strong>Trees, Strings & Numeric</strong></summary>
Tree Traversal
- Recursive Walker — Preorder, Inorder, Postorder
- Iterative Walker — Stack-based traversal
String Algorithms
- Permutations & Anagrams
- Edit Distance (Levenshtein)
Numeric
- Binomial Coefficients
- Catalan Numbers
- Greatest Common Divisor
- Sieve of Eratosthenes
- Sieve of Atkin
Visualization
- Tree Drawer
</details>
<details>
<summary><strong>Searching</strong></summary>
</details>
---
🚀 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.
<a href="https://github.com/aalhour/C-Sharp-Algorithms/graphs/contributors">
<img src="https://contributors-img.firebaseapp.com/image?repo=aalhour/C-Sharp-Algorithms" />
</a>
---
📄 License
This project is licensed under the MIT License.
---