A complete learning resource featuring implementations, theory, and practical examples of essential data structures and algorithms.
Get Started β’ Documentation β’ Topics β’ Contribute
This repository is a comprehensive educational resource for learning and implementing Data Structures and Algorithms using C#. Whether you're a beginner or an experienced developer preparing for technical interviews, you'll find well-documented, production-ready implementations with detailed explanations.
- β Well-documented code with comments and explanations
- β Theory and practice combined for deeper understanding
- β Multiple data structures implementations
- β Algorithm implementations with complexity analysis
- β Real-world examples and use cases
- β Time & Space Complexity analysis for each topic
- β Production-ready code following industry standards
Data Structures are specialized formats for organizing, managing, and storing data in a way that enables efficient access and modification.
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β DATA STRUCTURES β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β β
β ββββββββββββββββββββββββ ββββββββββββββββββββββββ β
β β PRIMITIVE β β ABSTRACT β β
β β β β β β
β β β’ int β β β’ Array β β
β β β’ float β β β’ Linked List β β
β β β’ char β β β’ Stack β β
β β β’ bool β β β’ Queue β β
β β β’ double β β β’ Tree β β
β β β β β’ Graph β β
β β (Single value) β β β’ Hash Table β β
β ββββββββββββββββββββββββ ββββββββββββββββββββββββ β
β β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Algorithms are step-by-step procedures or formulas for solving a problem or completing a task, often involving searching and manipulating data structures.
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β ALGORITHM CATEGORIES β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β β
β β’ Sorting (Bubble, Quick, Merge, Heap, etc.) β
β β’ Searching (Binary Search, Linear Search) β
β β’ Graph Algorithms (DFS, BFS, Dijkstra) β
β β’ Dynamic Programming β
β β’ Greedy Algorithms β
β β’ Divide & Conquer β
β β’ Backtracking β
β β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
| Term | Description |
|---|---|
| Algorithm | A set of step-by-step instructions to solve a specific problem |
| Data Structure | A way of organizing data so it can be used efficiently |
| Time Complexity | Measure of the amount of time an algorithm takes to run |
| Space Complexity | Measure of the amount of memory an algorithm uses |
| Big O Notation | Mathematical notation describing algorithm performance (O(1), O(n), O(nΒ²), etc.) |
| Recursion | A technique where a function calls itself |
| Divide and Conquer | Breaking complex problems into smaller sub-problems |
| Brute Force | Trying all possible solutions to find the best one |
| Optimization | Improving algorithm efficiency in time or space |
ARRAY
βββββββββββ¬ββββββββββ¬ββββββββββ¬ββββββββββ
β [0] β [1] β [2] β [3] β
βββββββββββ΄ββββββββββ΄ββββββββββ΄ββββββββββ
LINKED LIST
βββββββββββ¬βββ βββββββββββ¬βββ βββββββββββ¬ββββββ
β Data ββββΌββββββ Data ββββΌββββββ Data β NULLβ
βββββββββββ΄βββ βββββββββββ΄βββ βββββββββββ΄ββββββ
STACK (LIFO - Last In First Out)
βββββββββββ
β TOP [3] β
βββββββββββ€
β [2] β
βββββββββββ€
β [1] β
βββββββββββ€
β [0] β
βββββββββββ
QUEUE (FIFO - First In First Out)
FRONT [1] β [2] β [3] β [4] REAR
BINARY TREE
βββββββββββ
β 1 β
ββββββ¬βββββ
β
ββββββ΄βββββ
β β
βββββ΄ββββ βββββ΄ββββ
β 2 β β 3 β
βββ¬ββββ¬ββ βββββββ
β β
ββββ ββββ
β β
βββ΄ββ βββ΄ββ
β 4 β β 5 β
βββββ βββββ
BINARY SEARCH TREE (BST)
βββββββββββ
β 10 β
ββββββ¬βββββ
β
ββββββ΄βββββ
β β
βββββ΄ββββ βββββ΄βββββ
β 5 β β 15 β
ββββββββ ββββββ¬βββββ
β
βββββββ΄ββββββ
β β
βββββ΄ββββ βββββ΄ββββ
β 12 β β 20 β
βββββββββ βββββββββ
HASH TABLE (Hash Map)
ββββββββββββββββββββββββββββββββ
β Hash Table with Buckets β
ββββββββββββββββββββββββββββββββ€
β [0] β [bucket] β
β [1] β [bucket] β [bucket] β
β [2] β [bucket] β
β [3] β NULL β
β [4] β [bucket] β
β ... β ... β
ββββββββββββββββββββββββββββββββ
UNDIRECTED GRAPH
(A) βββ (B)
β \ / β
β \ / β
β (C) β
β / \ β
β / \ β
(D) βββ (E)
DIRECTED GRAPH (DAG)
(A) βββ (B) βββ (C)
β β β
β βββββββββ
ββββββββββββββββ(D)
- Arrays and Lists
- Strings
- Stacks and Queues
- Basic Sorting Algorithms
- Basic Searching Algorithms
- Linked Lists
- Trees and Binary Search Trees
- Heaps and Priority Queues
- Hash Tables
- Advanced Sorting (Merge Sort, Quick Sort)
- Graphs and Graph Traversal
- Dynamic Programming
- Greedy Algorithms
- Backtracking
- NP Problems and Approximation
| Complexity | Name | Example |
|---|---|---|
| O(1) | Constant | Array access by index |
| O(log n) | Logarithmic | Binary search |
| O(n) | Linear | Simple loop |
| O(n log n) | Linearithmic | Merge sort, Quick sort |
| O(nΒ²) | Quadratic | Bubble sort, Selection sort |
| O(nΒ³) | Cubic | Triple nested loop |
| O(2βΏ) | Exponential | Fibonacci (naive) |
| O(n!) | Factorial | Permutations |
Operations
β
O(n!)β β±
β β±
O(2βΏ)β β±
β β±
O(nΒ³)ββ±
ββ±
O(nΒ²)βββββββ
β\
O(n log n)β \
β \
O(n)β \
β \
O(log n)β \
β \
O(1)βββββββββ\ββββββββ
β
ββββββββββββββββββββ n (Input Size)
- .NET SDK (version 6.0 or higher)
- C# knowledge (basics)
- Any IDE (Visual Studio, Visual Studio Code, or Rider)
# Clone the repository
git clone https://github.com/ZainulabdeenOfficial/Data-Structures-and-Algorithms-C-Sharp-.git
# Navigate to the project
cd Data-Structures-and-Algorithms-C-Sharp-
# Build the project
dotnet build
# Run examples
dotnet runData-Structures-and-Algorithms-C-Sharp-/
β
βββ README.md # Main documentation (you are here)
βββ Theory.md # Detailed theory explanations
βββ LICENSE # GPL 3.0 License
β
βββ DataStructures/
β βββ Arrays/
β βββ LinkedLists/
β βββ Stacks/
β βββ Queues/
β βββ Trees/
β βββ Graphs/
β βββ HashTables/
β
βββ Algorithms/
βββ Sorting/
βββ Searching/
βββ DynamicProgramming/
βββ GraphAlgorithms/
βββ Other/
| Data Structure | Use Case |
|---|---|
| Array | Storing collections, matrix operations, cache |
| Linked List | Music player playlists, browser history |
| Stack | Function call stack, undo/redo functionality |
| Queue | Print queue, task scheduling, BFS |
| Tree | File systems, DOM structure, databases |
| Graph | Social networks, GPS navigation, web crawlers |
| Hash Table | Caching, indexing, database operations |
| Heap | Priority queues, heap sort, Dijkstra's algorithm |
Bubble Sort: O(nΒ²) average, O(nΒ²) worst
Selection Sort: O(nΒ²) average, O(nΒ²) worst
Insertion Sort: O(nΒ²) average, O(nΒ²) worst
Merge Sort: O(n log n) average, O(n log n) worst
Quick Sort: O(n log n) average, O(nΒ²) worst
Heap Sort: O(n log n) average, O(n log n) worst
Linear Search: O(n) time complexity
Binary Search: O(log n) time complexity (requires sorted array)
BFS (Breadth-First Search): O(V + E)
DFS (Depth-First Search): O(V + E)
Dijkstra's Algorithm: O((V + E) log V)
Floyd-Warshall: O(VΒ³)
We welcome contributions! Here's how you can help:
- Fork the repository
- Create a new branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- Follow C# naming conventions
- Add comments and documentation
- Include time and space complexity analysis
- Add example use cases
- Update README if adding new topics
- LeetCode - Practice coding problems
- HackerRank - Algorithm challenges
- CodeSignal - Interview prep
- GeeksforGeeks - Tutorials and explanations
- "Introduction to Algorithms" - Cormen, Leiserson, Rivest, Stein
- "Cracking the Coding Interview" - Gayle Laakmann McDowell
- "The Algorithm Design Manual" - Steven Skiena
- Kunal Kushwaha
- Abdul Bari
- Striver (DSA in C++)
- Code with Harry
This project is licensed under the GNU General Public License v3.0 - see the LICENSE file for details.
Zainulabedin
- GitHub: @ZainulabdeenOfficial
- Repository: Data Structures & Algorithms in C#
If you find this repository helpful:
- β Star the repository
- π Watch for updates
- π’ Share with others
- π¬ Contribute your improvements
Have questions or suggestions? Feel free to:
- Open an Issue
- Start a Discussion
- Fork and contribute