repo_name stringlengths 1 52 | repo_creator stringclasses 6
values | programming_language stringclasses 4
values | code stringlengths 0 9.68M | num_lines int64 1 234k |
|---|---|---|---|---|
C-Sharp | TheAlgorithms | C# | using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Algorithms.Other
{
/// <summary>
/// Almost all real complex decision-making task is described by more than one criterion.
/// Therefore, the methods of multicriteria optimization a... | 76 |
C-Sharp | TheAlgorithms | C# | using System;
using Algorithms.Numeric.GreatestCommonDivisor;
namespace Algorithms.Other
{
/// <summary>Implementation of the Pollard's rho algorithm.
/// Algorithm for integer factorization.
/// Wiki: https://en.wikipedia.org/wiki/Pollard's_rho_algorithm.
/// </summary>
public static class Pollard... | 38 |
C-Sharp | TheAlgorithms | C# | using System;
namespace Algorithms.Other
{
/// <summary>
/// The RGB color model is an additive color model in which red, green, and
/// blue light are added together in various ways to reproduce a broad array of
/// colors. The name of the model comes from the initials of the three addi... | 150 |
C-Sharp | TheAlgorithms | C# | using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Runtime.CompilerServices;
namespace Algorithms.Other
{
/// <summary>
/// Implements the Sieve of Eratosthenes.
/// </summary>
public class SieveOfEratosthenes
{
private readonly bool[]... | 72 |
C-Sharp | TheAlgorithms | C# | using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Algorithms.Other
{
/// <summary>Implementation of Welford's variance algorithm.
/// </summary>
public class WelfordsVariance
{
/// <summary>
/// Mean accumul... | 73 |
C-Sharp | TheAlgorithms | C# | using System;
using System.Collections.Generic;
using System.Linq;
namespace Algorithms.Problems.CoinChange
{
public static class DynamicCoinChangeSolver
{
/// <summary>
/// Generates an array of changes for current coin.
/// For instance, having coin C = 6 and array A = [1,3,4] it r... | 175 |
C-Sharp | TheAlgorithms | C# | using System;
using System.Collections.Generic;
namespace Algorithms.Problems.NQueens
{
public class BacktrackingNQueensSolver
{
/// <summary>
/// Solves N-Queen Problem given a n dimension chessboard and using backtracking with recursion algorithm.
/// If we find a dead-end ... | 109 |
C-Sharp | TheAlgorithms | C# | using System.Collections.Generic;
namespace Algorithms.Problems.StableMarriage
{
public class Accepter
{
public Proposer? EngagedTo { get; set; }
public List<Proposer> PreferenceOrder { get; set; } = new();
public bool PrefersOverCurrent(Proposer newProposer) =>
Engaged... | 16 |
C-Sharp | TheAlgorithms | C# | using System;
using System.Collections.Generic;
using System.Linq;
namespace Algorithms.Problems.StableMarriage
{
public static class GaleShapley
{
/// <summary>
/// Finds a stable matching between two equal sets of elements (fills EngagedTo properties).
/// time complexity: ... | 67 |
C-Sharp | TheAlgorithms | C# | using System.Collections.Generic;
namespace Algorithms.Problems.StableMarriage
{
public class Proposer
{
public Accepter? EngagedTo { get; set; }
public LinkedList<Accepter> PreferenceOrder { get; set; } = new();
}
}
| 12 |
C-Sharp | TheAlgorithms | C# | using System;
namespace Algorithms.Search
{
/// <summary>
/// Binary Searcher checks an array for element specified by checking
/// if element is greater or less than the half being checked.
/// time complexity: O(log(n)),
/// space complexity: O(1).
/// Note: Array must ... | 49 |
C-Sharp | TheAlgorithms | C# | using System;
using System.Collections.Generic;
using System.Linq;
namespace Algorithms.Search
{
/// <summary>
/// A Boyer-Moore majority finder algorithm implementation.
/// </summary>
/// <typeparam name="T">Type of element stored inside array.</typeparam>
public static class BoyerMoore<T> wh... | 59 |
C-Sharp | TheAlgorithms | C# | using System;
using Utilities.Exceptions;
namespace Algorithms.Search
{
/// <summary>
/// The idea: you could combine the advantages from both binary-search and interpolation search algorithm.
/// Time complexity:
/// worst case: Item couldn't be found: O(log n),
/// average case... | 81 |
C-Sharp | TheAlgorithms | C# | using System;
namespace Algorithms.Search
{
/// <summary>
/// Class that implements Fibonacci search algorithm.
/// </summary>
/// <typeparam name="T">Type of array element.</typeparam>
public class FibonacciSearcher<T> where T : IComparable<T>
{
/// <summary>
/// Finds ... | 91 |
C-Sharp | TheAlgorithms | C# | namespace Algorithms.Search
{
/// <summary>
/// Class that implements interpolation search algorithm.
/// </summary>
public static class InterpolationSearch
{
/// <summary>
/// Finds the index of the item searched for in the array.
/// Algorithm performance:
... | 53 |
C-Sharp | TheAlgorithms | C# | using System;
namespace Algorithms.Search
{
/// <summary>
/// Jump Search checks fewer elements by jumping ahead by fixed steps.
/// The optimal steps to jump is √n, where n refers to the number of elements in the array.
/// Time Complexity: O(√n)
/// Note: The array has to be s... | 63 |
C-Sharp | TheAlgorithms | C# | using System;
using Utilities.Exceptions;
namespace Algorithms.Search
{
/// <summary>
/// Class that implements linear search algorithm.
/// </summary>
/// <typeparam name="T">Type of array element.</typeparam>
public class LinearSearcher<T>
{
/// <summary>
/// Finds fir... | 55 |
C-Sharp | TheAlgorithms | C# | using System;
using System.Collections.Generic;
namespace Algorithms.Search
{
/// <summary>
/// RecursiveBinarySearcher.
/// </summary>
/// <typeparam name="T">Type of searcher target.</typeparam>
public class RecursiveBinarySearcher<T> where T : IComparable<T>
{
/// <summary>
... | 66 |
C-Sharp | TheAlgorithms | C# | using System.Collections.Generic;
namespace Algorithms.Search.AStar
{
/// <summary>
/// Contains the code for A* Pathfinding.
/// </summary>
public static class AStar
{
/// <summary>
/// Resets the Nodes in the list.
/// </summary>
/// <param name="nodes">... | 144 |
C-Sharp | TheAlgorithms | C# | using System;
namespace Algorithms.Search.AStar
{
/// <summary>
/// Contains Positional and other information about a single node.
/// </summary>
public class Node : IComparable<Node>, IEquatable<Node>
{
public Node(VecN position, bool traversable, double traverseMultiplier)
... | 103 |
C-Sharp | TheAlgorithms | C# | namespace Algorithms.Search.AStar
{
/// <summary>
/// The states the nodes can have.
/// </summary>
public enum NodeState
{
/// <summary>
/// TODO.
/// </summary>
Unconsidered = 0,
/// <summary>
/// TODO.
/// </summary>
... | 24 |
C-Sharp | TheAlgorithms | C# | using System;
namespace Algorithms.Search.AStar
{
/// <summary>
/// A pathfinding exception is thrown when the Pathfinder encounters a critical error and can not continue.
/// </summary>
public class PathfindingException : Exception
{
public PathfindingException(string message)
... | 16 |
C-Sharp | TheAlgorithms | C# | using System;
using System.Collections.Generic;
// todo: extract to data structures
namespace Algorithms.Search.AStar
{
/// <summary>
/// Generic Priority Queue.
/// List based.
/// </summary>
/// <typeparam name="T">
/// The type that will be stored.
/// Has to be ICompa... | 149 |
C-Sharp | TheAlgorithms | C# | using System;
namespace Algorithms.Search.AStar
{
/// <summary>
/// Vector Struct with N Dimensions.
/// </summary>
public struct VecN : IEquatable<VecN>
{
private readonly double[] data;
/// <summary>
/// Initializes a new instance of the <see cref="VecN" /> str... | 117 |
C-Sharp | TheAlgorithms | C# | using System.Collections.Generic;
using System.Numerics;
namespace Algorithms.Sequences;
/// <summary>
/// <para>
/// The all ones sequence.
/// </para>
/// <para>
/// OEIS: https://oeis.org/A000012.
/// </para>
/// </summary>
public class AllOnesSequence : ISequence
{
/// <summary... | 30 |
C-Sharp | TheAlgorithms | C# | using System.Collections.Generic;
using System.Numerics;
namespace Algorithms.Sequences;
/// <summary>
/// <para>
/// The all threes sequence.
/// </para>
/// <para>
/// OEIS: https://oeis.org/A010701.
/// </para>
/// </summary>
public class AllThreesSequence : ISequence
{
public I... | 27 |
C-Sharp | TheAlgorithms | C# | using System.Collections.Generic;
using System.Numerics;
namespace Algorithms.Sequences;
/// <summary>
/// <para>
/// The all twos sequence.
/// </para>
/// <para>
/// OEIS: https://oeis.org/A007395.
/// </para>
/// </summary>
public class AllTwosSequence : ISequence
{
public IEnum... | 27 |
C-Sharp | TheAlgorithms | C# | using System.Collections.Generic;
using System.Numerics;
namespace Algorithms.Sequences
{
/// <summary>
/// <para>
/// Sequence of binary prime constant
/// (Characteristic function of primes: 1 if n is prime, else 0).
/// </para>
/// <para>
/// Wikipedia... | 43 |
C-Sharp | TheAlgorithms | C# | using System.Collections.Generic;
using System.Numerics;
namespace Algorithms.Sequences
{
/// <summary>
/// <para>
/// Sequence of binomial coefficients.
/// </para>
/// <para>
/// Wikipedia: https://en.wikipedia.org/wiki/Binomial_coefficient.
/// </para>
... | 68 |
C-Sharp | TheAlgorithms | C# | using System.Collections.Generic;
using System.Numerics;
namespace Algorithms.Sequences;
/// <summary>
/// <para>
/// Cake numbers: maximal number of pieces resulting from n planar cuts through a cube
/// (or cake): C(n+1,3) + n + 1.
/// </para>
/// <para>
/// OEIS: https://oeis.or... | 31 |
C-Sharp | TheAlgorithms | C# | using System.Collections.Generic;
using System.Numerics;
namespace Algorithms.Sequences
{
/// <summary>
/// <para>
/// Catalan numbers: C[n+1] = (2*(2*n+1)*C[n])/(n+2).
/// </para>
/// <para>
/// Wikipedia: https://en.wikipedia.org/wiki/Catalan_number.
/// </... | 39 |
C-Sharp | TheAlgorithms | C# | using System.Collections.Generic;
using System.Numerics;
namespace Algorithms.Sequences;
/// <summary>
/// <para>
/// Central polygonal numbers (the Lazy Caterer's sequence): n(n+1)/2 + 1; or, maximal number of pieces
/// formed when slicing a pancake with n cuts.
/// </para>
/// <para>
//... | 31 |
C-Sharp | TheAlgorithms | C# | using System.Collections.Generic;
using System.Numerics;
namespace Algorithms.Sequences
{
/// <summary>
/// <para>
/// Sequence of cube numbers.
/// </para>
/// <para>
/// Wikipedia: https://en.wikipedia.org/wiki/Cube_(algebra).
/// </para>
/// <para>... | 37 |
C-Sharp | TheAlgorithms | C# | using System.Collections.Generic;
using System.Numerics;
namespace Algorithms.Sequences
{
/// <summary>
/// <para>
/// Sequence of the number of divisors of n, starting with 1.
/// </para>
/// <para>
/// OEIS: https://oeis.org/A000005.
/// </para>
/// </s... | 42 |
C-Sharp | TheAlgorithms | C# | using System.Collections.Generic;
using System.Numerics;
namespace Algorithms.Sequences
{
/// <summary>
/// <para>
/// Sequence of Euclid numbers: 1 + product of the first n primes.
/// </para>
/// <para>
/// Wikipedia: https://wikipedia.org/wiki/Euclid_number.
/... | 36 |
C-Sharp | TheAlgorithms | C# | using System.Collections.Generic;
using System.Linq;
using System.Numerics;
namespace Algorithms.Sequences
{
/// <summary>
/// <para>
/// Sequence of Euler totient function phi(n).
/// </para>
/// <para>
/// Wikipedia: https://en.wikipedia.org/wiki/Euler%27s_totient_... | 99 |
C-Sharp | TheAlgorithms | C# | using System.Collections.Generic;
using System.Numerics;
namespace Algorithms.Sequences
{
/// <summary>
/// <para>
/// Sequence of factorial numbers.
/// </para>
/// <para>
/// Wikipedia: https://en.wikipedia.org/wiki/Factorial.
/// </para>
/// <pa... | 38 |
C-Sharp | TheAlgorithms | C# | using System.Collections.Generic;
using System.Numerics;
namespace Algorithms.Sequences
{
/// <summary>
/// <para>
/// Sequence of Fermat numbers: a(n) = 2^(2^n) + 1.
/// </para>
/// <para>
/// Wikipedia: https://wikipedia.org/wiki/Fermat_number.
/// </par... | 37 |
C-Sharp | TheAlgorithms | C# | using System.Collections.Generic;
using System.Linq;
using System.Numerics;
namespace Algorithms.Sequences
{
/// <summary>
/// <para>
/// Sequence of Fermat primes: primes of the form 2^(2^k) + 1, for some k >= 0.
/// </para>
/// <para>
/// Wikipedia: https://wiki... | 37 |
C-Sharp | TheAlgorithms | C# | using System.Collections.Generic;
using System.Numerics;
namespace Algorithms.Sequences
{
/// <summary>
/// <para>
/// Fibonacci sequence.
/// </para>
/// <para>
/// Wikipedia: https://wikipedia.org/wiki/Fibonacci_number.
/// </para>
/// <para>
... | 41 |
C-Sharp | TheAlgorithms | C# | using System.Collections.Generic;
using System.Linq;
using System.Numerics;
namespace Algorithms.Sequences
{
/// <summary>
/// <para>
/// Golomb's sequence. a(n) is the number of times n occurs in the sequence, starting with a(1) = 1.
/// </para>
/// <para>
/// Wikip... | 47 |
C-Sharp | TheAlgorithms | C# | using System.Collections.Generic;
using System.Numerics;
namespace Algorithms.Sequences
{
/// <summary>
/// Common interface for all integer sequences.
/// </summary>
public interface ISequence
{
/// <summary>
/// Gets sequence as enumerable.
/// </summary>
... | 17 |
C-Sharp | TheAlgorithms | C# | using System.Collections.Generic;
using System.Numerics;
namespace Algorithms.Sequences
{
/// <summary>
/// <para>
/// Kolakoski sequence; n-th element is the length of the n-th run in the sequence itself.
/// </para>
/// <para>
/// Wikipedia: https://en.wikipedia.or... | 48 |
C-Sharp | TheAlgorithms | C# | using System.Collections.Generic;
using System.Linq;
using System.Numerics;
namespace Algorithms.Sequences
{
/// <summary>
/// <para>
/// Kolakoski sequence; n-th element is the length of the n-th run in the sequence itself.
/// </para>
/// <para>
/// Wikipedia: http... | 47 |
C-Sharp | TheAlgorithms | C# | using System.Collections.Generic;
using System.Linq;
using System.Numerics;
namespace Algorithms.Sequences
{
/// <summary>
/// <para>
/// Sequence of Kummer numbers (also called Euclid numbers of the second kind):
/// -1 + product of first n consecutive primes.
/// </para... | 38 |
C-Sharp | TheAlgorithms | C# | using System.Collections.Generic;
using System.Numerics;
namespace Algorithms.Sequences
{
/// <summary>
/// <para>
/// Sequence of Lucas number values.
/// </para>
/// <para>
/// Wikipedia: https://en.wikipedia.org/wiki/Lucas_number.
/// </para>
/// ... | 66 |
C-Sharp | TheAlgorithms | C# | using System;
using System.Collections.Generic;
using System.Numerics;
namespace Algorithms.Sequences
{
/// <summary>
/// <para>
/// Number of ways of making change for n cents using coins of 1, 2, 5, 10 cents.
/// </para>
/// <para>
/// OEIS: https://oeis.org/A00000... | 58 |
C-Sharp | TheAlgorithms | C# | using System;
using System.Collections.Generic;
using System.Numerics;
namespace Algorithms.Sequences;
/// <summary>
/// <para>
/// Sequence of number of triangles in triangular matchstick arrangement of side n for n>=0.
/// </para>
/// <para>
/// M. E. Larsen, The eternal triangle – ... | 72 |
C-Sharp | TheAlgorithms | C# | using System.Collections.Generic;
using System.Numerics;
namespace Algorithms.Sequences
{
/// <summary>
/// <para>
/// Sequence of natural numbers.
/// </para>
/// <para>
/// Wikipedia: https://wikipedia.org/wiki/Natural_number.
/// </para>
/// <pa... | 35 |
C-Sharp | TheAlgorithms | C# | using System.Collections.Generic;
using System.Numerics;
namespace Algorithms.Sequences
{
/// <summary>
/// <para>
/// Sequence of negative integers.
/// </para>
/// <para>
/// Wikipedia: https://wikipedia.org/wiki/Negative_number.
/// </para>
/// ... | 36 |
C-Sharp | TheAlgorithms | C# | using System.Collections.Generic;
using System.Numerics;
namespace Algorithms.Sequences
{
/// <summary>
/// <para>
/// Sequence of number of truth tables generated by Boolean expressions of n variables
/// (Double exponentials of 2: a(n) = 2^(2^n)).
/// </para>
/// ... | 38 |
C-Sharp | TheAlgorithms | C# | using System.Collections.Generic;
using System.Numerics;
namespace Algorithms.Sequences
{
/// <summary>
/// <para>
/// Number of primes with n digits
/// (The number of primes between 10^(n-1) and 10^n).
/// </para>
/// <para>
/// Wikipedia: https://wikip... | 46 |
C-Sharp | TheAlgorithms | C# | using System.Collections.Generic;
using System.Numerics;
namespace Algorithms.Sequences
{
/// <summary>
/// <para>
/// Sequence of number of primes less than 10^n (with at most n digits).
/// </para>
/// <para>
/// Wikipedia: https://wikipedia.org/wiki/Prime-counting... | 44 |
C-Sharp | TheAlgorithms | C# | using System.Collections.Generic;
using System.Numerics;
namespace Algorithms.Sequences;
/// <summary>
/// <para>
/// 1's-counting sequence: number of 1's in binary expression of n.
/// </para>
/// <para>
/// OEIS: https://oeis.org/A000120.
/// </para>
/// </summary>
public class On... | 90 |
C-Sharp | TheAlgorithms | C# | using System.Collections.Generic;
using System.Numerics;
namespace Algorithms.Sequences
{
/// <summary>
/// <para>
/// Sequence of powers of 10: a(n) = 10^n.
/// </para>
/// <para>
/// Wikipedia: https://wikipedia.org/wiki/Power_of_10.
/// </para>
/// ... | 37 |
C-Sharp | TheAlgorithms | C# | using System.Collections.Generic;
using System.Numerics;
namespace Algorithms.Sequences
{
/// <summary>
/// <para>
/// Sequence of powers of 2: a(n) = 2^n.
/// </para>
/// <para>
/// Wikipedia: https://wikipedia.org/wiki/Power_of_two.
/// </para>
/// ... | 37 |
C-Sharp | TheAlgorithms | C# | using System.Collections.Generic;
using System.Numerics;
namespace Algorithms.Sequences
{
/// <summary>
/// <para>
/// Sequence of number of primes less than or equal to n (PrimePi(n)).
/// </para>
/// <para>
/// Wikipedia: https://wikipedia.org/wiki/Prime-counting_f... | 43 |
C-Sharp | TheAlgorithms | C# | using System.Collections.Generic;
using System.Linq;
using System.Numerics;
namespace Algorithms.Sequences
{
/// <summary>
/// <para>
/// Sequence of prime numbers.
/// </para>
/// <para>
/// Wikipedia: https://wikipedia.org/wiki/Prime_number.
/// </para>
... | 48 |
C-Sharp | TheAlgorithms | C# | using System.Collections.Generic;
using System.Numerics;
namespace Algorithms.Sequences
{
/// <summary>
/// <para>
/// Sequence of primorial numbers: product of first n primes.
/// </para>
/// <para>
/// Wikipedia: https://wikipedia.org/wiki/Primorial.
/// </... | 38 |
C-Sharp | TheAlgorithms | C# | using System.Collections.Generic;
using System.Numerics;
namespace Algorithms.Sequences
{
/// <summary>
/// <para>
/// Recaman's sequence. a(0) = 0; for n > 0, a(n) = a(n-1) - n if nonnegative and not already in the sequence, otherwise a(n) = a(n-1) + n.
/// </para>
/// <para>
... | 48 |
C-Sharp | TheAlgorithms | C# | using System.Collections.Generic;
using System.Numerics;
namespace Algorithms.Sequences
{
/// <summary>
/// <para>
/// Sequence of square numbers.
/// </para>
/// <para>
/// Wikipedia: https://wikipedia.org/wiki/Square_number.
/// </para>
/// <para... | 37 |
C-Sharp | TheAlgorithms | C# | using System.Collections.Generic;
using System.Numerics;
namespace Algorithms.Sequences;
/// <summary>
/// <para>
/// Sequence of tetrahedral (triangular pyramids) counts for n >= 0.
/// </para>
/// <para>
/// OEIS: http://oeis.org/A000292.
/// </para>
/// <para>
/// Wik... | 43 |
C-Sharp | TheAlgorithms | C# | using System.Collections.Generic;
using System.Linq;
using System.Numerics;
namespace Algorithms.Sequences;
/// <summary>
/// <para>
/// Tetranacci numbers: a(n) = a(n-1) + a(n-2) + a(n-3) + a(n-4) with a(0) = a(1) = a(2) = a(3) = 1.
/// </para>
/// <para>
/// OEIS: https://oeis.org/A00028... | 34 |
C-Sharp | TheAlgorithms | C# | using System.Collections.Generic;
using System.Numerics;
namespace Algorithms.Sequences
{
/// <summary>
/// <para>
/// Number of halving and tripling steps to reach 1 in the '3n+1' problem.
/// </para>
/// <para>
/// Wikipedia: https://en.wikipedia.org/wiki/Collatz_c... | 54 |
C-Sharp | TheAlgorithms | C# | using System.Collections.Generic;
using System.Linq;
using System.Numerics;
namespace Algorithms.Sequences;
/// <summary>
/// <para>
/// Tribonacci numbers: a(n) = a(n-1) + a(n-2) + a(n-3) with a(0)=a(1)=a(2)=1.
/// </para>
/// <para>
/// OEIS: https://oeis.org/A000213.
/// </para>
///... | 33 |
C-Sharp | TheAlgorithms | C# | using System.Collections.Generic;
using System.Numerics;
namespace Algorithms.Sequences
{
/// <summary>
/// <para>
/// Van Eck's sequence. For n >= 1, if there exists an m < n such that a(m) = a(n), take the largest such m and set a(n+1) = n-m; otherwise a(n+1) = 0. Start with a(1)=0.
//... | 45 |
C-Sharp | TheAlgorithms | C# | using System.Collections;
using System.Collections.Generic;
using System.Numerics;
namespace Algorithms.Sequences
{
/// <summary>
/// <para>
/// The zero sequence.
/// </para>
/// <para>
/// OEIS: https://oeis.org/A000004.
/// </para>
/// </summary>
p... | 29 |
C-Sharp | TheAlgorithms | C# | using System;
namespace Algorithms.Shufflers
{
/// <summary>
/// Fisher-Yates shuffle is a simple shuffling algorithm,
/// which is usually used to shuffle a deck of cards.
/// </summary>
/// <typeparam name="T">Type array input.</typeparam>
public class FisherYatesShuffler<T> : IShuffl... | 33 |
C-Sharp | TheAlgorithms | C# | namespace Algorithms.Shufflers
{
/// <summary>
/// Shuffles array.
/// </summary>
/// <typeparam name="T">Type of array item.</typeparam>
public interface IShuffler<in T>
{
/// <summary>
/// Shuffles array.
/// </summary>
/// <param name="array">Array to S... | 16 |
C-Sharp | TheAlgorithms | C# | using System;
using System.Collections.Generic;
namespace Algorithms.Sorters.Comparison
{
/// <summary>
/// TODO.
/// </summary>
/// <typeparam name="T">TODO. 2.</typeparam>
public class BinaryInsertionSorter<T> : IComparisonSorter<T>
{
/// <summary>
/// Sorts array usin... | 73 |
C-Sharp | TheAlgorithms | C# | using System;
using System.Collections.Generic;
namespace Algorithms.Sorters.Comparison
{
/// <summary>
/// Class that implements bogo sort algorithm.
/// </summary>
/// <typeparam name="T">Type of array element.</typeparam>
public class BogoSorter<T> : IComparisonSorter<T>
{
privat... | 64 |
C-Sharp | TheAlgorithms | C# | using System.Collections.Generic;
namespace Algorithms.Sorters.Comparison
{
/// <summary>
/// Class that implements bubble sort algorithm.
/// </summary>
/// <typeparam name="T">Type of array element.</typeparam>
public class BubbleSorter<T> : IComparisonSorter<T>
{
/// <summary>... | 44 |
C-Sharp | TheAlgorithms | C# | using System.Collections.Generic;
namespace Algorithms.Sorters.Comparison
{
/// <summary>
/// Cocktail Sort is a variation of Bubble sort, where Cocktail
/// Sort traverses through a given array in both directions alternatively.
/// </summary>
/// <typeparam name="T">Array input type.</t... | 62 |
C-Sharp | TheAlgorithms | C# | using System;
using System.Collections.Generic;
namespace Algorithms.Sorters.Comparison
{
/// <summary>
/// Comb sort is a relatively simple sorting algorithm that improves on bubble sort.
/// </summary>
/// <typeparam name="T">Type of array element.</typeparam>
public class CombSorter<T> : ... | 53 |
C-Sharp | TheAlgorithms | C# | using System.Collections.Generic;
namespace Algorithms.Sorters.Comparison
{
/// <summary>
/// Cycle sort is an in-place, unstable sorting algorithm,
/// a comparison sort that is theoretically optimal in terms of the total
/// number of writes to the original array.
/// It is bas... | 80 |
C-Sharp | TheAlgorithms | C# | using System.Collections.Generic;
namespace Algorithms.Sorters.Comparison
{
/// <summary>
/// Class that implements exchange sort algorithm.
/// </summary>
/// <typeparam name="T">Type of array element.</typeparam>
public class ExchangeSorter<T> : IComparisonSorter<T>
{
/// <summ... | 35 |
C-Sharp | TheAlgorithms | C# | using System.Collections.Generic;
namespace Algorithms.Sorters.Comparison
{
/// <summary>
/// Heap sort is a comparison based sorting technique
/// based on Binary Heap data structure.
/// </summary>
/// <typeparam name="T">Input array type.</typeparam>
public class HeapSorter<T> : I... | 69 |
C-Sharp | TheAlgorithms | C# | using System.Collections.Generic;
namespace Algorithms.Sorters.Comparison
{
/// <summary>
/// Sorts array in ascending order using comparison sort.
/// </summary>
/// <typeparam name="T">Type of array item.</typeparam>
public interface IComparisonSorter<T>
{
/// <summary>
... | 19 |
C-Sharp | TheAlgorithms | C# | using System.Collections.Generic;
namespace Algorithms.Sorters.Comparison
{
/// <summary>
/// Class that implements insertion sort algorithm.
/// </summary>
/// <typeparam name="T">Type of array element.</typeparam>
public class InsertionSorter<T> : IComparisonSorter<T>
{
/// <summa... | 34 |
C-Sharp | TheAlgorithms | C# | using System.Collections.Generic;
namespace Algorithms.Sorters.Comparison
{
/// <summary>
/// Sorts arrays using quicksort (selecting median of three as a pivot).
/// </summary>
/// <typeparam name="T">Type of array element.</typeparam>
public sealed class MedianOfThreeQuickSorter<T> : Quick... | 57 |
C-Sharp | TheAlgorithms | C# | using System.Collections.Generic;
using System.Linq;
namespace Algorithms.Sorters.Comparison
{
/// <summary>
/// Divide and Conquer algorithm, which splits
/// array in two halves, calls itself for the two
/// halves and then merges the two sorted halves.
/// </summary>
/// <type... | 67 |
C-Sharp | TheAlgorithms | C# | using System.Collections.Generic;
namespace Algorithms.Sorters.Comparison
{
/// <summary>
/// Sorts arrays using quicksort (selecting middle point as a pivot).
/// </summary>
/// <typeparam name="T">Type of array element.</typeparam>
public sealed class MiddlePointQuickSorter<T> : QuickSorte... | 15 |
C-Sharp | TheAlgorithms | C# | using System.Collections.Generic;
namespace Algorithms.Sorters.Comparison
{
/// <summary>
/// Class that implements pancake sort algorithm.
/// </summary>
/// <typeparam name="T">Type of array element.</typeparam>
public class PancakeSorter<T> : IComparisonSorter<T>
{
/// <summar... | 79 |
C-Sharp | TheAlgorithms | C# | using System.Collections.Generic;
namespace Algorithms.Sorters.Comparison
{
/// <summary>
/// Sorts arrays using quicksort.
/// </summary>
/// <typeparam name="T">Type of array element.</typeparam>
public abstract class QuickSorter<T> : IComparisonSorter<T>
{
/// <summary>
... | 69 |
C-Sharp | TheAlgorithms | C# | using System;
using System.Collections.Generic;
namespace Algorithms.Sorters.Comparison
{
/// <summary>
/// Sorts arrays using quicksort (selecting random point as a pivot).
/// </summary>
/// <typeparam name="T">Type of array element.</typeparam>
public sealed class RandomPivotQuickSorter<T... | 18 |
C-Sharp | TheAlgorithms | C# | using System.Collections.Generic;
namespace Algorithms.Sorters.Comparison
{
/// <summary>
/// Class that implements selection sort algorithm.
/// </summary>
/// <typeparam name="T">Type of array element.</typeparam>
public class SelectionSorter<T> : IComparisonSorter<T>
{
/// <summa... | 40 |
C-Sharp | TheAlgorithms | C# | using System.Collections.Generic;
namespace Algorithms.Sorters.Comparison
{
/// <summary>
/// TODO.
/// </summary>
/// <typeparam name="T">TODO. 2.</typeparam>
public class ShellSorter<T> : IComparisonSorter<T>
{
/// <summary>
/// Sorts array using specified comparer,... | 56 |
C-Sharp | TheAlgorithms | C# | using System;
using System.Collections.Generic;
namespace Algorithms.Sorters.Comparison
{
/// <summary>
/// Timsort is a hybrid stable sorting algorithm, derived from merge sort and insertion sort, designed to perform well on many kinds of real-world data.
/// It was originally implemented by Tim P... | 635 |
C-Sharp | TheAlgorithms | C# | using System;
using System.Collections.Generic;
namespace Algorithms.Sorters.External
{
public class ExternalMergeSorter<T> : IExternalSorter<T>
{
public void Sort(
ISequentialStorage<T> mainMemory,
ISequentialStorage<T> temporaryMemory,
IComparer<T> comparer)
... | 130 |
C-Sharp | TheAlgorithms | C# | using System.Collections.Generic;
namespace Algorithms.Sorters.External
{
public interface IExternalSorter<T>
{
/// <summary>
/// Sorts elements in sequential storage in ascending order.
/// </summary>
/// <param name="mainMemory">Memory that contains array to sort and will ... | 15 |
C-Sharp | TheAlgorithms | C# | namespace Algorithms.Sorters.External
{
public interface ISequentialStorage<T>
{
public int Length { get; }
ISequentialStorageReader<T> GetReader();
ISequentialStorageWriter<T> GetWriter();
}
}
| 12 |
C-Sharp | TheAlgorithms | C# | using System;
namespace Algorithms.Sorters.External
{
public interface ISequentialStorageReader<out T> : IDisposable
{
T Read();
}
}
| 10 |
C-Sharp | TheAlgorithms | C# | using System;
namespace Algorithms.Sorters.External
{
public interface ISequentialStorageWriter<in T> : IDisposable
{
void Write(T value);
}
}
| 10 |
C-Sharp | TheAlgorithms | C# | using System.IO;
namespace Algorithms.Sorters.External.Storages
{
public class IntFileStorage : ISequentialStorage<int>
{
private readonly string filename;
public IntFileStorage(string filename, int length)
{
Length = length;
this.filename = filename;
}
... | 44 |
C-Sharp | TheAlgorithms | C# | namespace Algorithms.Sorters.External.Storages
{
public class IntInMemoryStorage : ISequentialStorage<int>
{
private readonly int[] storage;
public IntInMemoryStorage(int[] array) => storage = array;
public int Length => storage.Length;
public ISequentialStorageReader<int> Get... | 46 |
C-Sharp | TheAlgorithms | C# | using System;
using System.Collections.Generic;
using System.Linq;
namespace Algorithms.Sorters.Integer
{
/// <summary>
/// Class that implements bucket sort algorithm.
/// </summary>
public class BucketSorter : IIntegerSorter
{
private const int NumOfDigitsInBase10 = 10;
//... | 109 |
C-Sharp | TheAlgorithms | C# | using System;
using System.Linq;
namespace Algorithms.Sorters.Integer
{
/// <summary>
/// Counting sort is an algorithm for sorting a collection of objects according to keys that are small integers; that
/// is, it is an integer sorting algorithm. It operates by counting the number of objects that ... | 60 |
C-Sharp | TheAlgorithms | C# | namespace Algorithms.Sorters.Integer
{
/// <summary>
/// Sorts array of integers without comparing them.
/// </summary>
public interface IIntegerSorter
{
/// <summary>
/// Sorts array in ascending order.
/// </summary>
/// <param name="array">Array to sort.... | 15 |
C-Sharp | TheAlgorithms | C# | namespace Algorithms.Sorters.Integer
{
/// <summary>
/// Radix sort is a non-comparative integer sorting algorithm that sorts data with integer keys by grouping keys by the
/// individual
/// digits which share the same significant position and value. A positional notation is required, bu... | 50 |
C-Sharp | TheAlgorithms | C# | namespace Algorithms.Sorters.String
{
/// <summary>
/// Sorts array of strings without comparing them.
/// </summary>
public interface IStringSorter
{
/// <summary>
/// Sorts array in ascending order.
/// </summary>
/// <param name="array">Array to sort.</p... | 15 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.