People can chose up to 5 of 25 lectures in advance. All these lectures are given on one day in five rooms at five time slots. Each (preferred) lecture a listener can attend to makes her a bit happier, each lecture he chose but can't attend to (because another preferred lecture is in the same time slot) makes him a bit unhappier. The list...
Hi,
There is a data set of "file" - name of file, and 32bit number is following after it - something like hash for the file.
"file1" 6a9bd9a6 1df3b24b 7ab054dc
"file2" 6a9bd54e 1df3b24b 8cd054dc
"file3" 6a9bd9a6 7ab054dc
How am I going to get unique files so s2 is not a prefix of any other s2 - that means the number is unique. If the...
/**
* Returns a number between kLowerBound and kUpperBound
* e.g.: Wrap(-1, 0, 4); // Returns 4
* e.g.: Wrap(5, 0, 4); // Returns 0
*/
int Wrap(int const kX, int const kLowerBound, int const kUpperBound)
{
// Suggest an implementation?
}
...
I have an array of objects. the objects have a Boolean value in them that I want to use as a key for sorting the array (all objects with true come before all objects with false) but otherwise leave things in the same order.
Is there a simple, in-place, O(n) solution to this? Maybe some variant of radix-sort?
...
Who can recommend me a good sweep algorithm which would have good results for double data?
Some documentation, methods, anything.
This is a sweep algorithm for detecting the intersection points of a graph in the 2-dimensional space. The graph is always closed.
...
Given a graph of n nodes that are all interconnected on a coordinate plane, what's the best way to find a subtree of minimal distance that contains m nodes?
The only solution I've found to this problem is to generate all combinations of the nodes to connect and attempt to connect these nodes via either Kruskal's or Prim's algorithm whil...
First of all this is tough thing to solve, so far I didn't come up with a good example but I hope someone here will figure this out. I hope there is known way to solve these kind of problems, or an obscure algorithm.
Scenario:
In my application I do several requests to the very same webpage
Webpage has dynamic and random content in it...
Say I have a bunch of objects with dates and I regularly want to find all the objects that fall between two arbitrary dates. What sort of datastructure would be good for this?
...
I have two lists containing x-y coordinates (of stars). I could also have magnitudes (brightnesses) attached to each star. Now each star has random position jiggles and there can be a few extra or missing points in each image. My question is, "What is the best 2D point matching algorithm for such a dataset?" I guess both for a simple lin...
Say I have nodes connected in the below fashion, how do I arrive at the number of paths that exist between given points, and path details?
1,2 //node 1 and 2 are connected
2,3
2,5
4,2
5,11
11,12
6,7
5,6
3,6
6,8
8,10
8,9
Find the paths from 1 to 7:
Answer:
2 paths found and they are
1,2,3,6,7
1,2,5,6,7
implementation found here...
Hey all,
I'm trying to build my own prediction market, and I'm thinking about algorithms. That is to say, how to adjust the price of a contract based on the amount of call and put orders. The basic algorithm I am using now is of two kinds:
For yes/no events (i.e., either the events happens or doesn't) I am just taking the percentage o...
Hello all
Im very interested in text analysis, where can I start leaning about the subject?
Algorithms and stuff for beginners?
...
I wondering about how serial number generators and validator work. My aim would be to generate a serial number with five parts consisting of numbers and letters only.
I enjoy coding as a hobby and would not call myself a professional programmer. However, I am very interested in how those interesting functions work technically to broaden...
I was looking at the Wikipedia entry for Prim's algorithm and I noticed that its time complexity with an adjacency matrix is O(V^2) and its time complexity with a heap and adjacency list is O(E lg(V)) where E is the number of edges and V is the number of vertices in the graph.
Since Prim's algorithm is used in denser graphs, E can appro...
I've a panel of size X by Y. I want to place up to N rectangles, sized randomly, upon this panel, but I don't want any of them to overlap. I need to know the X, Y positions for these rectangles.
Algorithm, anyone?
Edit: All the N rectangles are known at the outset and can be selected in any order. Does that change the procedure?
...
So, I understand the problem of finding the longest simple path in a graph is NP-hard, since you could then easily solve the Hamiltonian circuit problem by setting edge weights to 1 and seeing if the length of the longest simple path equals the number of edges.
My question is: What kind of path would you get if you took a graph, found t...
Guys I'm having major trouble understanding recursion at school. Whenever the prof is talking about it I seem to get it but as soon as I try it on my own it completely blows my brains. I was trying to solve Towers of Hanoi all night and completely blew my mind. My textbook has only about 30 pages in recursion so it is not too useful. Doe...
Can someone explain Breadth-first search to solve the below kind of problems
I need to find all the paths between 4 and 7
...
I've got 4 text files, 2 of them contains a keyword which other 2 text files don't.
What's the fastest way/algorithm to find this "keyword" shared in the first 2 text files but don't exist in the other 2 files?
I can think of really slow ways such as go word by word and then search with IndexOf etc. But sounds like it's going to be r...
Ok, someone tell me which would be better. I need to |= the elements of one vector with another. That is, I want to
void orTogether(vector<char>& v1, const vector<char>& v2)
{
typedef vector<char>::iterator iter;
for (iter i = v1.begin(), iter j = v2.begin() ; i != v1.end(); ++i, ++j)
*i |= *j;
}
I can't use for_each d...