Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions Algorithms/Knapsack/NaiveKnapsackSolver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@ namespace Algorithms.Knapsack;
public class NaiveKnapsackSolver<T> : IHeuristicKnapsackSolver<T>
{
/// <summary>
/// TODO.
/// Solves the knapsack problem using a naive greedy approach.
/// Items are added in order until capacity is reached.
/// </summary>
/// <param name="items">TODO. 2.</param>
/// <param name="capacity">TODO. 3.</param>
/// <param name="weightSelector">TODO. 4.</param>
/// <param name="valueSelector">TODO. 5.</param>
/// <returns>TODO. 6.</returns>
/// <param name="items">Array of items to consider for the knapsack.</param>
/// <param name="capacity">Maximum weight capacity of the knapsack.</param>
/// <param name="weightSelector">Function to get the weight of an item.</param>
/// <param name="valueSelector">Function to get the value of an item.</param>
/// <returns>Array of items that fit in the knapsack.</returns>
public T[] Solve(T[] items, double capacity, Func<T, double> weightSelector, Func<T, double> valueSelector)
{
var weight = 0d;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
namespace Algorithms.Numeric.GreatestCommonDivisor;

/// <summary>
/// TODO.
/// Euclidean algorithm for finding the greatest common divisor.
/// </summary>
public class EuclideanGreatestCommonDivisorFinder : IGreatestCommonDivisorFinder
{
/// <summary>
/// Finds greatest common divisor for numbers a and b
/// using euclidean algorithm.
/// </summary>
/// <param name="a">TODO.</param>
/// <param name="b">TODO. 2.</param>
/// <param name="a">First number.</param>
/// <param name="b">Second number.</param>
/// <returns>Greatest common divisor.</returns>
public int FindGcd(int a, int b)
{
Expand Down
6 changes: 3 additions & 3 deletions Algorithms/Sorters/Comparison/BinaryInsertionSorter.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
namespace Algorithms.Sorters.Comparison;

/// <summary>
/// TODO.
/// Class that implements binary insertion sort algorithm.
/// </summary>
/// <typeparam name="T">TODO. 2.</typeparam>
/// <typeparam name="T">Type of array element.</typeparam>
public class BinaryInsertionSorter<T> : IComparisonSorter<T>
{
/// <summary>
Expand Down Expand Up @@ -37,7 +37,7 @@ public void Sort(T[] array, IComparer<T> comparer)
/// <param name="from">Left index to search from (inclusive).</param>
/// <param name="to">Right index to search to (inclusive).</param>
/// <param name="target">The value to find placefor in the provided array.</param>
/// <param name="comparer">TODO.</param>
/// <param name="comparer">Compares elements.</param>
/// <returns>The index where to insert target value.</returns>
private static int BinarySearch(T[] array, int from, int to, T target, IComparer<T> comparer)
{
Expand Down
12 changes: 9 additions & 3 deletions Algorithms/Sorters/Comparison/BogoSorter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,16 @@ public class BogoSorter<T> : IComparisonSorter<T>
private readonly Random random = new();

/// <summary>
/// TODO.
/// Sorts array using specified comparer,
/// randomly shuffles elements until array is sorted,
/// internal, in-place, unstable,
/// worst-case time complexity: unbounded (infinite),
/// average time complexity: O((n+1)!),
/// space complexity: O(n),
/// where n - array length.
/// </summary>
/// <param name="array">TODO. 2.</param>
/// <param name="comparer">TODO. 3.</param>
/// <param name="array">Array to sort.</param>
/// <param name="comparer">Compares elements.</param>
public void Sort(T[] array, IComparer<T> comparer)
{
while (!IsSorted(array, comparer))
Expand Down
4 changes: 2 additions & 2 deletions Algorithms/Sorters/Comparison/ShellSorter.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
namespace Algorithms.Sorters.Comparison;

/// <summary>
/// TODO.
/// Class that implements Shell sort algorithm.
/// </summary>
/// <typeparam name="T">TODO. 2.</typeparam>
/// <typeparam name="T">Type of array element.</typeparam>
public class ShellSorter<T> : IComparisonSorter<T>
{
/// <summary>
Expand Down