algorithm

Algorithms for Simulating Fluid Flow

I've got a game idea that requires some semi-realistic simulation of a fluid flowing around various objects. Think of a pool of mercury on an irregular surface that is being tilted in various directions. This is for a game, so 100% physical realism is not necessary. What is most important is that the calculations can be done in real t...

What is the worst case time complexity for this algorithm?

procedure matrixvector(n:integer); var i,j:integer; begin for i<-1 to n do begin B[i] = 0; C[i] = 0; for j<-1 to i do B[i]<- B[i]+ A[i,j]; for j<-n down to i+1 do C[i]<-C[i] + A[i,j] end end; ...

What would be a good algorithm for a circular reference check in this case?

Given you have the following class (bad C#, but you get the drift): public abstract class AmICircular { // assume Children is never null private List<AmICircular> Children {get;set;} // assume target is never null public void Add(AmICircular target) { target.PerformCircularReferenceCheck(this); Children.Add(target); ...

Fibonacci, Binary, or Binomial heap in c#?

Are there any heap data structure implementations out there, fibonacci, binary, or binomial? Reference: These are data structures used to implement priority queues, not the ones used to allocate dynamic memory. See http://en.wikipedia.org/wiki/Heap_(data_structure) Thanks, Dave ...

Image recognition and 3d rendering

How hard would it be to take an image of an object (in this case of a predefined object), and develop an algorithm to cut just that object out of a photo with a background of varying complexity. Further to this, a photo's object (say a house, car, dog - but always of one type) would need to be transformed into a 3d render. I know there ...

The "Waiting lists problem"

A number of students want to get into sections for a class, some are already signed up for one section but want to change section, so they all get on the wait lists. A student can get into a new section only if someone drops from that section. No students are willing to drop a section they are already in unless that can be sure to get...

What algorithms compute directions from point A to point B on a map?

How do map providers (such as Google or Yahoo! Maps) suggest directions? I mean, they probably have real-world data in some form, certainly including distances but also perhaps things like driving speeds, presence of sidewalks, train schedules, etc. But suppose the data were in a simpler format, say a very large directed graph with edg...

Analyse python list with algorithm for counting occurences over date ranges

The following shows the structure of some data I have (format: a list of lists) data = [ [1,2008-12-01], [1,2008-12-01], [2,2008-12-01] ... (the lists continue) ] The dates range from 2008-12-01 to 2008-12-25. The first field identifies a user by id, the second field (a date field) shows when this user visited a page on my ...

Predictive "blood glucose" algorithm?

I'm writing an app that lets a diabetic user enter his/her "blood glucose" readings, and then charts them on a graph over time from left to right. Since the blood readings will be done only several times a day, an algorithm would be handy to: a) fill in the gaps on the graph between readings (curves would be more realistic than jerky li...

FIFO queue synchronization

Should FIFO queue be synchronized if there is only one reader and one writer? ...

STL __merge_without_buffer algorithm?

Where can I get a decent high-level description of the algorithm used in __merge_without_buffer() in the C++ STL? I'm trying to reimplement this code in the D programming language, with some enhancements. I can't seem to grok what it's doing at the algorithmic level from just reading the STL source code because there are too many low-l...

(ProjectEuler) Sum Combinations

From ProjectEuler.net: Prob 76: How many different ways can one hundred be written as a sum of at least two positive integers? I have no idea how to start this...any points in the right direction or help? I'm not looking for how to do it but some hints on how to do it. For example 5 can be written like: 4 + 1 3 + 2 3 + 1 + 1 2 + 2 + ...

Algorithm for ProjectEuler Problem 99

From http://projecteuler.net/index.php?section=problems&amp;id=99 Comparing two numbers written in index form like 211 and 37 is not difficult, as any calculator would confirm that 211 = 2048 37 = 2187. However, confirming that 632382518061 > 519432525806 would be much more difficult, as both numbers contain ...

Prime factor of 300 000 000 000?

I need to find out the prime factors of over 300 billion. I have a function that is adding to the list of them...very slowly! It has been running for about an hour now and i think its got a fair distance to go still. Am i doing it completly wrong or is this expected?! (Please no solutions for my code to give it away, but some subtle hi...

Which algorithm should I use for signal (sound) one class classification?

Update this question was previously titled as "Give me the name of a simple algorithm for signal(sound) pattern detection" My objective is to detect the presence of a given pattern in a noisy signal. I want to detect the presence of a species of insect recording the sounds with a microphone. I have previously recorded the sound of the ...

String matching

Hello, Let me explain the problem: Let's say I have a library, the library contains many books, each book contains chapters, each chapter contains string (and the string begins and ends with dot "."). The sequence again, library -> book -> chapter -> string. I extracted the strings from books, let's call them "books strings". I have a...

Windows Explorer sort method

Hi all, I'm looking for an algorithm that sorts strings similar to the way files (and folders) are sorted in Windows Explorer. It seems that numeric values in strings are taken into account when sorted which results in something like name 1, name 2, name 10 instead of name 1, name 10, name 2 which you get with a regular string com...

Traversing a tree of objects in c#

I have a tree that consists of several objects where each object has a name (string), id (int) and possibly an array of children, that are of the same type. How do I go through the entire tree and print out all of the ids and names? I'm new to programming and frankly, I'm having trouble wraping my head around this because I don't know h...

Algorithm to find subset within two sets of integers whose sums match

Hi, I'm looking for an algorithm which can take two sets of integers (both positive and negative) and find subsets within each that have the same sum. The problem is similar to the subset sum problem: http://en.wikipedia.org/wiki/Subset-sum_problem except that I'm looking for subsets on both sides. Here's an example: List A {4, 5, 9,...

How to efficiently build a tree from a flat structure ?

Hi, I have a bunch of objects in a flat structure. These objects have an ID and a ParentID property so they can be arranged in trees. They are in no particular order. Each ParentID property does not necessarily matches with an ID in the structure. Therefore their could be several trees emerging from these objects. How would you process...