Basic implementation of core Computer Science algorithms and data structures written in C# and packaged as .NET Core assembly. Hence, the choice to use core
:-)
This project was primarily influenced by the following StackOverflow question and popular answer, my desire to create a cross-platform library and more importantly, help anyone interested in learning the fundamentals.
- Provide implementations to standard algorithms/data structures
- Include unit tests to verify functionality
- Write clean and straightforward code with helpful comments
- No dependency on third-party libraries
-
Algorithms
- Sorting
- Bubble Sort implementation and tests
- Insertion Sort implementation and tests
- Selection Sort implementation and tests
- Merge Sort implementation and tests
- Quick Sort implementation and tests
- Searching
- Binary Search implementation and tests
- Depth First Search implementation and test
- Breadth First Search implementation and test
- Sorting
-
Data structures
- Linked List implementation and tests
- Doubly Linked List implementation and tests
- Queue implementation and tests
- Stack implementation and tests
- Graph
- Undirected (implemented using Adjacency List) and tests
- Min Heap (coming soon!)
- Max Heap (coming soon!)
-
The goal of this project is to implement solutions, not leverage LINQ or make use of latest-and-greatest syntactic sugar provided by .NET Core to reduce code.
-
It should also be noted, I have not provided a solution to 'RegEx match open tags except XHTML self-contained tags'. Use an XML parser instead :-)
- Binary Search
int[] array = new int[] { 1, 2, 15, 35, 46, 78, 100 };
int index = BinarySearch.Search(array, 35);
// Will return 3
- Bubble Sort
int[] unsortedArray = new[] { 300, 5, 1, 8, 100, 2, 10 };
BubbleSort.Sort(unsortedArray);
// Will produce [1, 2, 5, 8, 10, 100, 300]
- Insertion Sort
int[] unsortedArray = new int[] { 38, 27, 43, 3, 9, 82, 10 };
InsertionSort.Sort(unsortedArray);
// Will produce [3, 9, 10, 27, 38, 43, 82]
- Selection Sort
int[] unsortedArray = new int[] { 300, 5, 1, 8, 100, 2, 10 };
SelectionSort.Sort(unsortedArray);
// Will produce [1, 2, 5, 8, 10, 100, 300]
- Stack
using Core = CoreConcepts.DataStructures.Linear;
Core.Stack<int> stack = new Core.Stack<int>();
int itemsToPush = 5;
for (int i = 1; i <= itemsToPush; i++)
{
stack.Push(i);
}
for (int i = itemsToPush; i > 0; i--)
{
int value = stack.Pop();
}