Why is theory useful? Do you ever use it in your day-to-day coding? For example, we learned about the halting problem, Turing machines, reductions, etc... a lot of classmates are saying it's abstract and useless and there's no real point to knowning any of it (meaning, you can forget it once the course is over and not lose anything).
...
Given an array of items, each of which has a value and cost, what's the best algorithm determine the items required to reach a minimum value at the minimum cost? eg:
Item: Value -> Cost
-------------------
A 20 -> 11
B 7 -> 5
C 1 -> 2
MinValue = 30
naive solution: A + B + C + C + C. Value: 30, Cost 22
best option: A...
For a project I have a specification with formulas, I have to implement. In these formulas a cumulative standard normal distribution function exists, that takes a float and outputs a probability. The function is symbolized by a Φ. Exists a Java-library, that computes this function?
...
Kernel-based classifier usually requires O(n^3) training time because of the inner-product computation between two instances. To speed up the training, inner-product values can be pre-computed and stored in a two-dimensional array. However when the no. of instances is very large, say over 100,000, there will not be sufficient memory to d...
I have an expensive computation, the result of which I'd like to cache. Is there some way to make a map with two keys? I'm thinking of something like Map<(Thing1, Thing2), Integer>.
Then I could check:
if (! cache.contains(thing1, thing2)) {
return computeResult();
}
else {
return cache.getValue(thing1, thing2);
}
pseudocode. But...
My integers in Ruby (MRI) refuse to overflow. I've noticed the class change from fixnum to bignum but I'm wondering how this is modeled and what sort of process ruby uses to perform arithmetic on these massive integers. I've seen this behaviour in SCHEME as well as other environments.
I ask because I'd like to implement something simil...
The period of the Mersenne Twister used in the module random is (I am told) 2**19937 - 1. As a binary number, that is 19937 '1's in a row (if I'm not mistaken). Python converts it to decimal pretty darned fast:
$ python -m timeit '2**19937'
10000000 loops, best of 3: 0.0271 usec per loop
$ python -m timeit -s 'result = 0' 'result += ...
During my studies at university I had to learn a lot about the theory of computation. I studied the subject for three terms. I had a hard time and I have to admit that I forgot a lot.
I am wondering whether this is a personal problem, or if we just had to learn a lot of (more or less) useless stuff.
So my question is: What topics in th...
As an input, I receive some planar, triangulated geometry. Now, I need to compute the four coordinates of the corners of the bounding rectangle. Any Ideas?
...
I have the equation y = 3(x+1)^2 + 5(x+1)^4.
Using Horner's scheme I could evaluate this polynomial in this form, y = 8+x(26+x(33+x(20+5x))), thus requiring 8 arithmetic operations.
I could also evaluate it in this form, y = (x+1)^2 * ((5x+10)x+8), requiring 7 operations.
I've been told this can be done in 5 operations but Horner's a...
Hi experts, do you happen to have a sample code on how to subtract day tomorrow or 2 days from today? And then I will multiply it by a number depending on its reserved value. I am figuring how to operate a hotel checking in and show its price by asking when the customer checks out, so the price will be ready upon checking in
...