tagged [algorithm]
How can I calculate what date Good Friday falls on, given a year?
How can I calculate what date Good Friday falls on, given a year? Does anyone have a good algorithm to calculate what date Good Friday falls on given the year as an input? Preferably in C#.
- Modified
- 31 Mar at 08:7
What is the complexity of the sorted() function?
What is the complexity of the sorted() function? I have a list of lists and I am sorting them using the following Was wondering what is the runtime complexity of this python function?
Select N random elements from a List<T> in C#
Select N random elements from a List in C# I need a quick algorithm to select 5 random elements from a generic list. For example, I'd like to get 5 random elements from a `List`.
- Modified
- 21 Jul at 12:27
How might I find the largest number contained in a JavaScript array?
How might I find the largest number contained in a JavaScript array? I have a simple JavaScript Array object containing a few numbers. Is there a function that would find the largest number in this ar...
- Modified
- 4 Sep at 14:20
Equation for testing if a point is inside a circle
Equation for testing if a point is inside a circle If you have a circle with center `(center_x, center_y)` and radius `radius`, how do you test if a given point with coordinates `(x, y)` is inside the...
- Modified
- 23 Jun at 15:30
HSL to RGB color conversion
HSL to RGB color conversion I am looking for an algorithm to convert between HSL color to RGB. It seems to me that HSL is not very widely used so I am not having much luck searching for a converter.
How do you detect Credit card type based on number?
How do you detect Credit card type based on number? I'm trying to figure out how to detect the type of credit card based purely on its number. Does anyone know of a definitive, reliable way to find th...
- Modified
- 30 Dec at 16:15
How to determine the longest increasing subsequence using dynamic programming?
How to determine the longest increasing subsequence using dynamic programming? I have a set of integers. I want to find the [longest increasing subsequence](https://en.wikipedia.org/wiki/Longest_incre...
- Modified
- 25 Apr at 09:35
How to create a trie in c#
How to create a trie in c# Does anyone know where I can find an example of how to construct a trie in C#? I'm trying to take a dictionary/list of words and create a trie with it.
- Modified
- 30 Jul at 16:23
Javascript Array.sort implementation?
Javascript Array.sort implementation? Which algorithm does the JavaScript `Array#sort()` function use? I understand that it can take all manner of arguments and functions to perform different kinds of...
- Modified
- 28 Jan at 14:18
What's the quickest way to compute log2 of an integer in C#?
What's the quickest way to compute log2 of an integer in C#? How can I most efficiently count the number of bits required by an integer (log base 2) in C#? For example:
- Modified
- 23 Jan at 10:19
Picking a random element from a set
Picking a random element from a set How do I pick a random element from a set? I'm particularly interested in picking a random element from a HashSet or a LinkedHashSet, in Java. Solutions for other l...
- Modified
- 24 Sep at 19:40
Red eye reduction algorithm
Red eye reduction algorithm I need to implement red eye reduction for an application I am working on. Googling mostly provides links to commercial end-user products. Do you know a good red eye reducti...
- Modified
- 25 Sep at 15:30
C# compare algorithms
C# compare algorithms Are there any open source algorithms in c# that solve the problem of creating a difference between two text files? It would be super cool if it had some way of highlighting what ...
Converting a Uniform Distribution to a Normal Distribution
Converting a Uniform Distribution to a Normal Distribution How can I convert a uniform distribution (as most random number generators produce, e.g. between 0.0 and 1.0) into a normal distribution? Wha...
- Modified
- 6 Jun at 20:56
Popularity algorithm
Popularity algorithm On SO 18 Joel mentioned an algorithm that would rank items based on their age and popularity and it's based on gravity. Could someone post this? C# would be lovely, but really any...
Algorithm for checking transitivity of relation?
Algorithm for checking transitivity of relation? I need to check if relation is transitive or not? Would you please suggest some algorithm to check the transitivity of relations? I am storing relation...
- Modified
- 10 Mar at 23:19
Creating all possible k combinations of n items in C++
Creating all possible k combinations of n items in C++ There are n people numbered from `1` to `n`. I have to write a code which produces and print all different combinations of `k` people from these ...
- Modified
- 10 Oct at 21:48
Why doesn't Dijkstra's algorithm work for negative weight edges?
Why doesn't Dijkstra's algorithm work for negative weight edges? Can somebody tell me why Dijkstra's algorithm for single source shortest path assumes that the edges must be non-negative. I am talking...
- Modified
- 9 May at 06:11
Efficient Algorithm for Bit Reversal (from MSB->LSB to LSB->MSB) in C
Efficient Algorithm for Bit Reversal (from MSB->LSB to LSB->MSB) in C What is the most efficient algorithm to achieve the following: `0010 0000 => 0000 0100` The conversion is from MSB->LSB to LSB->MS...
- Modified
- 29 Jan at 03:53
Why do we check up to the square root of a number to determine if the number is prime?
Why do we check up to the square root of a number to determine if the number is prime? To test whether a number is prime or not, why do we have to test whether it is divisible only up to the square ro...
- Modified
- 14 Apr at 17:52
How to round decimal value up to nearest 0.05 value?
How to round decimal value up to nearest 0.05 value? Is there any way to round up decimal value to its nearest 0.05 value in .Net? Ex: 7.125 -> 7.15 6.66 -> 6.7 If its now available can anyone provide...
What is the time and space complexity of a breadth first and depth first tree traversal?
What is the time and space complexity of a breadth first and depth first tree traversal? Can someone explain with an example how we can calculate the time and space complexity of both these traversal ...
- Modified
- 15 May at 11:19
Removing Duplicate Images
Removing Duplicate Images We have a collection of photo images sizing a few hundred gigs. A large number of the photos are visually duplicates, but with differing filesizes, resolution, compression et...
- Modified
- 5 Dec at 16:28
How to write an algorithm to check if the sum of any two numbers in an array/list matches a given number?
How to write an algorithm to check if the sum of any two numbers in an array/list matches a given number? How can I write an algorithm to check if the sum of any two numbers in an array/list matches a...
- Modified
- 19 Apr at 10:40