The Algorithms Library is a versatile C# project that provides a comprehensive collection of basic algorithms implemented within the .NET 4.7.3 framework. This library is designed with extensibility in mind, allowing users to easily add their own algorithms.
It's a great tool for learning algorithms and their implementation. It also allows you to quickly test your own algorithms or create a collection of your favorite / custom algorithms.
It is built using the Visual Studio 2022.
This project was created targeting Windows. It has not been tested on other operating systems.
Before using the Algorithms Library, make sure that you have the following prerequisites installed on your system:
- Visual Studio 2022 (version 17.6.3 or later)
- ".NET desktop development" workload installed.
-
Clone this repository to your local machine using Git, or download the ZIP file and extract it to a directory of your choice:
git clone https://github.com/JakubKorytko/algorithms-library.git
-
Change to the project directory:
cd algorithms-library
-
In Visual Studio, open the `AlgorithmsLibrary.sln' solution file.
-
Build or run the project in Visual Studio:
-
Run the project in the Visual Studio
F5
/Ctrl + F5
by default- or
Debug
->Start Debugging
/Start Without Debugging
on the toolbar
-
or Build project executable
Ctrl + B
/Ctrl + Shift + B
by default- or
Build
->Build Solution
/Build AlgorithmsLibrary
on the toolbar
The executable will be available in the
build
directory in both cases. -
The application has an intuitive text-based menu. When launched, the menu is displayed and the application waits for your input (case-insensitive).
<algorithm_name>
- execute the selected algorithmmenu
- show the menu optionsexit
- Eratosthenes (Sieve of Eratosthenes)
- SuperAlgorithm (an example algorithm without input)
- Factorial (Factorial calculator)
- Fibonacci (Fibonacci sequence calculator)
- Hanoi (Hanoi tower solver)
- Triangular (Triangular numbers calculator)
Add a new class to the Components/Algorithms folder.
Make sure that the class is derived from the Algorithm class
(AlgorithmsLibrary.AlgorithmsCore
namespace).
Also, the class should:
-
Override the public void method named
Display
which is used to execute the algorithm (you must handle the output within this function)- IF NOT: The application displays
No display method defined for this algorithm
when you try to select it from the menu.
- IF NOT: The application displays
-
Override the public virtual string
Description
:public override string Description { get { return "..."; } }
- IF NOT: The application displays
No description provided for this algorithm
next to it in the printed menu.
- IF NOT: The application displays
-
Have a unique class name that is displayed in the menu.
For example, see Components/Algorithms/Algorithm.example.cs
If you need to add a method that is available to all algorithms, add a new method to the Components/AlgorithmsCore/BaseClassTools.cs file.
The file contains a sample method that you can check to create your own.
(Also, there are already some methods there to parse integers from the input, check them out if you are interested).
If you find issues or have suggestions for improvements, feel free to open an issue or submit a pull request. Contributions are welcome!
If you have any questions, feel free to contact me at [email protected].
This project is released under the MIT License. See the LICENSE file for details.