# Search Results

Results tagged with Search options answers only user 17408
38 results

Questions about problems that entail selecting the best element from some set of available alternatives, and methods to solve them.

Imagine you have a 256 bit vector floating point unit which can perform eight 32 bit operations in parallel. How many operations per second can you perform with or without using the vector FPU? Imagi …
Polynomial time is not too difficult. A "cluster" contains a sequence of 1 or more consecutive numbers from your list. The "badness" of a cluster is defined as the sum of absolute differences betwee …
answered Jan 28 '18 by gnasher729
There's a rather simple algorithm for this. You start at the end of the array, day 10. If you only wanted to travel from that day onwards, you could buy a 1 day, 7 day, or 30 day ticket. 1 day is op …
answered Jun 21 '16 by gnasher729
Assume you start at zero. Lion #i is at $d_i$ and wakes up at $w_i$. If there is no lion with $d_i > 0$ and $w_i < d_i$ then you walk to the right and are safe. If there is no lion with $d_i < 0$ and …
answered Nov 17 '18 by gnasher729
You can also replace with if (loop_condition) { loop_invariant_code do { loop_body } while (loop_condition) } With all he precautions of course. That makes the loop a bit simple …
Assume no method is free: If some methods are free, you try all the free methods first obviously, and you are left with a problem without free methods. Assume you have only n = 2 methods. Method 1 c …
answered Aug 6 '16 by gnasher729
At any point in time, you have either (a) not bought anything, (b) bought stock once, (c) bought and sold stock once, (d) bought and sold, then bought again, (e) bought and sold twice. In each case yo …
answered Jul 17 '16 by gnasher729
You could answer the question "what is the highest number of boxes that we can lift starting at box #k", for k = N, N-1, N-2, ..., 1 in that order. For k = N the answer is obviously 1, and for every …
answered Dec 3 '16 by gnasher729
Problem definition: There are k ≥ 1 bids. Each bid $B_i$ consists of a price $p_i$ and a set $X_i$ of integers. A subset S of the integers 1 to k is acceptable if $X_i$ and $X_j$ have no element in co …
answered Aug 23 '16 by gnasher729
In practice, just as you can calculate g (u) for one particular u quite quickly, you can calculate g (u) for all $u \in V$ in parallel, operating with bit vectors of $|V|$ bits instead of boolean valu …
answered Aug 28 '16 by gnasher729
Algorithm: Pick girl #i where $P_i$ is as high as possible. Eligible boys are those with $A_j ≥ P_i ≥ B_j$. If there is no eligible boy then she is not matched, otherwise match her with eligible boy # …
answered Nov 6 '17 by gnasher729
If you could solve the decision problem (do these items fit in k bins) you can obviously solve the optimisation problem (what is the minimum number of bins) using binary search. But you actually want …
If you want to calculate the product of n matrices $A_1$ to $A_n$ in the best possible time, you can easily calculate how many operations are needed to calculate the product of $A_i$ to $A_j$ for all …
I think this should be doable in O (n). Take the similar problem: Given $a_i$, 1 ≤ i ≤ n, and d ≥ 0, find $b_i$ in non-descending order such that $|a_i - b_i| ≤ d$ for all i, or show that it isn't p …