A comprehensive collection of data structures and algorithms implementations in C#. This project serves as a learning resource and reference for common computer science concepts.
DSA/
├── DSA.sln # Solution file
├── README.md # This file
└── DSA_CSharp/ # Main C# project
├── Program.cs # Entry point with example selection
├── CSharp.csproj # Project file
└── [Implementation Files] # Individual algorithm/data structure files
- .NET 9.0 or later
- Visual Studio, VS Code, or JetBrains Rider
- Clone or download this repository
- Open the solution file
DSA.slnin your IDE - Build and run the project
- Uncomment the desired example in
Program.csto see it in action
- Stack (
StackExample.cs) - LIFO (Last In, First Out) data structure - Queue (
QueueExample.cs) - FIFO (First In, First Out) data structure - Priority Queue (
PriorityQueueExample.cs) - Queue with priority-based ordering - Linked List (
LinkedListExample.cs) - Dynamic linear data structure - Array List (
ArrayListExample.cs) - Dynamic array implementation
- Binary Search Tree (
BinarySearchTreeExample.cs) - Self-balancing binary tree - Graph (
Graph.cs) - Graph data structure with adjacency representations- Adjacency Matrix (
AdjacencyMatrixExample.cs) - Matrix-based graph representation - Adjacency List (
AdjacenyListExample.cs) - List-based graph representation
- Adjacency Matrix (
- Hash Tables (
HashTablesExample.cs) - Key-value pair storage with hashing
- Linear Search (
LinearSearchExample.cs) - Sequential search through elements - Binary Search (
BinarySearchExample.cs) - Efficient search in sorted arrays - Interpolation Search (
InterpolationSearchExample.cs) - Improved binary search for uniformly distributed data
- Bubble Sort (
BubbleSortExample.cs) - Simple comparison-based sorting - Selection Sort (
SelectionSortExample.cs) - In-place comparison sorting - Insertion Sort (
InsertionSortExample.cs) - Efficient for small datasets - Merge Sort (
MergeSortExample.cs) - Divide-and-conquer stable sorting - Quick Sort (
QuickSortExample.cs) - Efficient divide-and-conquer sorting
- Depth-First Search (DFS) (
DepthFirstSearchExample.cs) - Graph traversal using stack - Breadth-First Search (BFS) (
BreadthFirstSearchExample.cs) - Graph traversal using queue
- Tree Traversal (
TraverseTreeExample.cs) - In-order, pre-order, and post-order traversals
- Recursion (
RecursionExample.cs) - Recursive algorithm examples
To run a specific algorithm or data structure example:
- Open
Program.cs - Uncomment the desired example line in the
Mainmethod:
static void Main()
{
// Uncomment the example you want to run
new StackExample(); // Stack operations
new BinarySearchExample(); // Binary search demonstration
new MergeSortExample(); // Merge sort algorithm
// ... other examples
}- Build and run the project
This project helps understand:
- Time and Space Complexity - Big O notation analysis
- Data Structure Selection - When to use which data structure
- Algorithm Efficiency - Comparing different algorithmic approaches
- Implementation Details - How these concepts work under the hood
Each implementation includes comments about:
- Time Complexity - How runtime scales with input size
- Space Complexity - Memory usage characteristics
- Best/Average/Worst Case scenarios where applicable
Feel free to contribute by:
- Adding new algorithms or data structures
- Improving existing implementations
- Adding more detailed comments or documentation
- Fixing bugs or optimizing code
- All implementations prioritize clarity and educational value over production optimization
- Each example is self-contained and can be run independently
- The code includes extensive comments explaining the logic and complexity
Happy Learning! 🎓