algorithm

Create a "pairing" from a graph?

This problem smells like there should be an answer in graph theory, but it doesn't exactly match any of the graph theory problems I know. (Note: this is actually a real-world problem, fictionalized for easier reading) Imagine that I have a even-numbered group of Chess players at my house. I have plenty of tables and chess sets for every...

Algorithm to pick values from set to match target value?

I have a fixed array of constant integer values about 300 items long (Set A). The goal of the algorithm is to pick two numbers (X and Y) from this array that fit several criteria based on input R. Formal requirement: Pick values X and Y from set A such that the expression X*Y/(X+Y) is as close as possible to R. That's all there is to ...

Stable separation for two classes of elements in an array

Consider the following problem. We are given an array of elements belonging to one two classes: either red or blue. We have to rearrange the elements of the array so that all blue elements come first (and all red elements follow). The rearrangement must be done is stable fashion, meaning that the relative order of blue elements must be ...

Single dimension peak fitting

I have a single dimensional array of floating point values (c# doubles FYI) and I need to find the "peak" of the values ... as if graphed. I can't just take the highest value, as the peak is actually a plateau that has small fluctuations. This plateau is in the middle of a bunch of noise. I'm looking find a solution that would give me t...

Implementation of any Hamiltonian Path Problem algorithm

Hi all ! Here is my problem : I have an array of points, the points have three properties : the "x" and "y" coordinates, and a sequence number "n". The "x" and "y" are defined for all the points, the "n" are not. You can access and write them calling points[i]->x, points[i]->y, points[i]->n. i.e. : points[i]->n = var var = points[i]-...

Automatic images translation to 3d model

I'm quite interested in automatic images translation to 3d models. Not really for commercial product, but from the point of possible academic research and implementation. What I'd like to achieve is almost transparent for user process of transformation series of images (fewer is better) to 3d model which might be shown in flash/silverli...

How does pattern matching work behind the scenes in F#?

Hello Everyone, I am completely new to F# (and functional programming in general) but I see pattern matching used everywhere in sample code. I am wondering for example how pattern matching actually works? For example, I imagine it working the same as a for loop in other languages and checking for matches on each item in a collection. Th...

help in the Donalds B. Johnson's algorithm, i cannot understand the pseudo code

Hi , does anyone know the Donald B. Johnson's algorithm which enumerates all the elementary circuits (cycles) in a Directed graph? link text I have the paper he had published in 1975 but I cannot understand the pseudo-code. My goal is to implement this algorithm in Java. Some questions I have is for example what is the matrix Ak i...

Algorithms FPGAs dominate CPUs on

Hi! For most of my life, I've programmed CPUs; and although for most algorithms, the big-Oh running time remains the same on CPUs / FPGAs, the constants are quite different (for example, lots of CPU power is wasted shuffling data around; whereas for FPGAs it's often compute bound). I would like to learn more about this -- anyone know o...

what is the easiest way to do this function in c# ?

Hello let say that we have an array [5,5] 01,02,03,04,05 06,07,08,09,10 11,12,13,14,15 16,17,18,19,20 21,22,23,24,25 the user should send 2 values to the function (start,searchFOR) for example (13,25) the function should search for that value in this way 07,08,09 12, ,14 17,18,19 if the value is n't found in this level it will go...

How to detect generation loss of a transcoded audio.

Lets say you have a 96 kbit mp3 and you Transcode the file into a 320 kbit mp3. How could you programmatically detect the original bit rate or quality? Generation loss is created because each time a lossy algorithm is applied new information will be deemed "unnecessary" and is discarded. How could an algorithm use this property to det...

complexity of algorithms

I have question what is complexity of this algorithm public class smax{ public static void main(String[]args){ int b[]=new int[11]; int a[]=new int[]{4,9,2,6,8,7,5}; for (int i=0;i<b.length;i++){ b[i]=0; } int m=0; while (m<b.length) { int k=a[0]; for (int i=0;i<a.len...

Faster way to compare two sets of points in N-dimensional space?

List1 contains a high number (~7^10) of N-dimensional points (N <=10), List2 contains the same or fewer number of N-dimensional points (N <=10). My task is this: I want to check which point in List2 is closest (euclidean distance) to a point in List1 for every point in List1 and subsequently perform some operation on it. I have been do...

How to get it working in O(n)?

Possible Duplicate: Interview Q: given an array of numbers, return array of products of all other numbers (no division) I came across an interview task/question that really got me thinking ... so here it goes: You have an array A[N] of N numbers. You have to compose an array Output[N] such that Output[i] will be equal to mul...

question about merge algorithm

hi i have question i know that this question is somehow nonsense but let see i have code to merge two sorted array in a one sorted array here is code in java public class Merge { public static void main(String[]args){ int a[]=new int[]{7,14,23,30,35,40}; int b[]=new int[]{5,8,9,11,50,67,81}; int c[]=new in...

Algorithm to fill slots

I am searching for an algorithm to fill several slots, which are already filled to some level. The current levels and the available quantity to fill are known Resulting levels should be as equal as possible, but existing level cannot be reduced Slots are filled from left to right, so left slots get higher level if equal level is imposs...

Peterson algorithm in Java?

Is there example implementation of Peterson algorithm for mutual exclusion in Java? ...

Interesting task using random numbers only

Given any number of the random real numbers from the interval [0,1] is there exist any method to construct a floating point number with zero fractional part? Your algorithm can use only random() function calls and no variables or constants. No constants and variables are allowed, no type casting is allowed. You can use for/while, if/el...

How to calculate the y-pixels of someones weight on a graph? (math+programming question)

I'm not that smart like some of you geniuses. I need some help from a math whiz. My app draws a graph of the users weight over time. I need a surefire way to always get the right pixel position to draw the weight point at for a given weight. For example, say I want to plot the weight 80.0(kg) on the graph when the range of weights is ...

flashsort algorithm

here is article about FlashSort http://en.wikipedia.org/wiki/Flashsort can anybody help me how to implement i need only steps not code for example i have some numbers (3,8,4,6,9,12,10,11} please help how to sort it by flashsort? i know this site where is explained flashsort but this code is difficult for me to implement in java SUB...