algorithm

What is the best way to compute trending topics or tags?

Many sites offer some statistics like "The hottest topics in the last 24h". For example, Topix.com shows this in its section "News Trends". There, you can see the topics which have the fastest growing number of mentions. I want to compute such a "buzz" for a topic, too. How could I do this? The algorithm should weight the topics which a...

Is a kd-tree suitable for 4D space-time data (x,y,z,time)?

I want to use a data structure for sorting space-time data (x,y,z,time). Currently a processing algorithm searches a set of 4D (x,y,z,time) points, given a spherical (3d) spacial radius and a linear (1d) time radius, marking for each point, which other points are within those radii. The reason is that after processing, I can ask any 4D ...

Liquefy filter/iwarp

I'm trying to build something like the Liquefy filter in Photoshop. I've been reading through image distortion code but I'm struggling with finding out what will create similar effects. The closest reference I could find was the iWarp filter in the Gimp but the code for that isn't commented at all. I've also looked at places like ImageM...

An array stack algorithm without copy

I have a flashlite3 application with navigation consisting of icons the user can browse left or right through infinitely. The basic algorithm i'm using now works (and is adequate for this project) however, part of the solution depends on a duplicate of the array of icons. Depending on the number of items in the array, and/or the size of...

finding substrings in python

hi, Can you please help me to get the substrings between two characters at each occurrence For example to get all the substrings between "Q" and "E" in the given example sequence in all occurrences: ex: QUWESEADFQDFSAEDFS and to find the substring with minimum length. ...

Fastest way to find minimum distance between points

I have a set of 2D points and need to find the fastest way to figure out which pair of points has the shortest distance in the set. What is the optimal way to do this? My approach is to sort them with quicksort and then calculate the distances. This would be O(nlogn + n) = O(nlogn). Is it possible to do it in linear time? Thanks. ...

What is a good local heuristic for dynamic discrete node flow control?

Suppose you have a set of nodes. Some nodes are producers, some are consumers, and some are routers. Each node has a maximum throughput which defines the maximum number of units it can accept per day, and also the maximum number of units it can send per day (in this case accepts and sends do not interfere with each other). Each node also...

Expressing an integer as a series of multipliers

Scroll down to see latest edit, I left all this text here just so that I don't invalidate the replies this question has received so far! I have the following brain teaser I'd like to get a solution for, I have tried to solve this but since I'm not mathematically that much above average (that is, I think I'm very close to average) I ca...

How do I find the shortest path that covers all nodes in a directed cyclic graph?

I need an example of the shortest path of a directed cyclic graph from one node (it should reach to all nodes of the graph from a node that will be the input). Please if there is an example, I need it in C++, or the algorithm. Thanks very much......... ...

Segment tree java implementation

Do you know a good implementation of a (binary) segment tree in Java? ...

What's wrong with my KD-Tree? (K=2)

More specifically, there's something wrong with my nearest neighbor search. I've confirmed that the tree is built correctly, and that all the helper functions work as expected. Note this differs slightly from standard KD-trees in that I'm looking for the closest 3 points. struct Node { unsigned int axis; Point* obj; struct Node* left...

How can i perform an insertion sort but check a property of the element in the array not just the element?

Sorry, I'm sure this is simple but I'm tired and can't figure it out. I have an array of elements, each element is in fact a particle which is a data structure (a struct in c) containing, among other things the particles current position (int x,y,z). I want to compare the elements x position not just the element itself. Looking at the...

Problem in understanding problem 31 of Project Euler?

Hi, Could anyone please explain me problem 31 of project euler more clearly please. My English is not good, I really don't understand problem clearly. Is the problem saying to calculate the coins in any order like: 2*£1 or perhaps 1×£1 + 1×50p + 2×20p + 1×5p + 1×2p + 3×1p Thanks in advance for your time and suggestion. ...

NP-Hard? Algorithmic complexity of online poker collusion detection?

What's the best way to describe the algorithmic complexity of collusion detection for a ten-million-player online poker site? Assume (I don't think these assumptions make much difference so feel free to ignore them, but just to clarify): That the site has 10,000,000 registered users. That these players have played a total of 5 billion...

Statistical estimation algorithm

I'm not sure if this question is appropriate for Stack Overflow but I'll give it a try anyway. I have some data as follows: I also have another set of data that I believe follows a similar distribution but I only know the total percent (e.g. 30% rather than 17%.) Can anyone suggest an algorithm to estimate the %s for each individual t...

Iterating over a Binary Tree with O(1) Auxiliary Space

Is it possible to iterate over a binary tree in O(1) auxiliary space (w/o using a stack, queue, etc.), or has this been proven impossible? If it is possible, how can it be done? Edit: The responses I've gotten about this being possible if there are pointers to parent nodes are interesting and I didn't know that this could be done, but...

Whats the most efficient method for transitioning between two images (Like Mac wallpaper change)

I'm working on a wallpaper application. Wallpapers are changed every few minutes as specified by the user. The feature I want is to fade in a new image while fading out the old image. Anyone who has a mac may see the behavior I want if they change their wallpaper every X minutes. My current thoughts on how I would approach this is ...

How to round floats to integers while preserving their sum?

Let's say I have an array of floating point numbers, in sorted (let's say ascending) order, whose sum is known to be an integer N. I want to "round" these numbers to integers while leaving their sum unchanged. In other words, I'm looking for an algorithm that converts the array of floating-point numbers (call it fn) to an array of integ...

Algorithm to find the smallest non negative integer that is not in a list

Given a list of integers, how can I best find an integer that is not in the list? The list can potentially be very large, and the integers might be large (i.e. BigIntegers, not just 32-bit ints). If it makes any difference, the list is "probably" sorted, i.e. 99% of the time it will be sorted, but I cannot rely on always being sorted. ...

are they adding copy_if to c++0x?

It's very annoying that copy_if is not in C++. Does anyone know if it will be in C++0x? ...