Back to C Sharp Algorithms

README

README.md

2.0.111.2 KB
Original Source

                                          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"></a> <a href="https://github.com/aalhour/C-Sharp-Algorithms/releases"></a> <a href="LICENSE"></a> <a href="https://github.com/aalhour/C-Sharp-Algorithms/stargazers"></a> </p> <p align="center"> </p>

⚡ Quick Start

bash
# 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

ProjectDescription
AlgorithmsSorting, searching, graph algorithms, and more
DataStructuresLists, trees, heaps, hash tables, graphs
UnitTestComprehensive test coverage

📦 Data Structures

<details> <summary><strong>Lists & Collections</strong></summary>
StructureDescription
ArrayListDynamic array with auto-resizing
StackLIFO collection
QueueFIFO collection
SLinkedListSingly-linked list
DLinkedListDoubly-linked list
SkipListProbabilistic balanced structure
CircularBufferFixed-size circular queue
</details> <details> <summary><strong>Heaps & Priority Queues</strong></summary>
StructureDescription
BinaryMinHeapMin-heap using binary tree
BinaryMaxHeapMax-heap using binary tree
BinomialMinHeapBinomial heap (min)
MinPriorityQueuePriority queue (min)
KeyedPriorityQueueKey-value priority queue
</details> <details> <summary><strong>Hash Tables</strong></summary>
StructureDescription
ChainedHashTableSeparate chaining collision resolution
CuckooHashTableCuckoo hashing
OpenScatterHashTableLinear probing
OpenAddressingHashTableOpen addressing with double hashing

Hashing Functions: PrimeHashingFamilyUniversalHashingFamily

</details> <details> <summary><strong>Trees</strong></summary>

Search Trees

StructureDescription
BinarySearchTreeClassic BST (Map version)
AugmentedBinarySearchTreeBST with subtree counts
TernarySearchTreeFor string keys

Self-Balancing Trees

StructureDescription
AVLTreeHeight-balanced BST
RedBlackTreeColor-balanced BST (Map version)
BTreeB-tree for disk-based storage

Prefix Trees

StructureDescription
TriePrefix tree for strings
TrieMapAssociative prefix tree
</details> <details> <summary><strong>Graphs</strong></summary>
TypeSparseDense
UndirectedUndirectedSparseGraphUndirectedDenseGraph
Undirected WeightedUndirectedWeightedSparseGraphUndirectedWeightedDenseGraph
DirectedDirectedSparseGraphDirectedDenseGraph
Directed WeightedDirectedWeightedSparseGraphDirectedWeightedDenseGraph

Also: CliqueGraph

</details> <details> <summary><strong>Sorted Collections</strong></summary>
StructureDescription
SortedListAlways-sorted list
SortedDictionarySorted key-value store
</details>

🔧 Algorithms

<details> <summary><strong>Sorting</strong> (16 algorithms)</summary>
AlgorithmTypeComplexity
QuickSortDivide & ConquerO(n log n) avg
MergeSortDivide & ConquerO(n log n)
HeapSortSelectionO(n log n)
InsertionSortInsertionO(n²)
SelectionSortSelectionO(n²)
BubbleSortExchangeO(n²)
ShellSortInsertionO(n log² n)
CombSortExchangeO(n²)
CountingSortNon-comparisonO(n + k)
LSD RadixSortNon-comparisonO(nk)
BucketSortDistributionO(n + k)
BSTSortTree-basedO(n log n)
CycleSortIn-placeO(n²)
GnomeSortExchangeO(n²)
OddEvenSortExchangeO(n²)
PigeonHoleSortDistributionO(n + k)
</details> <details> <summary><strong>Graph Algorithms</strong></summary>

Traversal

Shortest Paths

Applications

</details> <details> <summary><strong>Trees, Strings & Numeric</strong></summary>

Tree Traversal

String Algorithms

Numeric

Visualization

</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"> </a>

📄 License

This project is licensed under the MIT License.