Skip to content

Commit 411763c

Browse files
authored
docs: Complete XML documentation comments for sorting and numeric algorithms (#553)
1 parent cf79871 commit 411763c

File tree

5 files changed

+24
-17
lines changed

5 files changed

+24
-17
lines changed

Algorithms/Knapsack/NaiveKnapsackSolver.cs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,14 @@ namespace Algorithms.Knapsack;
77
public class NaiveKnapsackSolver<T> : IHeuristicKnapsackSolver<T>
88
{
99
/// <summary>
10-
/// TODO.
10+
/// Solves the knapsack problem using a naive greedy approach.
11+
/// Items are added in order until capacity is reached.
1112
/// </summary>
12-
/// <param name="items">TODO. 2.</param>
13-
/// <param name="capacity">TODO. 3.</param>
14-
/// <param name="weightSelector">TODO. 4.</param>
15-
/// <param name="valueSelector">TODO. 5.</param>
16-
/// <returns>TODO. 6.</returns>
13+
/// <param name="items">Array of items to consider for the knapsack.</param>
14+
/// <param name="capacity">Maximum weight capacity of the knapsack.</param>
15+
/// <param name="weightSelector">Function to get the weight of an item.</param>
16+
/// <param name="valueSelector">Function to get the value of an item.</param>
17+
/// <returns>Array of items that fit in the knapsack.</returns>
1718
public T[] Solve(T[] items, double capacity, Func<T, double> weightSelector, Func<T, double> valueSelector)
1819
{
1920
var weight = 0d;

Algorithms/Numeric/GreatestCommonDivisor/EuclideanGreatestCommonDivisorFinder.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
namespace Algorithms.Numeric.GreatestCommonDivisor;
22

33
/// <summary>
4-
/// TODO.
4+
/// Euclidean algorithm for finding the greatest common divisor.
55
/// </summary>
66
public class EuclideanGreatestCommonDivisorFinder : IGreatestCommonDivisorFinder
77
{
88
/// <summary>
99
/// Finds greatest common divisor for numbers a and b
1010
/// using euclidean algorithm.
1111
/// </summary>
12-
/// <param name="a">TODO.</param>
13-
/// <param name="b">TODO. 2.</param>
12+
/// <param name="a">First number.</param>
13+
/// <param name="b">Second number.</param>
1414
/// <returns>Greatest common divisor.</returns>
1515
public int FindGcd(int a, int b)
1616
{

Algorithms/Sorters/Comparison/BinaryInsertionSorter.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
namespace Algorithms.Sorters.Comparison;
22

33
/// <summary>
4-
/// TODO.
4+
/// Class that implements binary insertion sort algorithm.
55
/// </summary>
6-
/// <typeparam name="T">TODO. 2.</typeparam>
6+
/// <typeparam name="T">Type of array element.</typeparam>
77
public class BinaryInsertionSorter<T> : IComparisonSorter<T>
88
{
99
/// <summary>
@@ -37,7 +37,7 @@ public void Sort(T[] array, IComparer<T> comparer)
3737
/// <param name="from">Left index to search from (inclusive).</param>
3838
/// <param name="to">Right index to search to (inclusive).</param>
3939
/// <param name="target">The value to find placefor in the provided array.</param>
40-
/// <param name="comparer">TODO.</param>
40+
/// <param name="comparer">Compares elements.</param>
4141
/// <returns>The index where to insert target value.</returns>
4242
private static int BinarySearch(T[] array, int from, int to, T target, IComparer<T> comparer)
4343
{

Algorithms/Sorters/Comparison/BogoSorter.cs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,16 @@ public class BogoSorter<T> : IComparisonSorter<T>
99
private readonly Random random = new();
1010

1111
/// <summary>
12-
/// TODO.
12+
/// Sorts array using specified comparer,
13+
/// randomly shuffles elements until array is sorted,
14+
/// internal, in-place, unstable,
15+
/// worst-case time complexity: unbounded (infinite),
16+
/// average time complexity: O((n+1)!),
17+
/// space complexity: O(n),
18+
/// where n - array length.
1319
/// </summary>
14-
/// <param name="array">TODO. 2.</param>
15-
/// <param name="comparer">TODO. 3.</param>
20+
/// <param name="array">Array to sort.</param>
21+
/// <param name="comparer">Compares elements.</param>
1622
public void Sort(T[] array, IComparer<T> comparer)
1723
{
1824
while (!IsSorted(array, comparer))

Algorithms/Sorters/Comparison/ShellSorter.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
namespace Algorithms.Sorters.Comparison;
22

33
/// <summary>
4-
/// TODO.
4+
/// Class that implements Shell sort algorithm.
55
/// </summary>
6-
/// <typeparam name="T">TODO. 2.</typeparam>
6+
/// <typeparam name="T">Type of array element.</typeparam>
77
public class ShellSorter<T> : IComparisonSorter<T>
88
{
99
/// <summary>

0 commit comments

Comments
 (0)