Welcome to the Algorithms in C# repository! In this project, you will find implementations of various popular algorithms written in C#. The goal of this repository is to provide examples of common algorithms and serve as a reference for students and developers looking to learn and improve their C# and algorithmic skills.
Each project folder has its own README.md with a short description and its time/space complexity.
Below is a list of the algorithms implemented in this repository:
-
Bubble Sort: A simple sorting algorithm that works by repeatedly stepping through the list to be sorted, comparing each pair of adjacent items and swapping them if they are in the wrong order. (This project also includes Selection Sort, Merge Sort and Quick Sort alongside Bubble Sort and Insertion Sort.)
-
Insertion Sort: An efficient sorting algorithm that builds a sorted list one item at a time, moving the unsorted elements to their correct position in the sorted list.
-
Binary Search: An efficient search algorithm that finds the desired value within a sorted list by repeatedly dividing the list in half and comparing the desired value with the value in the middle.
-
DataTypeChecker: A function that checks and returns the data type of a variable in C#.
-
FindIndex: A method that finds the index of a specific element in a list or array.
-
GetArrayData: A function that generates and returns an array of data.
-
GetMax: A method that finds the maximum value in an array or list.
-
GetMaxofMaxRow: A function that finds the maximum value of a matrix of matrices.
-
GetNumberFromRandom: A function that generates and returns a random number within a specific range.
-
GetPrime: A method that checks if a given number is a prime number.
-
IndexOfArray: A method that searches for a specific element in an array and returns its index.
-
InvokeDelegate: An example of how to invoke delegates in C#.
-
IsPrime: A function that checks if a given number is a prime number.
-
IsSymmetric: A function that checks if a matrix is symmetric (a matrix that is equal to its transpose).
-
ReverseArray: A function that reverses the order of elements in an array.
-
ReverseNumberA: A function that reverses an integer using arithmetic operations.
-
ReverseNumberB: A function that reverses an integer by converting it to a string and manipulating its characters.
-
StringBenchmark: An example of how to benchmark the performance of different string operations in C#.
-
Merge Sort: A divide-and-conquer sorting algorithm that recursively splits the list in half, sorts each half, and merges the results.
-
Quick Sort: A divide-and-conquer sorting algorithm that partitions the list around a pivot and recursively sorts the partitions.
-
LinkedList: A singly linked list implementation supporting append, remove and lookup.
-
Stack: A LIFO (last-in, first-out) stack implementation backed by a resizable array.
-
Queue: A FIFO (first-in, first-out) queue implementation backed by a linked list.
-
GraphTraversal: Breadth-First Search (BFS) and Depth-First Search (DFS) over a graph represented as an adjacency list.
-
DynamicProgramming: Fibonacci with memoization and the 0/1 Knapsack problem solved with bottom-up dynamic programming.
The AlgorithmsCSharp.Tests project covers sorting, binary search, primality checking, symmetry checking, digit and number reversal, factorial calculation, the linked list, stack, queue, graph traversal (BFS/DFS), and dynamic programming (memoized Fibonacci, 0/1 Knapsack). Run it with:
dotnet test "AlgorithmsC#.sln"This project is licensed under the MIT License.