instruction stringlengths 0 29.8k ⌀ |
|---|
Right, if you have an algorithm A that reduces $\Pi$ to $x$ in polytime, and you can solve $x$ is polytime using some algorithm B, then you can solve $\Pi$ in polytime by applying first A and then B.
Using polytime reductions on a problem in P however is rather boring, since you can solve the instance during the red... |
|formal-languages|regular-languages|finite-automata| |
I'm reviewing for finals and have a sample problem that I **think** I understand, but would like someone to bless my understanding or smack me and tell me why I'm wrong.
I'm presented with a problem $\Pi$ of unknown complexity class. If I can transform $\Pi$ to some problem $X$, where $X \in {\sf P}$, what does t... |
|complexity-theory|reductions|complexity-classes|p-vs-np| |
For a random undirected graph with $n$ nodes, where each node has $k$ incident edges ( $nk/2$ edges in total), the vertex set is partitioned into two sets each having $n/2$ nodes.
What is the order of the number of edges that start in one partition and end in the other?
My back of the napkin calculation is half ... |
|graphs|random-graphs| |
null |
It is well known that regular languages are characterized by the Myhill-Nerode equivalence. For language $L$ over $\Sigma^*$ define the equivalence $x\sim_L y$ over $\Sigma^*$ iff for all $z\in\Sigma^*$ we have $xz\in L \iff yz\in L$. Then $L$ is regular iff $\sim_L$ is of finite index, i.e., has a finite number of equ... |
Myhill-Nerode and closure properties |
|regular-languages|closure-properties| |
Problems in NP have certificates which can be verified in polynomial time.
It seems conceivable that there could be problems in P which have certificates which can be verified in logarithmic time. (Such certificates would also have to be logarithmic in size, naturally.)
However, it is also conceivable that there... |
Are any problems in P known to have logarithmic-time-verifiable certificates? |
|complexity-theory|nondeterminism|proof-complexity| |
Say I have a context-free grammar defined by the following rule.
$$
\langle EXPR\rangle \rightarrow \langle EXPR\rangle + \langle EXPR\rangle~|~\langle EXPR\rangle \times \langle EXPR\rangle~|~(\langle EXPR \rangle)~|~x
$$
This grammar is ambiguous since, for instance, I can generate the string $x + x \times x$... |
In general, how does one make a context-free grammar unambiguous? |
|formal-grammars|context-free| |
Implications of polynomial time reductions |
For a random undirected graph with $n$ nodes, where each node has $k$ incident edges ($nk/2$ edges in total), the vertex set is partitioned into two sets each having $n/2$ nodes.
>What is the order of the number of edges that start in one partition and end in the other?
My back of the napkin calculation is h... |
Mean number of edges between two equal partitions |
Yes.
To build a minimum spanning tree you will order edges by weights from smallest to largest. An edge is included as long as it does not make a cycle. If there are two minimum weight edges, then these edges are first and second. The first two edges do not make a cycle. Therefore, since all other edges are distinc... |
I am trying to design an efficienct algorithm to color a unicyclic graph. I know if a graph does not contain any cycles (it's a tree) then it is 2-colorable. But cycles are either 2 (is even number of vertices) or 3 (is odd number of vertices) colorable. So if there contains just one cycle then the chromatic number of ... |
Coloring a Unicyclic Graph |
|graphs| |
Let's say: `T(n) = T(sqrt(n)) + 1`
How do you solve such recurrence? |
How to find recurrences where Master formula cannot be applied |
|complexity-theory|algorithms| |
I am trying to understand why the modular exponentiation algorithm has a running time of about $\log(n)$ where $n$ is the exponent. Here is the algorithm:
function modular_pow(base, exponent, modulus)
result := 1
while exponent > 0
if (exponent mod 2 == 1):
result :... |
Running Time of Modular Exponentiation |
|algorithms| |
I have a data structure described as following:
- It's a collection of trees.
- Each tree has the same structure.
- Each tree has information of diferent nature.
A example of this data structure:
4 - - - - - - - 'a' - - - - - - - 3.5
/ \ / \ / \
... |
Is this data structure a hypertree or only isomorphic trees? |
|untagged| |
null |
I find [this](http://theory.stanford.edu/~trevisan/cs172/ps04.pdf),
but I can't complete it, is there any other solution for it? |
How can I prove that the language of a read-only Turing machines is regular? |
null |
The main idea is that $a^x \cdot a^x = a^{2x}$.
Now, in order to get, say, $a^{10}$ you can do $res = res * a$ for 10 times.
On the other hand you can do compute $a^2=a\cdot a$, then $a^4=a^2\cdot a^2$, then $a^8 = a^4 \cdot a^4$, and get the final result by multiplying $a^8$ with $a^2$. That is, we "break" the com... |
The equivalence classes of the Myhill-Nerode relation are also the states of the minimal DFA for the language. So whatever is easy to show using DFAs, you can convert to a proof which uses the Myhill-Nerode point of view. Wherever you need NFAs, you can expect the proof to get more complicated.
But the correct answe... |
A BTree has a $k$ value that determines that every node has $k$ to $2k$ children. When a node has $2k$ keys it needs to be split into two nodes.
Let's say I want to create a $k/(2k-x)$ tree. (like a 2-3 tree that follows the BTree rules, but isnt $k/2k$)
What is the possible range of $x$? The tree must follow the... |
B-tree branching factor boundaries |
|data-structures|search-trees| |
I found out you can prove a hand is fair with the following method:
Every user has a randomly generated "secret" in an input field he can personally edit, before each card is picked all the secrets are sent to the server and hashed seperately, then all the secrets are hashed into a single hash which is used as a see... |
For the recurrence,
$$
T(n) = T(\sqrt{n}) + 1
$$
Let $n = 2^{2^{k}}$, therefore we can write the recurrence as:
$$
T(2^{2^{k}}) = T(2^{2^{k-1}}) + T(2^{2^{k-2}}) + \ldots + T(2^{2^{k-k}})+ 1
$$
, i.e. $ k * O(1) $ work or linear in $k$. We can express $k$ in terms of $n$:
$$
\log{n} = 2^{k} \\
\log{\l... |
null |
Apparently, if $N=NP$, all languages $\in P$ except for $\emptyset$ and $\Sigma^*$ would be $NP-complete$.
Why these two languages in particular? Can't we reduce any other language in $P$ to them by outputting them when accepting or not accepting? |
If $N = NP$, why wouldn't $\emptyset$ and $\Sigma^*$ be $NP-complete$? |
|np-complete| |
As there are no strings in $\emptyset$, any machine that computes it always rejects, so we can't map Yes-instance of other problems to anything. Similarly for $\Sigma^{\ast}$ there's nothing to map No-instances to. |
You need a polynomial reduction from the problem $A$ to the problem $B$ if you want to prove that $B$ is "harder" than $A$. We build a polynomial reduction by transforming any instance $x$ of $A$ into an instance $f(x)$ of $B$ such that $x∈A$ iff $f(x)∈B$.
The function $f$ must and can be polynomial. If $\mathsf{P}=... |
> **Possible Duplicate:**
> [Every simple undirected graph with more than $(n-1)(n-2)/2$ edges is connected](http://cs.stackexchange.com/questions/6801/every-simple-undirected-graph-with-more-than-n-1n-2-2-edges-is-connected)
<!-- End of automatically inserted text -->
At lesson my teacher said that a graph with ... |
{"OriginalQuestionIds":[6801],"Voters":[{"Id":71,"DisplayName":"Joe"},{"Id":3092,"DisplayName":"Jernej"},{"Id":2205,"DisplayName":"A.Schulz"},{"Id":867,"DisplayName":"AJed"},{"Id":1636,"DisplayName":"Luke Mathieson"}]} |
Indeed you made a step to resolve ambiguity, but your solution does not give a fully unmabiguous grammar yet. The string $x+x+x$ can be parsed in two different ways, like $x + [x+x]$ or like $[x+x]+x$, where the brackets indicate parses. As far as I see your solution resolves semantical ambiguities (it fixes the relati... |
null |
null |
For the recurrence,
$$
T(n) = T(\sqrt{n}) + 1
$$
Let $n = 2^{2^{k}}$, therefore we can write the recurrence as:
$$
T(2^{2^{k}}) = T(2^{2^{k-1}}) + 1 \\
T(2^{2^{k-1}}) = T(2^{2^{k-2}}) + 1
\\\ldots\\\\\ldots\\
T(2^{2^{k-k}}) = 1
$$
, i.e. $ k * O(1) $ work or linear in $k$. We can express $k$ in terms... |
Given: $T(n) = T(\sqrt{n}) + 1$ (base case $T(x) = 1$ for $x<=2$)
How do you solve such a recurrence? |
Apparently, if $P=NP$, all languages $\in P$ except for $\emptyset$ and $\Sigma^*$ would be $NP-complete$.
Why these two languages in particular? Can't we reduce any other language in $P$ to them by outputting them when accepting or not accepting? |
If $P = NP$, why wouldn't $\emptyset$ and $\Sigma^*$ be $NP-complete$? |
null |
Apparently, if ${\sf P}={\sf NP}$, all languages in ${\sf P}$ except for $\emptyset$ and $\Sigma^*$ would be ${\sf NP}$-complete.
Why these two languages in particular? Can't we reduce any other language in ${\sf P}$ to them by outputting them when accepting or not accepting? |
|np-complete|reductions| |
If P = NP, why wouldn't $\emptyset$ and $\Sigma^*$ be NP-complete? |
Consider an undirected graph with a source and a sink vertex. We would like to remove minimum number of vertices in that graph to disconnect any path between source and sink.
My intuition tells me that we can use max-flow, min-cut algorithm to solve this problem. I don't know whether my solution is correct or not. P... |
remove min number of vertices to disconnect the graph |
|graphs| |
null |
Consider an undirected graph with a source and a sink vertex. We would like to remove minimum number of vertices in that graph to disconnect any path between source and sink.
My intuition tells me that we can use max-flow, min-cut algorithm to solve this problem. I don't know whether my solution is correct or not. P... |
Remove minimum number of vertices to disconnect the graph |
|algorithms|graphs|network-flow| |
null |
null |
I try to understand distributed 6-color algoriht for vertex coloring [Vertex Coloring](http://disco.ethz.ch/lectures/podc_allstars/lecture/chapter1.pdf), page 10.
Here is a short description
Idea of the algorithm: We start with color labels that have log $n$ bits. In each synchronous round we compute a new label... |
Distributed 6-color Vertex Coloring |
|algorithms|distributed-systems|colorings| |
The labels $c_v$ and $c_p$ are relative. So when a node (parent in your example) having $c_v = 1010010000$ receives from its parent (grandparent in your example) an id $c_p = 0010110000$, the difference, as you correctly point out, is in the fifth position.
Now, the total number of bits in the original ids is 10, so... |
The labels $c_v$ and $c_p$ are relative. So when a node (parent in your example) having $c_v = 1010010000$ receives from its parent (grandparent in your example) an id $c_p = 0010110000$, the difference, as you correctly point out, is in the fifth position.
Now, the total number of bits in the original ids is 10, so... |
Here is an algorithm to count distinct subsequences of length $3$ in time $O(n \log n)$, regardless of how many times any value $a$ occurs in $A[j]$.
First, create a binary search tree $T$ containing all possible values $a = A[j]$, storing at each node how many times it occurs in $A$, and how many nodes there are wh... |
Just a note: the previous answers are ok, however you're not too far from the correct trivial reduction:
if $\sf{P} = \sf{NP}$ then any $L \in \sf{NP}$ is Karp reducible to the language $\{1\}$ which is a [sparse language][1]
The converse direction is certainly more interesting and it is known as the [Mahaney's t... |
Just a note: the previous answers are ok, however you're not too far from the correct trivial reduction:
if $\sf{P} = \sf{NP}$ then any $L \in \sf{NP}$ is Karp reducible to the language $\{1\}$ (just map in polynomial time every $x \in L$ to 1, every $x \notin L$ to 0), which is trivially a [sparse language][1]
T... |
null |
Here is an algorithm to count distinct subsequences of length $3$ in time $O(n \log n)$, regardless of how many times any value $a$ occurs in $A[j]$.
First, create a binary search tree $T$ containing all possible values $a = A[j]$, storing at each node how many times it occurs in $A$, and how many nodes there are wh... |
**Yes**, your algorithm is correct. The maximum number of edges that a graph can have without forming a cycle is when it is a tree. Lesser number of edges is only when the graph is disconnected. We will assume that the graph is connected, without loss of generality. In such a case, there would be $|V| - 1$ edges in the... |
1. How is an arithmetic model defined?
What relations are between it and Turing machine? Are they equivalent in some sense?
Is it true that
- in the arithmetic model of computation, the basic arithmetic operations (addition, subtraction, multiplication, division, and
comparison... |
Models of computation: the arithmetic model, Turing machine (and ...) |
|complexity-theory|computation-models| |
1. How is an arithmetic model defined?
What relations are between it and Turing machine? Are they equivalent in some sense?
Is it true that
- in the arithmetic model of computation, the basic arithmetic operations (addition, subtraction, multiplication, division, and
comparison... |
[Wikipedia][1] defines it to be
> An algorithm is said to be of **polynomial time** if its running time is upper bounded by a polynomial expression in the size of the input for the algorithm, i.e., $T(n) = O(n^k)$ for some constant k.
> The algorithm runs in **strongly polynomial time** if [8]
>
> - the numb... |
Definitions of an algorithm running in polynomial time and in strongly polynomial time |
|complexity-theory| |
1. How is an arithmetic model defined?
What relations are between it and Turing machine? Are they equivalent in some sense?
Is it true that
- in the arithmetic model of computation, the basic arithmetic operations (addition, subtraction, multiplication, division, and
comparison... |
1. How is an arithmetic model defined?
What relations are between it and Turing machine? Are they equivalent in some sense?
Is it true that
- in the arithmetic model of computation, the basic arithmetic operations (addition, subtraction, multiplication, division, and
comparison... |
*2. Are there other models of computation distinct from the Turing machine and the arithmetic model?*
- [Tag-systems][1] (and their variations: 2-tag systems, cyclic tag systems, bi-tag systems)
All those models are Turing complete (and can simulate a Turing machine with only polynomial time slowdown). A lot of i... |
*2. Are there other models of computation distinct from the Turing machine and the arithmetic model?*
- [Tag-systems][1] (and their variations: 2-tag systems, cyclic tag systems, bi-tag systems)
All those models are Turing complete (and can simulate a Turing machine with only polynomial time slowdown). A lot of i... |
null |
Let $A$ and $B$ be Turing-recognizable languages. Must language $C = A \cap B$ be Turing-recognizable too?
I have a hunch that it should be because we can construct an enumerator for $C$ by enumerating all the languages in $A$ and then all the languages in $B$.
However, I also know that Turing-recognizable langua... |
Are Turing-recognizable languages closed under intersection? |
|formal-languages| |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.