This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
How to calculate or approximate the median of a list without storing the list
I want to apply using C# an algorithm to find the median value using selection/quick sort. But I do not want to sort the whole array in order to get the median.
Can I do it?
Wikipedia's entry on Selection Algorithm gives various alternatives, including the Median of Medians approach, which would seem to fit your requirements. In particular, it has a worst-case performance of O(n).
Related
This question already has answers here:
working with incredibly large numbers in .NET
(11 answers)
Closed 5 years ago.
I have to be able to handle extreme numbers and large es: consisting of eight million bits, but with which I must be able to perform the operations of division and rest.
This number can also be used as an array of bool
Use a BigInteger
The BigInteger type is an immutable type that represents an arbitrarily large integer whose value in theory has no upper or lower bounds.
This question already has answers here:
C# LINQ find duplicates in List
(13 answers)
Closed 5 years ago.
I was hoping to do something like:
int[] locations;
do
{/*edit locations to only contain one int in array of same value*/}
while (locations.Where(val, secondVal => val == secondVal).count > 1)
And I highly feel like I've done something of the sort in the past, perhaps it was with a list and it doesn't function the same way with an array but I can't seem to find my example anywhere.
I feel that the code snip explains well enough my intentions, but it doesn't work, would someone be able to help? Thanks.
I'll keep searching online but if someone could help it would obviously speed up my search.
You should look to this answer:
C# LINQ find duplicates in List
Just group elements by its value and then get the list
GroupBy(x=>x).Where(g=>g.Count()>1)
This question already has an answer here:
Maximum array dimension like a[1][1][1][1]....[1] in C#
(1 answer)
Closed 7 years ago.
This is a question that i cannot find an answer for, not even in the C# specifications. So before anyone goes, why would you use or need a N dimension array, remember that this is a question for knowledge purposes.
You're looking for the maximum rank of an array in C#. See the documentation at MSDN, under "Remarks":
An array can have a maximum of 32 dimensions.
For jagged arrays, it's implementation defined (usually more than 1000, for mono the limit seems to be 255) see the SO question linked by Zohar in the commments to your question.
This question already has answers here:
Is there a Lower Bound function on a SortedList<K ,V>?
(6 answers)
Closed 9 years ago.
I need a built-in datastructure in C# that has functionality similar to std::set (or std::map) in c++. What is important to me is that the structure should be sorted(thus Dictionary will not do here) and has a method similar to lower_bound(i.e. return first element with value at least v). I will also need to insert and delete elements from the structure. If possible I need these operations to have complexity O(log(n)). Could you please point me to the appropriate datastructure in C#?
I suspect you are looking for SortedSet in terms of a similar data structure to std::set.
This article goes into its performance characteristics.
A lower_bound functionality seems to be possible using SortedSet.GetViewBetween but has a worse complexity than the desired O(log(n)) according to this discussion.
This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
Are there any Fuzzy Search or String Similarity Functions libraries written for C#?
I need to check the similarity of input value -which one user entered- to our records.
12345 vs 1234
12345 vs 13245
Robert vs Robret
etc...
In short; I need to calculate the similarity and tolerate the input in some ratio...
The Levenshtein distance is a string similarity algorithm you could use.
Google shows me this
I think you might be looking for an Edit Distance algorithm.