I encountered this problem when doing some enthusiastic programming. The problem can be expressed as follows:
For a multiset A, let P(A) denote the
set of all possible permutations of A.
P(A) is naturally divided into
disjoint subsets that are equivalence
classes, with the equivalence relation
being "can be related by circ...
I found this description of the batch-fetching algorithm in "Manning - Java Persistence with Hibernate":
What is the real batch-fetching
algorithm? (...) Imagine a batch size of
20 and a total number of 119
uninitialized proxies that have to be
loaded in batches. At startup time,
Hibernate reads the mapping metadata
and c...
I've been working on a graph traversal algorithm over a simple network and I'd like to run it using multiprocessing since it it going to require a lot of I/O bounded calls when I scale it over the full network. The simple version runs pretty fast:
already_seen = {}
already_seen_get = already_seen.get
GH_add_node = GH.add_node
GH_add_e...
A rat is placed in a maze at some unknown position in the maze.
All we can go is in up, down, right or left directions. And we have two methods:
tryMove(<direction>) which returns false if there is a wall and true if we can move.
bool hasLadder(): which returns true if there is a ladder to escape.
We have to write a function explo...
Hi, first question to StackOverflow, please be gentle.
I am trying to find the equation (and then the algorithm for) the center point of three different points on a 2D cartesian plane, given a certain magnitude or "signal strength". These signal strengths are all on a scale relative to each other, but shouldn't necessary be conflated ...
Hello,
I would like to create a function floor(number, step), which acts like :
floor(0, 1) = 0
floor(1, 1) = 1
floor(1, 2) = 0
floor(5, 2) = 4
floor(.8, .25) = .75
What is the better way to do something like that ?
Thanks.
...
Since long back I have not used C or C++ ,so forget completely about Pointers. I'm familiar with C# and have written a basic version of this. Need to know whether I'm doing right/wrong?
Input:Linked List a->b->c->d->e->null
Output: Linked List b->a->d->c->e->null
We have to write code such that memory position is swapped and not the n...
I have a database to access via JDBC which returns around 200k of records I have to consolidate data table style for further processing. I could if that leads to good performance send a few SELECT (Count(...) ...) statements upfront.
What is a good algorithm in Java to compute such a pivot table?
...
Can the SO community shed some light on the recent P != NP proof ( http://www.hpl.hp.com/personal/Vinay_Deolalikar/Papers/pnp12pt.pdf ) by Vinay Deolalikar @ HP
What does the SO community think about it ? I know Scott Aaronson and other smart theorists are on top of it like white on rice, and has been blogging ( http://scottaaronson.c...
I needed to create an algorithm which will (efficiently) take an old array and a new array and give me back the changes between the two (which items added, which removed). It happens to need to be in JavaScript (to run in the browser) but the algorithm's more important than the language.
This is what I came up with: http://jsbin.com/ose...
In two dimensional space, given a bunch of rectangles, every rectangle covers a number of points and there may be overlap between two arbitrary rectangles, for a specified number K, how can i find the k rectangles such that their union cover the maximum number of points?
In this problem, if a point is covered by more than two rectangles ...
Possible Duplicates:
Given a 2d array sorted in increasing order from left to right and top to bottom, what is the best way to search for a target number?
Search a sorted 2D matrix
A time efficient program to find an element in a two dimensional matrix, the rows and columns of which are increasing monotonically. (Rows and co...
I need to implement a lock-free skip list. I tried to look for papers. Unfortunatly all I found was lock-free single linked lists (in many flavors). However how to implement lock-free skip list?
...
Hi SO community!
Problem statement
I have the following problem: I have a circle with a certain number (zero or more) of points on it. These positions are fixed. Now I have to position another set of points on the circle, such as all points together are as evenly distributed around the circle as possible.
Goal
My goal is now to devel...
I am parsing sentences. I want to know the relevant content of each sentence, defined loosely as "semi-unique words" in relation to the rest of the corpus. Something similar to Amazon's "statistically improbable phrases", which seem to (often) convey the character of a book through oddball strings of words.
My first pass was to start ma...
I have built a gameboard that consists of a grid, the grid is then randomly assigned, "Walls" to a cell. Once the cells are built, how can I check to see if a certain cell is 'locked in' so that I don't place a player there.
I have thought about this and the first ago I came up with check all sides for four walls, but obviously, a ce...
Hi,
I'm trying to create 2 linked list with a common intersection node. As I see this is a very hot question in LinkedList to find the intersection node. I have written following code but it throws InvalidOperationexception.
LinkedList<int> LL = new LinkedList<int>();
LL.AddFirst(5);
LL.AddFirst(4);
LL....
Problem Statement:
I have the following problem:
There are more than a billion points in 3D space. The goal is to find the top N points which has largest number of neighbors within given distance R. Another condition is that the distance between any two points of those top N points must be greater than R. The distribution of those point...
What's the most efficient way to identify a binary file? I would like to extract some kind of signature from a binary file and use it to compare it with others.
The brute-force approach would be to use the whole file as a signature, which would take too long and too much memory. I'm looking for a smarter approach to this problem, and I'...
I have a tree defined like,
struct tree {
char label[MAX_LENGTH];
char value[MAX_LENGTH];
struct tree *child;
struct tree *next;
};
Now I need to free the memory allocated by this tree. I wrote the following code.
unsigned int tree_free(struct tree *root)
{
struct tree *current = NULL, *next = NULL, *child = NULL;...