I was thinking about ways to solve this other question about counting the number of values whose digits sum to a target, and decided to try the case where the range was of the form [0, n^base). So essentially you get N independent digits to work with, which is a simpler problem.
The number of ways N natural numbers can sum to a target T...
For an array of size N, what is the # of comparisons required?
...
I have searched Google and Stackoverflow for this question, but I still don't understand how a minimax function works.
I found the wikipedia entry has a pseudocode version of the function:
function integer minimax(node, depth)
if node is a terminal node or depth <= 0:
return the heuristic value of node
α = -∞
for ch...
I'm trying to find the most efficient way to check if 2 arbitrarily sized cubes collide with each other. The sides of the cubes are not necessarily all equal in length (a box is possible). Given these constraints, how could I efficiently check if they collide? (each box has 24 verticies) Thanks
They are axis alligned
...
for i := 1 to n do
j := 2;
while j < i do
j := j^4;
I'm really confused when it comes to Big-O notation, so I'd like to know if it's O(n log n). That's my gut, but I can't prove it. I know the while loop is probably faster than log n, but I don't know by how much!
Edit: the caret denotes exponent.
...
Possible Dup: Help Me Figure Out A Random Scheduling Algorithm using Python and PostgreSQL
Let's say you have a division with 9 teams, and you want them to play 16 games each. Usually you would want to have 8 games (Home), and 8 games (Visitor). Is there a known algorithm to go in and assign the matches, randomly?
Note -> It can, somet...
How can we remove the median of a set with time complexity O(log n)? Some idea?
...
How does it work? Please explain in enough detail in English or pseudocode so that I can implement in any language.
It is mentioned and briefly described in this paper:
http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.4.3643&rep=rep1&type=pdf
but there isn't enough detail there to implement myself. (the weights in Fig...
I'm developing an application where entities are located at positions on Earth. I want to have a set of data from which I can determine what region(s) a point is contained within.
Regions may be of types:
Continent
Country
Lake
Sea
DMZ
Desert
Ice Shelf
...and so forth.
I'm envisioning representing each region as a polygon. For an...
I was wondering if anyone knows of a graph-theoretic algorithm that provides a metric for determining the pairwise similarity between paths through a directed graph? I imagine the simplest algorithms/metrics just counts the number of nodes common to both paths and does some sort of weighting in the case of comparing paths of different le...
I've got a path that is made up of multiple points - i.e. 0,0 0,50 50,50 70,20
If I just draw this line on the screen it looks quite harsh as it puts a sharp angle at the joining of each point.
Hence I was wondering what the bezier curves algorithm/method would look like which I could call that automatically change the sharp angles ...
Here's my solution to Project Euler problem #5:
#include <stdio.h>
#include <stdint.h>
#define N 20
int main( int argc, char* argv[] )
{
uint64_t r = 1;
uint64_t i, j;
for( i = 2; i <= N; ++i )
if( (j = r%i) )
r *= ( (i%j) ? i : (i/j) );
printf( "\n%llu\n", r );
return 0;
}
It is of O(n) efficiency. ...
I'd like an efficient method for doing the inplace union of a sorted vector with another sorted vector. By inplace, I mean that the algorithm shouldn't create a whole new vector or other storage to store the union, even temporarily. Instead, the first vector should simple grow by exactly the number of new elements.
Something like:
vo...
A cow is standing in front of an infinite fence . On the other side is grass. The cow wants to get to this grass. Somewhere along this fence is a hole through which the cow can get to the other side. The distance d from the cow to the hole has a probability distribution f(d) associated with it i.e. the probability that the hole is k step...
I'm working on a project that involves diverting phone calls to a number of destinations.
For example, I want:
10% of calls to go to destination A
20% of calls to go to destination B
30% of calls to go to destination C
40% of calls to go to destination D
The number of destinations and their percentages must be configurable.
I've ...
I want to run some analysis on networked data having multiple modes(i.e. multiple types of network nodes) and multiplex relations(i.e. multiples types of network edges).
The analysis is probably about SNA or applying any algorithm from graph theory, e.g. tie strength, centrality, betweenness, node distance, block, cluster, etc.
The sou...
I need to write a program to analyze the performance of computer systems and networks using queuing theory (http://en.wikipedia.org/wiki/Queueing_theory). I was wondering if there is an open source Java library implementing the various algorithms of queuing theory that can make my task easier.
Does anyone have any recommendations?
...
Is there an algorithm that will allow me to traverse a weighted graph in the following manner?
Start at a specific node
Go through all vertecies in the graph
Do this in the least amount of time (weights are times)
End up at the starting node
...
There are several questions on Stack Overflow discussing how to find the Greatest Common Divisor of two values. One good answer shows a neat recursive function to do this.
But how can I find the GCD of a set of more than 2 integers? I can't seem to find an example of this.
Can anyone suggest the most efficient code to implement this ...
Generally speaking, can you suggest an approach which would let me test objects to make sure they are alike.
Accept that objects are alike if over 'n%' worth of content of the object is identical.
Other then a brute force, are there any libraries available i can take advantage of?
thanks
...