tagged [algorithm]

Name of a particular algorithm

Name of a particular algorithm I'm trying to determine the name of the algorithm which will determine if a set of blocks listed as Xl,Yl-X2Y2 are part of a contiguous larger block. I'm just really loo...

28 Nov at 17:31

Random playlist algorithm

Random playlist algorithm I need to create a list of numbers from a range (for example from x to y) in a random order so that every order has an equal chance. I need this for a music player I write in...

1 Dec at 20:57

Bubble sort worst case example is O(n*n), how?

Bubble sort worst case example is O(n*n), how? I am trying Bubble sort. There are 5 elements and array is unsorted. Worst case for bubble sort shuold be O(n^2). As an exmaple I am using A = {5, 4, 3, ...

20 Dec at 01:24

Mapping a range of values to another

Mapping a range of values to another I am looking for ideas on how to translate one range values to another in Python. I am working on hardware project and am reading data from a sensor that can retur...

28 Dec at 15:53

What is the fastest way to count the unique elements in a list of billion elements?

What is the fastest way to count the unique elements in a list of billion elements? My problem is not usual. Let's imagine few billions of strings. Strings are usually less then 15 characters. In this...

13 Jan at 01:19

Efficient Cartesian Product algorithm

Efficient Cartesian Product algorithm Can somebody please demonstrate for me a more efficient Cartesian product algorithm than the one I am using currently (assuming there is one). I've looked around ...

Are unescaped user names incompatible with BNF?

Are unescaped user names incompatible with BNF? I've got a (proprietary) output from a software that I need to parse. Sadly, there are unescaped user names and I'm scratching my hairs trying to know i...

Rotating a point about another point (2D)

Rotating a point about another point (2D) I'm trying to make a card game where the cards fan out. Right now to display it Im using the Allegro API which has a function: so with this I can make my fan ...

13 Feb at 23:15

Facial recognition/merging software

Facial recognition/merging software Can anyone point me in the right direction of some facial recognition libraries & algorithms ? I've tried searching/googling but i mostly find thesises and very lit...

16 Feb at 12:34

Check if any item in a list matches any item in another list

Check if any item in a list matches any item in another list A coleague asked me to write a one-liner to replace the following method: ``` public static bool IsResourceAvailableToUser(IEnumerable reso...

24 Mar at 13:46

List all possible combinations of k integers between 1...n (n choose k)

List all possible combinations of k integers between 1...n (n choose k) Out of no particular reason I decided to look for an algorithm that produces all possible choices of k integers between 1...n, w...

13 Apr at 14:10

.NET Geometry Library

.NET Geometry Library Does anyone know of a good (efficient, nice API, etc.) geometry open source library for .NET? Some of the operations needed: - - `float``double`- - - - - `float``double`- - -

17 Apr at 20:59

Algorithm for Source Control System?

Algorithm for Source Control System? I need to write a simple source control system and wonder what algorithm I would use for file differences? I don't want to look into existing source code due to li...

18 Apr at 06:41

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...

19 Apr at 10:40

Most efficient algorithm for merging sorted IEnumerable<T>

Most efficient algorithm for merging sorted IEnumerable I have several huge . Theses lists are manipulated as `IEnumerable` but are . Since input lists are sorted, it should be possible to merge them ...

Stack and Hash joint

Stack and Hash joint I'm trying to write a data structure which is a combination of Stack and HashSet with fast push/pop/membership (I'm looking for constant time operations). Think of Python's Ordere...

7 May at 21:51

Generate 2D cross-section polygon from 3D mesh

Generate 2D cross-section polygon from 3D mesh I'm writing a game which uses 3D models to draw a scene (top-down orthographic projection), but a 2D physics engine to calculate response to collisions, ...

9 May at 11:27

What guarantees are there on the run-time complexity (Big-O) of LINQ methods?

What guarantees are there on the run-time complexity (Big-O) of LINQ methods? I've recently started using LINQ quite a bit, and I haven't really seen any mention of run-time complexity for any of the ...

Genetic Programming in C#

Genetic Programming in C# I've been looking for some good genetic programming examples for C#. Anyone knows of good online/book resources? Wonder if there is a C# library out there for Evolutionary/Ge...

Average function without overflow exception

Average function without overflow exception .NET Framework 3.5. I'm trying to calculate the average of some pretty large numbers. For instance: ``` using System; using System.Linq; class Program { s...

24 May at 18:6

What is the best way to find the digit at n position in a decimal number?

What is the best way to find the digit at n position in a decimal number? ### Background I'm working on a symmetric rounding class and I find that I'm stuck with regards to how to best find the number...

27 May at 17:49

traveling salesman problem, 2-opt algorithm c# implementation

traveling salesman problem, 2-opt algorithm c# implementation Can someone give me a code sample of 2-opt algorithm for traveling salesman problem. For now im using nearest neighbour to find the path b...

28 May at 10:54

how to develop a program to minimize errors in human transcription of hand written surveys

how to develop a program to minimize errors in human transcription of hand written surveys I need to develop custom software to do surveys. Questions may be of multiple choice, or free text in a very ...

Split String into smaller Strings by length variable

Split String into smaller Strings by length variable I'd like to break apart a String by a certain length variable. It needs to bounds check so as not explode when the last section of string is not as...

9 Jun at 21:15

Doubling a number - shift left vs. multiplication

Doubling a number - shift left vs. multiplication What are the differences between and ``` int size = length

17 Jun at 07:38

algorithm challenge: merging date range

algorithm challenge: merging date range I'm facing an interesting problem: - - Is it possible to "des-overlap" theses ranges? That is, to generate: - - Maybe I can make this a bit more graphical. This...

Asymptotically Fast Associative Array with Low Memory Requirements

Asymptotically Fast Associative Array with Low Memory Requirements Ok, tries have been around for a while. A typical implementation should give you O(m) lookup, insert and delete operations independen...

26 Jul at 14:51

C# hashcode for array of ints

C# hashcode for array of ints I have a class that internally is just an array of integers. Once constructed the array never changes. I'd like to pre-compute a good hashcode so that this class can be v...

4 Aug at 10:45

Recommended Open Source C# algorithms & data structures libraries

Recommended Open Source C# algorithms & data structures libraries What algorithms libraries can you recommend? The basic criteria are: - - - Algorithms libraries I have used and can recommend: - [Quic...

7 Aug at 13:57

Calculate coordinates of a regular polygon's vertices

Calculate coordinates of a regular polygon's vertices I am writing a program in which I need to draw polygons of an arbitrary number of sides, each one being translated by a given formula which change...

8 Aug at 23:19

I need an optimal algorithm to find the largest divisor of a number N. Preferably in C++ or C#

I need an optimal algorithm to find the largest divisor of a number N. Preferably in C++ or C# I am currently using the following code but its very slow for large numbers ``` static int divisor(int nu...

23 Aug at 06:47

Reversible shuffle algorithm using a key

Reversible shuffle algorithm using a key How would I code a reversible shuffle algorithm in C# which uses a key to shuffle and can be reversed to the original state? For instance, I have a string: "He...

29 Aug at 23:24

selection based on percentage weighting

selection based on percentage weighting I have a set of values, and an associated percentage for each: a: 70% chance b: 20% chance c: 10% chance I want to select a value (a, b, c) based on the percent...

7 Sep at 02:52

What is the most efficient pattern/algorithm to compare two lists and find the delta between those two lists?

What is the most efficient pattern/algorithm to compare two lists and find the delta between those two lists? We have two lists, let's say students and their scores. I want to compare these two lists ...

10 Sep at 21:4

C# Diff Algorithm for Text

C# Diff Algorithm for Text I'm looking for a diff algorithm that will produce results like SO's edit revisions page. I've more or less just started looking and I'm not opposed to doing it myself but I...

23 Sep at 12:33

Implementing a sparse array in C# / fastest way to map integer to a specific bucket/range number

Implementing a sparse array in C# / fastest way to map integer to a specific bucket/range number My initial problem is that I need to implement a very fast, sparse array in C#. Original idea was to us...

26 Sep at 14:17

C# implementation of Google's 'Encoded Polyline Algorithm'

C# implementation of Google's 'Encoded Polyline Algorithm' Does anyone have a concise and robust implementation of Google's [Encoded Polyline Algorithm](http://code.google.com/apis/maps/documentation/...

4 Oct at 02:37

In C# is it a good practice to use recursive functions in algorithms?

In C# is it a good practice to use recursive functions in algorithms? In many functional languages using a recursion is considered to be a good practice. I think it is good because of the way compiler...

What's the fastest way to compare two arrays for equality?

What's the fastest way to compare two arrays for equality? I have two arrays of objects which are likely to have the same values, but in a different order, e.g. I wish to treat these two arrays as equ...

11 Nov at 09:50

How to compute frequency of data using FFT?

How to compute frequency of data using FFT? I want to know the frequency of data. I had a little bit idea that it can be done using FFT, but I am not sure how to do it. Once I passed the entire data t...

Overriding GetHashCode

Overriding GetHashCode As you know, GetHashCode returns a semi-unique value that can be used to identify an object instance in a collection. As a good practice, it is recommended to override this meth...

Faster Algorithm for string comparing in c#

Faster Algorithm for string comparing in c# I have two sentences that needed to be compared to each-other. The final result is how much percent one sentence contains in the other, my problem is that I...

24 Nov at 15:0

How to prove that a problem is NP complete?

How to prove that a problem is NP complete? I have problem with scheduling. I need to prove that the problem is NP complete. What can be the methods to prove it NP complete?

27 Nov at 22:30

Generate large prime number with specified last digits

Generate large prime number with specified last digits Was wondering how is it possible to generate 512 bit (155 decimal digits) prime number, last five decimal digits of which are specified/fixed (eg...

4 Dec at 17:32

How is a random number generated at runtime?

How is a random number generated at runtime? Since computers cannot pick random numbers(can they?) how is this random number actually generated. For example in C# we say, What happens inside?

.NET library for text algorithms?

.NET library for text algorithms? Do you know any .NET library for text algorithms?? Especially I'm interested in strings match, and full-text-search algorithms like - - - I know the one I have mentio...

C#: Seeking PNG Compression algorithm/library

C#: Seeking PNG Compression algorithm/library I need to compress or at least drop the quality of some png images that users are uploading to my site. I already resized it but that doesn't do much for ...

23 Dec at 15:35

Sparse O(1) array with indices being consecutive products

Sparse O(1) array with indices being consecutive products I'd like to pre-calculate an array of values of some unary function `f`. I know that I'll only need the values for `f(x)` where `x` is of the ...

16 Jan at 22:5

Shuffle string c#

Shuffle string c# I want to know shuffle string string I would be able to get:

19 Jan at 19:48

Detect a specific frequency/tone from raw wave-data

Detect a specific frequency/tone from raw wave-data I am reading a raw wave stream coming from the microphone. (This part works as I can send it to the speaker and get a nice echo.) For simplicity let...

27 Jan at 06:52