instruction stringlengths 0 29.8k ⌀ |
|---|
Yes: The certificate (checked by the verifier) simply encodes the non-deterministic choices made by the non-deterministic program. You then run the original non-deterministic program, resolving the non-determinism using the certificate.
Remember that each "NP verifier" receives two inputs: The original problem insta... |
Given a string of length $n$, your own algorithm will loop $n$ times, and each addition grows in the order of $O(n)$, yielding a total of $O(n^2)$.
`result = result * base + digit`
With length $n = 10^6$, in the beginning we add one single-digit number, in the end we add one million-digit number, yielding $1 + 2 ... |
Generally speaking, we don't need compiler support to implement the verifier. Implementing a verifier for a NP-problem is usually easy; far easier than implementing an efficient solver. So I doubt that your idea is going to prove very useful.
That said, if you want to do it, if you have a formal specification of a... |
Yes. Sort all chocolates by price. For all possibilities for the choice of first chocolate, use [...] to find the best second chocolate to go with it. Keep the best pairing found.
Fill in the [...] with an appropriate algorithm, and you can beat $O(n^2)$.
To improve the running time even further, consider: as ... |
null |
null |
Id say this is the first case of Master Theorem, but when I try to prove that the limit of f(n)/ n ^ (1-E) is 0, I cannot do it. Does anyone have a solution? |
Does the Master Theorem apply to T(n) = 3T(n/3) + n/log2(n)? |
|algorithm-analysis|master-theorem| |
Sure. They are used in model checking. Specifically, if we want to check [liveness properties](https://en.wikipedia.org/wiki/Safety_and_liveness_properties) of systems, then typically we use $\omega$-automata (e.g., Büchi automata) to formalize the property we are trying to verify, and to model the composition of pro... |
null |
I was looking at the proof of if $NP \subseteq BPP$ then $NP = RP$ [here][1].
At the end of the proof the author states:
"Note that if $M$ always gives correct answers on calls to $M$, then when $\phi$ is satisfiable, $N$ (the newly constructed TM) constructs a satisfying assignment to $\phi$ and hence accepts. The... |
If $NP \subseteq BPP$ then $NP = RP$. Confusion on the probability that M gives at least one wrong answer in BPP in n invocations |
|complexity-theory|time-complexity|probability-theory|probabilistic-algorithms|probabilistic-turing-machines| |
null |
Sure. They are used in model checking. Specifically, if we want to check [liveness properties](https://en.wikipedia.org/wiki/Safety_and_liveness_properties) of systems, then typically we use $\omega$-automata (e.g., Büchi automata) to formalize the property we are trying to verify, and to model the composition of pro... |
Not only your professor is correct, but also the reduction is not well-written. Specifically, you did one of the following (and both are wrong):
- The reduction simulates the run of $M$ on $w$, and then decides which $N$ to output: this cannot be done as the machine that computes the reduction may not halt.
- The... |
null |
null |
This question comes [up](https://mathoverflow.net/q/165428/36103) [from](https://cs.stackexchange.com/q/63624/988) [time](https://news.ycombinator.com/item?id=38513091) [to](https://www.quora.com/What-are-some-examples-of-recursive-functions-that-are-not-primitive-recursive-such-as-the-Ackermann-function) [time](https:... |
This question comes [up](https://mathoverflow.net/q/165428/36103) [from](https://cs.stackexchange.com/q/63624/988) [time](https://news.ycombinator.com/item?id=38513091) [to](https://www.quora.com/What-are-some-examples-of-recursive-functions-that-are-not-primitive-recursive-such-as-the-Ackermann-function) [time](https:... |
null |
The problem is not where you think it is.
To decide this, you would normally just add up the square roots and compare the sums. The problem arises when both sums are close together, so you cannot easily prove which sum is larger. Now consider that all we know is that the numbers are integers. They could be 100 digi... |
Using the CGAL library, I am working on a 2D layout graph which contains an array of 2D polygons with holes. The aim is to generate random points (based on some conditions) and only keep the points inside the area of 2D polygons but not in their holes. The function I use for this is **CGAL::bounded_side_2** [1].
Per... |
Speed up FOR loop containing CGAL's bounded side check for each 2D point |
|graphs|computational-geometry|c++| |
as the title says, I am wondering why this exercise doesn't show a data forwarding from the "ex" stage of 2nd instruction to "ex" stage of 3rd instruction.
P.S. the architecture is MIPS (with simplified 5 stage cycle).
Thank you in advance
[![enter image description here][1]][1]
[1]: https://i.stack.imgu... |
Why can't I use data forwarding in this exercise? |
|computer-architecture|cpu-pipelines|mips| |
It's a parallel linear search, with an over-complicated way to divide up the array into a power-of-2 number of chunks. (Since you only split in half with multiple levels of recursion, instead of the usual `chunk_size = n/cores_available` which can keep all cores busy even if their number isn't a power of 2.)
**In t... |
null |
It's a parallel linear search, with an over-complicated way to divide up the array into a power-of-2 number of chunks. (Since you only split in half with multiple levels of recursion, instead of the usual `chunk_size = n/cores_available` which can keep all cores busy even if their number isn't a power of 2.)
**In t... |
If I understand what you're trying to achieve, this problem is solved by using a [point-in-polygon test](https://en.wikipedia.org/wiki/Point_in_polygon) for each of the 50,000 points. This should be efficient, even if performed on only a single machine. To deal with polygon-shaped holes, check if the point is contain... |
null |
null |
null |
Consider string "00". It fits your L but isn't accepted by the DFA.
I think slight modification will make your answer correct: \
$L = \{ w \; | \; w \text{ has at least one 1 and ends with an even number of 0s or ends with a 1 } \;\}$
Sketch of Proof in one direction: Because there's at least one 1, somewhere... |
Time starts at zero. Page 5 was last accessed at $t=23$, while page 3 was last accessed at $t=101$. Suppose rn is $t=102$, which do you think is the least recently used page?
|
It's a parallel linear search, with an over-complicated way to divide up the array into a power-of-2 number of chunks. (Since you only split in half with multiple levels of recursion, instead of the usual `chunk_size = n/cores_available` which can keep all cores busy even if their number isn't a power of 2.)
**In t... |
null |
I am studying the approximation algorithm. I have a question as follows.
For an approximation algorithm, if I have $sol \ge \alpha opt + c$, where $c$ is a constant,can i say that this algorithm is $\alpha$-apx? Why? |
The approximation ratio of approximation algorithm |
|approximation| |
I am studying the approximation algorithm. I have a question as follows.
For an approximation algorithm for maximization problem, if I have $sol \ge \alpha opt - c$, where $c$ is a positive constant and $0 < \alpha < 1$, can i say that this algorithm is $\alpha$-apx? Why? |
For a reduction $f$ to be computable, there must be a TM that for all inputs $y$ halts with $f(y)$ written on its tape.
The reduction you suggested is indeed computable. Here, your input $y$ is assumed to be of the form $\langle M, w \rangle$, then the reduction outputs a description of a machine $\langle M'\rangle$.... |
Your answer is correct.
$L = \{ w \; | \; w \text{ has at least one 1 and ends with an even number of 0s or ends with a 1 } \;\}$
Sketch of Proof in one direction: Because there's at least one 1, somewhere we find a 1 and get to $q_2$. To end in $q_2$, either the last word was a 1; or it was zero and last state ... |
null |
null |
null |
null |
There are several ways to prove this. Here is a formal one:
You can encode the set of DFAs over $\Sigma$ as words over the constant alphabet $\Sigma' = \{0, 1, \#\}$. This can be done as follows. Let $A = \langle \Sigma, Q, q_0, \delta, F\rangle$ be a DFA over $\Sigma$. We define the encoding of $A$, denoted $\langl... |
There are several ways to prove this. Here is a formal one:
You can encode the set of DFAs over $\Sigma$ as words over the constant alphabet $\Sigma' = \{0, 1, \#\}$. This can be done as follows. Let $A = \langle \Sigma, Q, q_0, \delta, F\rangle$ be a DFA over $\Sigma$. We define the encoding of $A$, denoted $\langl... |
Consider a nondeterministic Büchi automaton $A = \langle \Sigma, Q, q_0, \delta, \alpha\rangle$. The acceptance condition of $A$ is a subset of states $\alpha\subseteq Q$, and an infinite run $r = q_0, q_1, q_2, \ldots$ over an infinite word $\sigma_1\sigma_2\cdots $ is accepting iff $r$ visits a state in $\alpha$ infi... |
I am trying to solve the following problem. I've tried to find the name of this problem, but could not really find what I was looking for. I assume there should be some graph-theory that covers it, but it's been a while since my last algorithms class.
I do not need the global best solution, a "pretty good" solution ... |
How do I optimally fuse nodes in a tree structure? |
|graphs|optimization|dynamic-programming|trees|algorithm-design| |
I have a colored image 1024x1024 whose rows and columns were randomly shifted, how would I unscramble it without having any information about the original image? |
How to unscramble an RGB image 1024x1024 |
|algorithms|image-processing| |
The following is a real world problem, for which I adjusted the explanation, such that it is easier to understand.
In a very abstract form, the challenge is to find a group-sorting algorithm, that is only allowed to use queues.
**Instance of the problem**<br>
Let’s assume we have people arriving in cars at the ent... |
The Festival-Clique-Sorting Problem |
|sorting| |
The following is a real world problem, for which I adjusted the explanation, such that it is easier to understand.
In a very abstract form, the challenge is to find a group-sorting algorithm, that is only allowed to use queues.
**Instance of the problem**<br>
Let’s assume we have people arriving in cars at the ent... |
Let G be the CF grammar that has the production rules:
$S -> aS | aSbS | c$. Show that G is ambiguous.
I thought of proving it by representing the string $aacbc$ but I don't know if it is correct as a solution:
$aS -> aaSbS -> aacbS -> aacbc$
$aSbS -> aaSbS -> aacbS -> aacbc$
|
It shows that CF grammar is ambiguous |
|context-free|tree-grammars| |
null |
Most optimization textbooks **do not** cover the concept of NP-hardness. Some examples include:
- "Convex optimization" by Boyd and Vandenberghe
- "Numerical Optimization" by Nocedal and Wright
- "An Introduction to Optimization" by Chong and Zak
and half a dozen more well-known optimization textbooks... |
Seeking a reference for NP-hardness of optimization problems |
|complexity-theory|reference-request|np-hard|definitions|reference-question| |
Given $n$ points in 2d Euclidean space, the [$k$-center problem][1] asks us to find a subset of size $k$ of the points which we will call centers. The task is to pick these centers to minimize the maximum distance from any point to its closest center.
A classic greedy algorithm repeatedly picks points which are fu... |
How to find an example for a case in the metric k-center problem |
|approximation| |
null |
Question
-----------------
Prove that the number of comparisons between elements in binary heap build is at most $2n-2$.
$n$ is the total number of the nodes.
----------
pseudo code
-----------------
```
BUILD-MAX-HEAP (A)
1 heap-size [A] < - length[A]
2 for i <- Length[A]/2| downto 1
3 do MAX-H... |
Prove that the number of comparisons between elements in binary heap build is at most (2n-2) |
|heaps| |
null |
null |
|algorithms|np-hard|approximation| |
I am attending a course about algorithm design, and I have found an old test which has once been submitted. However, I don't have the solutions to it, and I am having some trouble with one specific excersise. This is the text:
Matt is planning a road trip from City A to City B, and he wants to minimize the number of... |
Number of stops during trip |
|algorithms|time-complexity|algorithm-analysis|dynamic-programming| |
Number of stops during trip - Dynamic programming algorithm |
null |
I am attending a course about algorithm design, and I have found an old test which has once been submitted. However, I don't have the solutions to it, and I am having some trouble with one specific excersise. This is the text:
Matt is planning a road trip from City A to City B, and he wants to minimize the number of... |
null |
I don't know exactly what you ask for, but here is an example of something.
First, observe that the first point is chosen arbitrarily.
Imagine two unit circles that intersect in a single point. In addition, add two points, one in the center of each circle. These are your points. Let $k=2$. The optimal solution pi... |
In my opinion, monographs on approximation algorithms come closest to what you are seeking:
- [Complexity and Approximation][1], by Giorgio Ausiello et al.
- [Approximation Algorithms][2], by Vijay Vazirani,
- [The Design of Approximation Algorithms][3], by David Shmoys and David Williamson.
If you are st... |
The following is a simple example:
Consider six points on a line: $p_1, \dotsc, p_6$. Let $k = 2$. The points $p_4, p_5, p_6$ are at the same position (or you can consider them very close to each other).
Then, there is an optimal solution $\{p_2, p_5\}$ with cost $2$.
Suppose, the greedy algorithm chooses the ... |
Given $n$ points in a 2d metric space, the [$k$-center problem][1] asks us to find a subset of size $k$ of the points which we will call centers. The task is to pick these centers to minimize the maximum distance from any point to its closest center.
A classic greedy algorithm repeatedly picks points which are fur... |
As it turns out, you don't need any dynamic programming to solve this problem, and a greedy solution works great. The greedy solution is: go as far as possible without taking a break from City $A$ (i.e. go to the furthest rest stop which is less than $n$ kilometers away). Repeat this process until you reach City $B$.
... |
As it turns out, you don't need any dynamic programming to solve this problem, and a greedy solution works great. The greedy solution is: go as far as possible without taking a break from City $A$ (i.e. go to the furthest rest stop which is less than $n$ kilometers away). Repeat this process until you reach City $B$. T... |
Take five equidistant points, $p_1, ..., p_5$ on a line and let $k=2$. The optimal solution picks points $p_2$ and $p_4$ with quality $\text{OPT}=d$.
Now, suppose the arbitrarily chosen center is point $p_3$, the central point. The next point will (wlog) be $p_1$. The quality of this solution is $\text{dist}(p_3, p_... |
You can't. Information has been lost.
There might be heuristics to make a best-effort recovery effort, based on the observation that typically adjacent pixels tend to have similar values (the difference in pixel intensities between neighboring pixels tends to be small). So, you could try to solve an optimization p... |
Let $\Sigma$ be an alphabet. Is the set of all DFAs over $\Sigma$ countable?
I know the set of all regular languages is countable, however, it is impossible to build an injection from the DFAs to the regular languages since a regular language isn't necessarily accepted by only a single DFA. |
Is the set of all DFAs countable? |
|regular-languages|automata|finite-automata|uncountability| |
This is [Case 2b from the Wikipedia article][1]: here $a = b = 3$ and $f(n) = n/\log n = n^{\log_b a} \cdot \log^{k}(n)$ for $k = -1$. Thus, the solution is $\Theta(n\log \log n)$.
[1]: https://en.wikipedia.org/wiki/Master_theorem_(analysis_of_algorithms)#Generic_form |
Let $D(V, A)$ be a DAG. We call a *dominated* path in $D$ a path $P$ such that
$P$ is maximal and $\exists P^{'} \in D . (P^{'} \text{ is maximal } \wedge V(P) \subset V(P^{'}))$
that is, $P$ is a dominated path iff $P$ is maximal and there exists another path $P^{'}$, also maximal, containing all the nodes of $... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.