algorithm

Incidence matrix instead of adjacency matrix

What kind of problems on graphs is faster (in terms of big-O) to solve using incidence matrix data structures instead of more widespread adjacency matrices? ...

Greatest GCD between some numbers

Hi, We've got some nonnegative numbers. We want to find the pair with maximum gcd. actually this maximum is more important than the pair! For example if we have: 2 4 5 15 gcd(2,4)=2 gcd(2,5)=1 gcd(2,15)=1 gcd(4,5)=1 gcd(4,15)=1 gcd(5,15)=5 the answer is 5. ...

Grouping individuals into families

We have a simulation program where we take a very large population of individual people and group them into families. Each family is then run through the simulation. I am in charge of grouping the individuals into families, and I think it is a really cool problem. Right now, my technique is pretty naive/simple. Each individual reco...

Calculating pageranks for a sparse directed graph with high percentage of deadlinks

Hi, I am a graduate student in computer science at Indiana University, Bloomington. For one of my research projects, i am working on calculating pageranks for a directed graph which is very sparse and has a high percentage of deadlinks. By deadlinks I mean nodes that have outdegree zero. Sometimes, in a graph with a lot of deadlinks, ...

Object under mouse?

My little game engine basically has a 3D array Cubes[x][y][z] (its actually a big 1D array but I'v done some overloading). I know which cube in X Y Z that the player is standing on. The player will be able to shoot a cube to destroy it which is why I need to figure out how to find the Cube that the mouse is under. I found some OpenGL doc...

given a color and alpha, what color & alpha to add to create a desired color?

If I have a bottom layer color and an alpha value (C&A) and want to create a custom C&A on the screen, what is the function to determine what C&A has to be added as a layer on top of the bottom layer? edit: I want to duplicate photoshop's "normal" mode so that I match a designer's graphic design. For example: BASE LAYER rgb: 255-0-0 ...

Constraint Satisfaction Problem: Choosing real numbers with certain characteristics

I have a set of n real numbers. I also have a set of functions, f_1, f_2, ..., f_m. Each of these functions takes a list of numbers as its argument. I also have a set of m ranges, [l_1, u_1], [l_2, u_2], ..., [l_m, u_m]. I want to repeatedly choose a subset {r_1, r_2, ..., r_k} of k elements such that l_i <= f_i({r_1, r_2, ...,...

How to split a list of items into equal partitions according to the item's weight?

Hi, I have a list of items that is somewhat like this: [ ["orange", 9], ["watermelon", 3], ["grapefruit", 6], ["peach", 8], ["durian", 2], ["apricot", 6] ] I would like to split this list into... say two groups so that the sum of the weights of the items in each group are as equal as possible, i.e.: List 1: orange: 9 ...

Problem 9 (Project Euler) with Java - is it perfect program?

I am new to Java and even OOP, but I tried to write program for this task: A Pythagorean triplet is a set of three natural numbers, a < b < c, for which, a^(2) + b^(2) = c^(2) For example, 3^(2) + 4^(2) = 9 + 16 = 25 = 5^(2). There exists exactly one Pythagorean triplet for which a + b + c = 1000. Find the product abc. I want that y...

How can I optimize my screencasting utility?

I'm developing a screencasting utility in C++. It basically captures desktop frames and creates an AVI file. The algorithm is as follows: Create a thread: this->m_hThread=CreateThread(NULL,0,thScreenCapture,this,0,NULL); Capture desktop in thScreenCapture n times per second (like 5 fps). obj->Capture(); In Capture(), append the bitm...

How to replace inadmissible solutions?

Hi, I'm building a genetic algorithm to maximize a mathematical function. The initial population is randomly selected, lets say of 20 individuals. The best is kept for the next generation. 18 tournaments are made so that afterwards individuals can be randomly selected to form nine pairs. From the nine pairs, nine children are 'born'. H...

Algorithm to remove vocal from sound track

Hi, I want to remove vocals from mp3 sound tracks. I searched google, and tried few softwares but none of them are convincing. I am planning to read the mp3 file, get a waveform and remove the waveform that is above a specified limit. do you have any suggestions on how to proceed. -- Update I just want code that can read mp3 file for...

Bullet algorithm having trouble with rotation on the X

Here is what I'm trying to do. I'm trying to make a bullet out of the center of the screen. I have an x and y rotation angle. The problem is the Y (which is modified by rotation on the x) is really not working as intended. Here is what I have. float yrotrad, xrotrad; yrotrad = (Camera.roty / 180.0f * 3.141592654f); xrotrad = (...

How to determine the complexity of an algorithm function?

How do you know if a algorithm function takes linear/constant/logarithmic time for a specific operation? does it depend on the cpu cycles? ...

select equal sized number groups from a sequence of random numbers

say i have a list of 100 numbers, i want to split them into 5 groups which have the sum within each group closest to the mean of the numbers. the simplest solution is to sort the hundred numbers and take the max number and keep adding the smallest numbers until the sum goes beyond the avg. obviously that is not going to bring the best...

sequence comparison with moved blocks detection

I need to compare 2 sequences and find an edit distance. Edits can include deletion and insertion operations (with modification weight 1 per symbol), and block move operations (with weight 0.1 per symbol) For example: A B C D E F G H F G H A B C Y D X E Block FGH was moved here. Is there any existing algorithm to solve this task efficien...

Duplicated strings in a 3TB TXT file

Say there is a 3TB TXT file, in which every line is a string, how to find those duplicated strings in them? It's an interview question from a friend of mine. We'd better make those questions clear enough after an interview, in case of the next one. PS: If I'm the interviewee, I will tell the interviewer: How can you guys store so many s...

Show the step to find the total operations of the algorithm

Bellow is some Java code for the question: int total1 = 0; int total2 = 0; for (int x = 0; x <= n; x++) total1 = total1 + x; for (int y = 1; y < n; y++) total2 += total1 * y; Based on the question above, I do an answer likes bellow. Please help me check my answer right or wrong. Thanks for your helping. Operation Numbe...

Truth table as the keys for a dictionary

I have six boolean flags that are independent of each other so there are 64 possible combinations. These flags should determine the value of some string. This string can have seven different values. I think implementing this as a large if-statement is a bad idea so I thought of creating a truth table where each combination determines a s...

Time blocks allocation Algorithm, Private Teacher->Student relationship, maximize number of classes to be given

Hello guys! The situation is the following. I'm a private teacher with dozens of students. I have some restrictions on my time (for example I can't teach at friday afternoons) and students also have many restrictions on their time. Based on that, I'm trying to create my agenda in a way that I can do as many private lessons as possible ...