Here's my scenario. Consider a set of events that happen at various places and times - as an example, consider someone high above recording the lightning strikes in a city during a storm. For my purpose, lightnings are instantaneous and can only hit certain locations (such as high buildings). Also imagine each lightning strike has a uniq...
Questions
Is there a best value to stay on so that I win the greatest percentage of games possible? If so, what is it?
Edit: Is there an exact probability of winning that can be calculated for a given limit, independent of whatever the opponent does? (I haven't done probability & statistics since college). I'd be interested in seeing t...
Can you recommend me a book or (better!) a site with many hard problems and exercises about data structures?
I'm already answering project Euler questions, but these questions are about interesting, but uncommon algorithms. I hardly used even a simple tree. Maybe there is a site with exercises like: hey, you need to calculate this: ... ...
Hello,
What is the most common way to get 4 Orientaton maps at 0, 45, 90 and 135 angles from Image.
I want to apply orientation kernels. Is that good solution ?
for 0 orientation
-1 -1 -1
2 2 2
-1 -1 -1
for 45 orientation
-1 -1 2
-1 2 -1
2 -1 -1
for 90 orientation
-1 2 -1
-1 2 -1
-1 2 -1
for 135 orientation
2 -1 -1
-1 2 -1
-1 -...
I have an N*N matrix (N=2 to 10000) of numbers that may range from 0 to 1000.
How can I find the largest (rectangular) submatrix that consists of the same number?
Examples:
or
10 9 9 9 80
5 9 9 9 10
85 86 54 45 45
15 21 5 1 0
5 6 88 11 10
The output should be the area of the submatrix, followed by 1-based coordinates ...
Hi,
I've used an array as hash table for hashing alogrithm with values:
int[] arr={4 , 5 , 64 ,432 };
and keys with consective integers in array as:
int keys[]={ 1 , 2 , 3 ,4};
Could anyone please tell me, what would be the good approach in mapping those integers keys with those arrays location? Is the following a short and bette...
I did the following algorithm involving a Binary Heap structure:
Algorithm: heapMinimum(node)
Input : Position n
Output : Sequence minList; containing the postions that hold the minimum value
1. minList <-- sequence
2. if parent(node) == NULL // current node is the root of the tree
3. minList.insertLast(node)
4. if (leftchild(no...
Hi all,
I want to find 9's complement of number but failed.
I tried it with the methods of 1's and 2's complements but no effect.
What is common method to find out the N's complement of a number?
...
Can somebody please show me in C-style pseudocode how to write a function (represent the points however you like) that returns true if 4-points (args to the function) form a rectangle, and false otherwise?
I came up with a solution that first tries to find 2 distinct pairs of points with equal x-value, then does this for the y-axis. Bu...
I am looking for a good algorithm that can recommend content objects to user by calculating similarity between user and content object. To calculate it, we have the content object tags (meta data) and user's interest data.
We can learn about user's interest in two ways:
Explicitly asking him: Ask him to rate a particular content item...
Let us say I have the following string:
"my ., .,dog. .jumps. , .and..he. .,is., .a. very .,good, .dog"
1234567890123456789012345678901234567890123456789012345678901 <-- char pos
Now, I have written a regular expression to remove certain elements from the string above, in this example, all whitespace, all periods, and all commas....
Hello,
I'm trying to develop a view of a hierarchical tree in which the weight of each node is the actual number of children it has. A leaf node has weight 1.
I want to arrange these items in a way they can be browsed going deeper into the tree by showing the root categories (with no parent) at the beginning. Clicking on a node makes t...
I'm working on a simple application that will generate time table (daily planner) for schools. I've read up basics of algorithms, but confused as to where to start.
The problem:
Allocate teachers to classes taking into consideration a lot of constraints like:
1) Subject
2) Expertise of teacher
3) Not more than 2 classes continuously.....
What's the most idiomatic way to convert a set of integers into a set of ranges?
E.g. given the set {0, 1, 2, 3, 4, 7, 8, 9, 11} I want to get { {0,4}, {7,9}, {11,11} }.
Let's say we are converting from std::set<int> into std::vector<std::pair<int, int>>.
I treat Ranges as inclusive on both sides, since it's more convenient in my cas...
Are there any silver bullets out there for searching medium sized amounts of text data (hundreds of gigabytes)? Don't really care if it's commercial or open source. I should add that I need it to be C++ or C based.
...
I'm trying to implement an algorithm that repeatedly applies operations on a Collection (currently a List). In each step Elements can be added, removed and changed (using getters and setters) within the collection. The algorithm is repeated until no changes were made to the collection in the previous step.
The order of elements is not ...
I am currently learning about Big O Notation running times and amortized times. I understand the notion of O(n) linear time, meaning that the size of the input affects the growth of the algorithm proportionally...and the same goes for, for example, quadratic time O(n2) etc..even algorithms, such as permutation generators, with O(n!) tim...
Hi! I am trying to store a large list of strings in a concise manner so that they can be very quickly analyzed/searched through.
A directed acyclic word graph (DAWG) suits this purpose wonderfully. However, I do not have a list of the strings to include in the first place, so it must be incrementally buildable. Additionally, when I sear...
Hi I was wondering whether anyone could offer some advice on the fastest / most efficient way to compre two arrays of strings in javascript.
I am developing a kind of tag cloud type thing based on a users input - the input being in the form a written piece of text such as a blog article or the likes.
I therefore have an array that I ke...
For instance, suppose I have an algorithm that's O(n) and an algorithm that's an amortized O(n). Is it fair to say that in strictly big oh terms, the non-amortized algorithm will always be as fast or faster than the amortized algorithm? Or is there ever any reason to prefer the amortized version (ignoring things like code simplicity or...