From 985c0bf2f2b75d069754f809ea76ed83f0d3191b Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 4 Nov 2025 16:44:33 +0000 Subject: [PATCH] docs: Complete XML documentation comments for sorting and numeric algorithms --- Algorithms/Knapsack/NaiveKnapsackSolver.cs | 13 +++++++------ .../EuclideanGreatestCommonDivisorFinder.cs | 6 +++--- .../Sorters/Comparison/BinaryInsertionSorter.cs | 6 +++--- Algorithms/Sorters/Comparison/BogoSorter.cs | 12 +++++++++--- Algorithms/Sorters/Comparison/ShellSorter.cs | 4 ++-- 5 files changed, 24 insertions(+), 17 deletions(-) diff --git a/Algorithms/Knapsack/NaiveKnapsackSolver.cs b/Algorithms/Knapsack/NaiveKnapsackSolver.cs index 38a4f93d..010ba68d 100644 --- a/Algorithms/Knapsack/NaiveKnapsackSolver.cs +++ b/Algorithms/Knapsack/NaiveKnapsackSolver.cs @@ -7,13 +7,14 @@ namespace Algorithms.Knapsack; public class NaiveKnapsackSolver : IHeuristicKnapsackSolver { /// - /// TODO. + /// Solves the knapsack problem using a naive greedy approach. + /// Items are added in order until capacity is reached. /// - /// TODO. 2. - /// TODO. 3. - /// TODO. 4. - /// TODO. 5. - /// TODO. 6. + /// Array of items to consider for the knapsack. + /// Maximum weight capacity of the knapsack. + /// Function to get the weight of an item. + /// Function to get the value of an item. + /// Array of items that fit in the knapsack. public T[] Solve(T[] items, double capacity, Func weightSelector, Func valueSelector) { var weight = 0d; diff --git a/Algorithms/Numeric/GreatestCommonDivisor/EuclideanGreatestCommonDivisorFinder.cs b/Algorithms/Numeric/GreatestCommonDivisor/EuclideanGreatestCommonDivisorFinder.cs index df93caf9..f3c64431 100644 --- a/Algorithms/Numeric/GreatestCommonDivisor/EuclideanGreatestCommonDivisorFinder.cs +++ b/Algorithms/Numeric/GreatestCommonDivisor/EuclideanGreatestCommonDivisorFinder.cs @@ -1,7 +1,7 @@ namespace Algorithms.Numeric.GreatestCommonDivisor; /// -/// TODO. +/// Euclidean algorithm for finding the greatest common divisor. /// public class EuclideanGreatestCommonDivisorFinder : IGreatestCommonDivisorFinder { @@ -9,8 +9,8 @@ public class EuclideanGreatestCommonDivisorFinder : IGreatestCommonDivisorFinder /// Finds greatest common divisor for numbers a and b /// using euclidean algorithm. /// - /// TODO. - /// TODO. 2. + /// First number. + /// Second number. /// Greatest common divisor. public int FindGcd(int a, int b) { diff --git a/Algorithms/Sorters/Comparison/BinaryInsertionSorter.cs b/Algorithms/Sorters/Comparison/BinaryInsertionSorter.cs index e6380673..36fc2354 100644 --- a/Algorithms/Sorters/Comparison/BinaryInsertionSorter.cs +++ b/Algorithms/Sorters/Comparison/BinaryInsertionSorter.cs @@ -1,9 +1,9 @@ namespace Algorithms.Sorters.Comparison; /// -/// TODO. +/// Class that implements binary insertion sort algorithm. /// -/// TODO. 2. +/// Type of array element. public class BinaryInsertionSorter : IComparisonSorter { /// @@ -37,7 +37,7 @@ public void Sort(T[] array, IComparer comparer) /// Left index to search from (inclusive). /// Right index to search to (inclusive). /// The value to find placefor in the provided array. - /// TODO. + /// Compares elements. /// The index where to insert target value. private static int BinarySearch(T[] array, int from, int to, T target, IComparer comparer) { diff --git a/Algorithms/Sorters/Comparison/BogoSorter.cs b/Algorithms/Sorters/Comparison/BogoSorter.cs index f419a331..c33812b1 100644 --- a/Algorithms/Sorters/Comparison/BogoSorter.cs +++ b/Algorithms/Sorters/Comparison/BogoSorter.cs @@ -9,10 +9,16 @@ public class BogoSorter : IComparisonSorter private readonly Random random = new(); /// - /// 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. /// - /// TODO. 2. - /// TODO. 3. + /// Array to sort. + /// Compares elements. public void Sort(T[] array, IComparer comparer) { while (!IsSorted(array, comparer)) diff --git a/Algorithms/Sorters/Comparison/ShellSorter.cs b/Algorithms/Sorters/Comparison/ShellSorter.cs index 046069b1..8e27ded5 100644 --- a/Algorithms/Sorters/Comparison/ShellSorter.cs +++ b/Algorithms/Sorters/Comparison/ShellSorter.cs @@ -1,9 +1,9 @@ namespace Algorithms.Sorters.Comparison; /// -/// TODO. +/// Class that implements Shell sort algorithm. /// -/// TODO. 2. +/// Type of array element. public class ShellSorter : IComparisonSorter { ///