instruction stringlengths 0 29.8k ⌀ |
|---|
I gotta make a CFG and PDA for the grammar that has perfectly nested parentheses and brackets.
S -> [S]
S -> (S)
S -> SS
S -> Epsilon
Not sure if this is correct, or how to make the PDA from it? |
CFG and PDA for the grammar that has perfectly nested parentheses and brackets |
|formal-grammars|context-free|pushdown-automata| |
I try to understand if someone can apply a **NTM** to recognize **coNP** language.
From the definition we know that:
**NP** - set of languages that can be recognized by NTM in polynomial time.
**coNP** - set of all languages that are complement to NP language.
as with P versus NP question, we have NP versus... |
I'm just curious about the pseudocode(or real source code, doesn't matter) of the recursive version of this algorithm. In almost every book chapter/paper when describing this topic, they mention that the recursive version takes exponential time and then they give the code for the dynamic programming approach. I underst... |
minimum weight triangulation |
|recursion| |
null |
These complexity classes are not just defined by a machine model but also by the criteria about when a machine accepts a strings. So although $\mathsf{NP}$ and $\mathsf{coNP}$ can be defined using essentially the same underlining machine structure their accepting criteria is difference. That is the main point you are m... |
$c=5$ is clearly the wrong answer, since for any $n$,
$$cn^3 < 5n^3 + \text{(positive terms)}$$
However, if we take $c>5$ then there will exists some $N_0$ such that for $n>N_0$
$$cn^3 \ge 5n^2+2n^2+22n+6$$
If we let $g(n)=(c-5)n^3-2n^2-22n-6$, then Since $\lim_{n\to\infty} g(n)=\infty$, by the limit definiti... |
There is a very well-known method of converting CFGs to PDAs.
Check https://www.youtube.com/watch?v=MJ9xNavURY8
Or the [Wikipedia article on Pushdown automata](http://en.wikipedia.org/wiki/Pushdown_automaton)
also [this question](http://cs.stackexchange.com/q/3205/157) has some interesting details.
But ma... |
Break the problem into two parts:
1. There is a $\mathsf{NP}$-complete language in $\mathsf{NTime}(n^{1000})$.
2. If an $\mathsf{NP}$-complete language is in $\mathsf{DTime}(n^{1000}) \subset \mathsf{P}$ then $\mathsf{P}=\mathsf{NP}$. |
null |
A: your CFG looks good.
B: There is a very well-known method of converting CFGs to PDAs.
Check https://www.youtube.com/watch?v=MJ9xNavURY8
Or the [Wikipedia article on Pushdown automata](http://en.wikipedia.org/wiki/Pushdown_automaton)
also [this question](http://cs.stackexchange.com/q/3205/157) has some... |
The language you study is a classic, the one-sided Dyck language (on two pairs of brackets). You can directly make a PDA by considering the following property of nested strings: every symbol closing bracket you read should match the last unmatched opening bracket. Keep the unmatched $[$ and $($ on the stack and you are... |
Note that here we don't have an arbitrary list of operations, we are talking about a single operation. So referring to it as amortized analysis can be confusing. Amortized analysis is usually used for an arbitrary list of operations, not a particular list of operations. We can use the methods for amortized analysis but... |
It doesn't need to be. There is nothing about the structure of the hash function in general that requires that.
However it is more convenient to use natural numbers/strings. Computation over other objects are normally defined using an encoding of those objects by finite strings or natural numbers and there is not mu... |
Another more advanced answer is to look at a complete problem from a class that is closed under complement. For example, take the [arithmetical hierarchy][1] which is closed under complements. Now consider a complete problem for it like:
> Given: a sentence in the language of [first-order arithmetic][2],
> Questi... |
The decision problem for factoring is $\mathsf{NP}$ and the factoring can be reduced to it in deterministic polynomial time.
If $\mathsf{P}=\mathsf{NP}$ then then any problem in $\mathsf{NP}$ including factoring will have a polynomial time algorithm.
Note that the best known deterministic/probabilistic algorithms... |
Here is the solution using padding. Suppose $L \in \mathrm{NTime}(n^{1000})$. Define a new language $L' = \{x0^{|x|^{10}-|x|} : x \in L\}$. Each $x \in L$ corresponds to some $y \in L'$ of length $|y| = |x| + (|x|^{10}-|x|) = |x|^{10}$. Therefore we can decide whether $y \in L'$ in non-deterministic time $|x|^{1000} = ... |
null |
These complexity classes are not just defined by a machine model but also by the criteria about when a machine accepts a strings. So although $\mathsf{NP}$ and $\mathsf{coNP}$ can be defined using essentially the same underlining machine structure their accepting criteria are different. That is the main point you are m... |
There are already good answers, but I would like to add a few small points.
Assume that we have a technique to solve problems, e.g. *diagonalization*. Assume that we want to show that the technique cannot solve a specific problem e.g. *$\mathsf{P}$ vs. $\mathsf{NP}$*. How can be show this?
Before going further, n... |
In non-centralized algorithmic theories, for example in the theory of distributed algorithms, there are problems with lower bounds, as $\Omega(n^2)$, that are "big" (I mean, bigger than $\Omega(n\log n)$), and nontrivial (I mean not obtained just nothing that it is the time required to read the input, as for matrix mul... |
Is there any nontrivial problem in the theory of centralized algorithms with a nontrivial polynomial lower bound of $\Omega(n^2)$? |
|algorithms|complexity-theory| |
I was offered by a professor to give some tutoring in his course of Algorithm Design, based on Kleinberg and Tardos' book. He suggested me to prepare two exercise on dynamic programming, one exercise for polynomial reduction, and another one for approximation algorithms.The exercise should be not too advanced, but not ... |
Best a-little-advanced examples of dynamic programming, polynomial reduction and approximation algorithm |
|algorithms| |
null |
R(b,j): the max reliability for constructing the system with stage 1....j with budget b
for j=1 to n
Pr(0,j)=0
for b=1 to B
Pr(b,1)=r_1
for b=1 to B
for j=1 to n
for k=1 to b/c_j
Pr(b,j)=max{Pr(b-c_j*k, j-1)*(1-(1-r_j)^k}
Re... |
Given that the Hamiltonian cycle problem is NP complete, I want to prove that the following is NP complete.
Given an undirected graph G(V,E), and s ant t belongs to V, does there exist a path from s to t with at least k edges such that all vertices in p are distinct.
I thought of assigning a weight of 1 to every ... |
Np completeness |
|np-complete| |
The easiest way (assuming I understand your question - I was a very bored Year 10 graduate) is to go to base 2.618~ and use the following system:
if initial bit = 0 then 0
if initial bit = 1 then see next bit.
if next bit = 0 then 1
if next bit = 1 then 2
Advantages: uses space efficently. Uses 1.618~ bits per... |
Given that the [Hamiltonian cycle problem][1] is NP-complete, I want to prove that the following problem is NP-complete:
> Given an undirected graph $G(V,E)$ and vertices $s,t\in V$, does there
> exist a path from $s$ to $t$ with at least $k$ edges such that all vertices
> in the path are distinct?
I thought of... |
Reduction to Hamiltonian cycle |
|complexity-theory|np-complete|reductions| |
null |
null |
|data-structures|runtime-analysis|heaps| |
I'm just curious about the pseudocode (or real source code, doesn't matter) of the recursive version of this algorithm. In almost every book chapter/paper when describing this topic, they mention that the recursive version takes exponential time and then they give the code for the dynamic programming approach. I unders... |
Minimum weight triangulation |
|algorithms|computational-geometry|recursion| |
This problem is named the **k-Stroll** problem in [Approximation Algorithms for the Directed k-Tour and k-Stroll Problems](http://ttic.uchicago.edu/~cjulia/papers/k-stroll-full.pdf):
> The input to the k-Stroll problem is a directed n-vertex graph
with nonnegative edge lengths, an integer k, and two special vertice... |
This problem is named the **k-Stroll** problem in [Approximation Algorithms for the Directed k-Tour and k-Stroll Problems](http://ttic.uchicago.edu/~cjulia/papers/k-stroll-full.pdf):
> The input to the k-Stroll problem is a directed n-vertex graph
with nonnegative edge lengths, an integer k, and two special vertice... |
This problem is named the **k-Stroll** problem in [Approximation Algorithms for the Directed k-Tour and k-Stroll Problems](http://ttic.uchicago.edu/~cjulia/papers/k-stroll-full.pdf):
> The input to the k-Stroll problem is a directed n-vertex graph
with nonnegative edge lengths, an integer k, and two special vertice... |
{"Voters":[{"Id":2755,"DisplayName":"Realz Slaw"}]} |
**Problem is in NP**
You can easily verify an answer to your problem: if a path is given, and it is goes from $s$ to $t$ and has $k$ edges with distinct vertices, then it is correct.
**Reduction from Hamiltonian Cycle Problem**
You can pick any vertex as $s$, and then for each neighbor, $(s,t_i)\in E$, attempt... |
{"Voters":[{"Id":2755,"DisplayName":"Realz Slaw"}]} |
Assuming you are asking about algorithms in general that have greater than $\Omega (n \log n)$ and are not in the field of distributed algorithms:
* Long multiplication takes $\Theta (n^2)$ time, when multiplying two $n$-bit integers.
* Matrix multiplication takes $\Theta (n^3)$ arithmetic operations for the naive ... |
null |
Assuming you are asking about algorithms in general that have greater than $\Omega (n \log n)$ and are not in the field of distributed algorithms (and assuming you are not being particular about $\Theta$ vs. $\Omega$ vs $\mathcal O$):
* Long multiplication takes $\Theta (n^2)$ time, when multiplying two $n$-bit in... |
I'm trying to solve a problem:
I have 11 ciphers encoded with the same key.
My aim is to decode target cipher.
If I do xor C1, C2 (ciphers encoded with the same key) I do get M1 xor M2 (where M1, M2 are plain text messages).
Please say what to do next. I don't understand how to get plain texts from M1 xor M2 |
One time pad, get plaintext using ciphers encoded with the same key |
|algorithms| |
In non-centralized algorithmic theories, for example in the theory of distributed algorithms, there are problems with lower bounds, as $\Omega(n^2)$, that are "big" (I mean, bigger than $\Omega(n\log n)$), and nontrivial.
I wonder if are there similar bound in the theory of centralized algorithm, I mean of order much ... |
In the theory of distributed algorithms, there are problems with lower bounds, as $\Omega(n^2)$, that are "big" (I mean, bigger than $\Omega(n\log n)$), and nontrivial.
I wonder if are there similar bound in the theory of serial algorithm, I mean of order much greater than $\Omega(n\log n)$. |
Is there any nontrivial problem in the theory of serial algorithms with a nontrivial polynomial lower bound of $\Omega(n^2)$? |
In the theory of distributed algorithms, there are problems with lower bounds, as $\Omega(n^2)$, that are "big" (I mean, bigger than $\Omega(n\log n)$), and nontrivial.
I wonder if are there problems with similar bound in the theory of serial algorithm, I mean of order much greater than $\Omega(n\log n)$. |
|cryptography|encryption|xor| |
I'm trying to solve a problem:
I have 11 ciphers encoded with the same key.
My aim is to decode target cipher.
If I do xor C1, C2 (**ciphers encoded with the same key**) I do get M1 xor M2 (where M1, M2 are plain text messages).
Please say what to do next. I don't understand how to get plain texts from M1 xor... |
Assuming you are asking about algorithms in general that have greater than $\Omega (n \log n)$ and are not in the field of distributed algorithms (and assuming you are not being particular about $\Theta$ vs. $\Omega$ vs $\mathcal O$):
* Even the best multiplication algorithms take more than $\mathcal{O} (n \log n)... |
I have a contiguous ordered data structure (0 based index):
x= [1/3, 1/3, 1/3]
Let's say I selected index 1 and increased the probability by 1/3. Rest of the probabilities each decrease by 1/6 and the total probability remains P = 1.
x= [5/6, 2/3, 5/6]
Let's say I selected index 2 and increased the pro... |
probability wheel, redistribution of probabilities |
|data-structures|probability-theory| |
**EDIT:**
Due to changing question, I have replaced my answer.
The only *problems* I can think of that have greater than $\Omega (n)$ worst case proven bounds are those that the size of the output is more than $\Omega (n)$.
* As AJed mentioned in his comment: The all-shortest path problem is $\Omega (n^2)$ becau... |
I have a contiguous ordered data structure (0 based index):
x= [1/3, 1/3, 1/3]
Let's say I selected index 1 and increased the probability by 1/3. Rest of the probabilities each decrease by 1/6 and the total probability remains P = 1.
x= [1/6, 2/3, 1/6]
Let's say I selected index 2 and increased the pro... |
It's really hard to say, what kind recursion you mean. There are different variants I can think of. For what you have written, I guess it is something like this.
function findOT(int l,r)
if ((r-l)==2) return perimeter(l,l+1,r)
min= infinity
for a=(l+1)..(r-1)
T=findOT(l,a)+perimeter(l... |
There may be a large number of algorithms proposed for generating graphs satisfying some common properties (e.g. clustering coefficient, average path length, degree distribution, etc).
My question concerns a specific case: I want to generate a few *undirected regular* graphs (i.e. every node in these graphs has the ... |
Algorithms for graph generation using given properties |
|algorithms|graphs| |
This can be easily achieved by an array $A$ and an additional variable $m$. The entry $A[i]$ stores the probability of $i$ times $m$.
In your example you start with
A=[1,1,1], m=3
The you increase the probability of the second element by 1/3. This can be carried out by setting $A[2]=4$ and $m=6$, which gi... |
**Problem is in NP**
You can easily verify an answer to your problem: if a path is given, and it is goes from $s$ to $t$ and has $k$ edges with distinct vertices, then it is correct.
**Reduction from Hamiltonian Cycle Problem**
You can pick any vertex as $s$, and then for each neighbor, $(s,t_i)\in E$, attempt... |
In fact, there's an argument to be made that the 'range' of CRC-style hashes is _not_ the integers (or naturals), but is in fact the field of polynomials over GF(2) modulo a primitive polynomial of degree $n$ (i.e., the field GF$(2^n)$). All of the operations are done on $n$-bit entities, but those entities are only '... |
In the theory of distributed algorithms, there are problems with lower bounds, as $\Omega(n^2)$, that are "big" (I mean, bigger than $\Omega(n\log n)$), and nontrivial.
I wonder if are there problems with similar bound in the theory of serial algorithm, I mean of order much greater than $\Omega(n\log n)$.
**EDIT:*... |
**EDIT:**
Due to changing question, I have replaced my answer.
The only *problems* I can think of that have greater than $\Omega (n)$ worst case proven bounds are those that the size of the output is more than $\Omega (n)$.
* The problem of listing all solutions to 3-SAT, or similarly, the problem of listing a... |
There may be a large number of algorithms proposed for generating graphs satisfying some common properties (e.g., clustering coefficient, average shortest path length, degree distribution, etc).
My question concerns a specific case: I want to generate a few *undirected regular* graphs (i.e., every node in these grap... |
|algorithms|graphs|sampling| |
If $P=NP$, and we have an algorithm that can solve the [k-SAT][1] problem in polynomial time, then integer factorization can simply be reduced to k-SAT by describing factoring as a problem in k-SAT.
Essentially it works as follows: You make a bunch of variables each representing the bits of $p$, and $q$, and $n$. Th... |
null |
This can be easily achieved by an array $A$ and an additional variable $m$. The entry $A[i]$ stores the probability of $i$ times $m$.
In your example you start with
A=[1,1,1], m=3
The you increase the probability of the second element by 1/3. This can be carried out by setting $A[2]=4$ and $m=6$, which gi... |
This answer is mostly a recap of the comments on the question above.
If a problem is NP-complete, it can indeed be reduced to ILP, by using Karp's reductions (― Joe, andy). Claims of "polynomial sized formulations" from one problem to another, are likely meant as more direct formulations, as opposed to multiple redu... |
null |
**EDIT:**
Due to changing question, I have replaced my answer.
The only *problems* I can think of that have greater than $\Omega (n)$ worst case proven bounds are those that the size of the output is more than $\Omega (n)$.
* The problem of listing all solutions to 3-SAT, or similarly, the problem of listing a... |
Some simple problems that have lower bounds greater than the size of their inputs, are algorithms that have output sizes greater than their input sizes.
Some examples:
* The problem of listing *all solutions* to 3-SAT, or similarly, the problem of listing all *Hamiltonian cycles*. These problems both have expon... |
Note, all you need to do to show something is NP-Hard is to show that an NP-Hard problem is its subproblem.
For instance, in your case, you could show that since finding a Hamilton Path is NP-Hard, then your problem is NP-Hard since a Hamilton Path is the specific case of your problem where `k = |V|-1`. |
Some simple problems that have lower bounds greater than the size of their inputs, are algorithms that have output sizes greater than their input sizes.
Some examples:
* The problem of listing *all solutions* to 3-SAT, or similarly, the problem of listing all *Hamiltonian cycles*. These problems both have exponen... |
A depth first search produces a spanning tree. If you perform DFS using all possible orderings of the adjacency list, wouldn't you find the minimum spanning tree? In other words, there is no example of a graph where a DFS won't find the minimum spanning tree regardless of how the adjacency list is ordered. Is this corr... |
Depth First Search to find Minimum spanning tree |
|algorithms|graphs|spanning-trees| |
There are such problems by time hierarchy theorem. Just take any problem that is complete for a large complexity class. For example, take a problem that is complete for [$\mathsf{ExpTime}$][1]. Such a problem will be $\Omega(n^c)$ for all $c\in\mathbb{N}$.
However also note that for problems in $\mathsf{NP}$, there ... |
Here is a hint. Suppose the sequence contains $n-1$ Xs and $n+1$ Ys, so that you need to change some Y to X. You can compute for each position $k \in [1,\ldots,2n]$ the number of Xs minus the number of Ys; let's call that a "report". Changing a Y to an X affects the report in a certain, easy to describe, way. On the ot... |
I recently came across the following interesting problem - one is given a sequence of Xs and Ys such as XXYXYXYYXYXXXYX, and consider a sequence to be good if, as you start at the left and move right, the number of Xs is greater than or equal to the number of Ys at any point except at the very end, at which the two qua... |
Improving Time Bound of this Algorithm past O(n^2) |
|algorithms| |
Some simple problems that have lower bounds greater than the size of their inputs, are algorithms that have output sizes greater than their input sizes.
Some examples:
* The problem of listing *all solutions* to 3-SAT, or similarly, the problem of listing all *Hamiltonian cycles*. These problems both have exponen... |
There are such problems by time hierarchy theorem. Just take any problem that is complete for a large complexity class. For example, take a problem that is complete for [$\mathsf{ExpTime}$][1]. Such a problem will be $\Omega(n^c)$ for all $c\in\mathbb{N}$.
However also note that for problems in $\mathsf{NP}$, there ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.