instruction
stringlengths
0
29.8k
⌀
Hint: $53 \cdot 100000010000000000 + 4 = 5300000530000000004$. Sketch: >! Assume $a$ has $n$ digits and $b$ has $m$ digits. >! If $\overline{x}=10^k \underbrace{00\dots01}_{n}0^l\underbrace{00\dots0}_{m}$ for some $k,l$ then $\overline{ax+b}=\overline{a}0^k \overline{a} 0^l \overline{b}$. >! If $L$ was c...
Hint: $53 \cdot 100000010000000000 + 4 = 5300000530000000004$. Sketch: >! Assume $a$ has $n$ digits and $b$ has $m$ digits. >! >! If $\overline{x}=10^k \underbrace{00\dots01}_{n}0^l\underbrace{00\dots0}_{m}$ for some $k,l$ then >! >! $\overline{ax+b}=\overline{a}0^k \overline{a} 0^l \overline{b}$. >! ...
Hint: $53 \cdot 100000010000000000 + 4 = 5300000530000000004$. Sketch: >! Assume $a$ has $n$ digits and $b$ has $m$ digits. >! >! If $\overline{x}=10^k \underbrace{00\dots01}_{n}0^l\underbrace{00\dots0}_{m}$ for some $k,l$ then >! >! $\overline{ax+b}=\overline{a}0^k \overline{a} 0^l \overline{b}$. >! ...
null
*See the end of this post for some clarification on the definition(s) of min-heap automata.* One can imagine using a variety of data structures for storing information for use by state machines. For instance, push-down automata store information in a stack, and Turing machines use a tape. State machines using queues...
###Closure Properties### Once you have a small collection of non-context-free languages you can often use [closure properties](https://en.wikipedia.org/wiki/Context-free_language#Closure_properties) of $\mathrm{CFL}$ like this: > Assume $L \in \mathrm{CFL}$. Then, by closure property X (together with Y), $L' \in \...
Hint: $53 \cdot 100000010000000000 + 4 = 5300000530000000004$. Sketch: >! Assume $a$ has $n$ digits and $b$ has $m$ digits. >! >! If $\overline{x}=10^k \underbrace{00\dots01}_{n}0^l\underbrace{00\dots0}_{m}$ for some $k,l$ then >! >! $\overline{ax+b}=\overline{a}0^k \overline{a} 0^l \overline{b}$. >! ...
[Markov Chain Monte-Carlo][1] is a technique for efficiently sampling from a complicated probability distribution. No matter what your (discrete) probability distribution, you can set up a markov chain so that the steady-state distribution of a [random walk][2] is the distribution you wish to sample from. You can then ...
Hint: $53 \cdot 100000010000000000 + 4 = 5300000530000000004$. Sketch: >! Assume $a$ has $n$ digits and $b$ has $m$ digits. >! >! If $\overline{x}=10^k \underbrace{00\dots01}_{n}0^l\underbrace{00\dots0}_{m}$ for some $k,l$ then >! >! $\overline{ax+b}=\overline{a}0^k \overline{a} 0^l \overline{b}$. >! ...
I'm looking for a data structure that stores a set of strings over a character set $\Sigma$, capable of performing the following operations. We denote $\mathcal{D}(S)$ as the data structure storing the set of strings $S$. * `Add-Prefix-Set` on $\mathcal{D}(S)$: given some set $T$ of (possibly empty) strings, whose s...
Hint: $53 \cdot 100000010000000000 + 4 = 5300000530000000004$. Sketch: >! Assume $a$ has $n$ digits and $b$ has $m$ digits. >! >! If $\overline{x}=10^k \underbrace{00\dots01}_{n}0^l\underbrace{00\dots0}_{m}$ for some $k,l$ then >! >! $\overline{ax+b}=\overline{a}0^k \overline{a} 0^l \overline{b}$. >! ...
I've came up with a result while reading some automata books, that Turing machines appear to be more powerful than pushdown automata. Since the tape of a Turing machine can always be made to behave like a stack, it'd seem that we can actually claim that TMs are more powerful. Is this true?
Are Turing machines more powerful than pushdown automata?
|automata|finite-automata|pushdown-automata|
If you only consider that 'Turing machines can always be made to behave like a stack' you can only conclude that they are at least as powerful as pushdown automata. But in general, yes it is true, Turing machines are more powerful than PDAs. The easiest example would be to show that Turing machines can describe Cont...
You can't go to the bottom of the stack without "forgetting" the rest of the stack. With a Turing machine you can easily go back and forth on the tape. This simple task cannot be done with a pushdown transducer (roughly the same thing as the pushdown automata, but that can write things at each step), but can easily ...
Turing machines are indeed more powerful than regular PDAs. However in special case of a PDA with two stacks (TPDA or 2-PDA) the TPDA is equally powerful than a turing automata. Basic idea is that in the left stack everything is stored which is left from the head on the turing-tape while the symbol under the hea...
You can recognize the canonical non-context-free (but context-sensitive) language $\{ a^n b^n c^n\ |\ n \geq 1 \}$ with this type of state machine. The crux is that you add tokens to the heap for every $a$ character, and while parsing the $b$ characters, you add 'larger' tokens to the heap, so they only end up at the b...
It is elementary set theory really. You know what is a reflexive relation, what is a symmetric relation, and what is a transitive relation, right? An equivalence relation is one that satisfies all three of those properties. You have probably heard of the "transitive closure" of a relation $R$? Well, it is nothi...
Turing machines are indeed more powerful than regular PDAs. However in special case of a PDA with two stacks (TPDA or 2-PDA) the TPDA is equally powerful than a turing automata. Basic idea is that in the left stack everything is stored which is left from the head on the turing-tape while the symbol under the hea...
|automata|turing-machines|pushdown-automata|
The question is not complete, since a language is a set of words, not pairs. If you encode it as $x\$y$ where $x,y$ are in binary, it is context-sensitive but not context-free (see Gilles's answer), if you encode it as $x\$y^R$ it is context-free but not regular (exercise), if you suitably intersperse bits of $x$ and $...
Many intractable problems can be modeled as deciding whether a set of triples satisfy some no-trivial property. For example, 3-edge coloring of cubic graphs can be modeled as the problem of deciding whether a set of triples satisfy that the elements in each triple must have different color. I'm looking for examples...
Non-trivial tractable properties of triples
|complexity-theory|
For the purposes of this proof we will assume that $\mathrm{USELESS}_{\mathrm{TM}}$ is decidable to display a contradiction. Create TM $R$ that does the following: - Converts TM $M$ to a pushdown automata $P$ with a relaxed stack (ie. no LIFO requirement). This is equivalent to a directed graph detailing the t...
null
Computing Ackermann function is in this spirit. To compute $A(m,n)$ you need to know $A(m,n-1)$ and $A(m-1,k)$ for some large $k$. Either the second coordinate decreases, or the first decreases, and second potentially increases. This does not ideally fit the requirements, since the number of columns is infinite, and...
Many intractable problems can be modeled as deciding whether a set of triples satisfy some no-trivial property. For example, 3-edge coloring of cubic graphs can be modeled as the problem of deciding whether a set of triples satisfy that the elements in each triple must have different color. I'm looking for examples...
Many intractable $NP$-complete problems can be modeled as deciding whether a set of triples satisfy some no-trivial property. For example, 3-edge coloring of cubic graphs can be modeled as the problem of deciding whether a set of triples satisfy that the elements in each triple must have different color. I'm lookin...
|complexity-theory|np-hard|
I'm looking for a data structure that stores a set of strings over a character set $\Sigma$, capable of performing the following operations. We denote $\mathcal{D}(S)$ as the data structure storing the set of strings $S$. * `Add-Prefix-Set` on $\mathcal{D}(S)$: given some set $T$ of (possibly empty) strings, whose s...
_One_ Turing machine is more powerful than _one_ pushdown automaton -- that is a fundamental theorem of automata theory and can be proved in a number of ways. For example, the halting problem for TMs is undecidable -- there is no program (or other TM) that will always give a correct yes-or-no answer to the question: w...
Let $\quad \displaystyle L = \{(i,j,k) \mid i,j,k \in \mathbb{N}, i + j + k \text{ prime}\}.$ Clearly, $|L|=|\overline{L}|=\infty$ as there are both [infinitely many primes](https://en.wikipedia.org/wiki/Euclid%27s_theorem) and non-primes ($2\mathbb{N}$). $L$ is decidable in polynomial time as both addition an...
I think your "non-trivial" property would need to be a property of *sets* of triples, not of triples themselves; i.e. you need that there are an infinite number of *sets* of triples that satisfy and do not satisfy the property. Call a triple consists of 3 identical elements a 3-clone. Checking that a triple is a 3-c...
|complexity-theory|
Many intractable $NP$-complete problems can be modeled as deciding whether a set of triples, {$t_1, t_2, ..., t_n$} where each triple $t_i$ is a subset of three elements over base set $U=$={$a_1, a_2, ..., a_k$}, satisfy some no-trivial property. For example, 3-edge coloring of cubic graphs can be modeled as the proble...
Many intractable $NP$-complete problems can be modeled as deciding whether a set of triples, $F=${$t_1, t_2, ..., t_n$} where each triple $t_i$ is a subset of three elements over base set $U=${$a_1, a_2, ..., a_k$}, satisfy some no-trivial property. For example, 3-edge coloring of cubic graphs can be modeled as the pro...
Many intractable $NP$-complete problems can be modeled as deciding whether a set of triples, $F=${$t_1, t_2, ..., t_n$} where each triple $t_i$ is a subset of three elements over base set $U=${$a_1, a_2, ..., a_k$}, satisfy some no-trivial property. For example, 3-edge coloring of cubic graphs can be modeled as the pro...
Let $S \subseteq \mathbb{N}^3$ with $|S| < \infty$ as requested. We say $\quad \displaystyle P(S)\ \ :\Longleftrightarrow\ \ \forall (i,j,k)\in S.\ i + j + k \text{ prime}.$ Clearly, $P$ is non-trivial as there are both [infinitely many primes](https://en.wikipedia.org/wiki/Euclid%27s_theorem) and non-primes ($2\...
Many intractable $NP$-complete problems can be modeled as deciding whether a set of triples, $F=${$t_1, t_2, ..., t_n$} where each triple $t_i$ is a subset of three elements over base set $U=${$a_1, a_2, ..., a_k$}, satisfy some no-trivial property. For example, 3-edge coloring of cubic graphs can be modeled as the pro...
I believe I have a reasonable grasp of complexities like $O(1)$, $\theta(n)$ and $\theta(n^2)$. In terms of a list, $O(1)$ is a constant lookup, so it's just getting the head of the list. $\theta(n)$ is where I'd walk the entire list, and $\theta(n^2)$ is walking the list once for each element in the list. Is th...
Many intractable $NP$-complete problems can be modeled as deciding whether a set of triples, $F=${$t_1, t_2, ..., t_n$} where each triple $t_i$ is a subset of three elements over base set $U=${$a_1, a_2, ..., a_k$}, satisfy some non-trivial property. For example, 3-edge coloring of cubic graphs can be modeled as the pr...
Many intractable $NP$-complete problems can be modeled as deciding whether a set of triples, $F=${$t_1, t_2, ..., t_n$} where each triple $t_i$ is a subset of three elements over base set $U=${$a_1, a_2, ..., a_k$}, satisfy some non-trivial property. For example, 3-edge coloring of cubic graphs can be modeled as the pr...
Let $S \subseteq \mathbb{N}^3$ with $|S| < \infty$ and $P_1(S)$ where $\quad \displaystyle P_1(S)\ \ :\Longleftrightarrow\ \ \forall (i,j,k)\in S. i,j,k \text{ mutually coprime }.$ $P_1$ is clearly non-trivial as requested. We say furthermore $\quad \displaystyle P_2(S)\ \ :\Longleftrightarrow\ \ \forall (i,j,...
### Choose a data representation First, look at the size of the result. You want the collection of shortest paths from $s$ to every other node. Unless the average length of a path is bounded by a constant (which it isn't: any list is unipath, and if you take the root for $s$ the total length of the paths is $n(n-1)/...
null
**Claim**: Red-black trees can be arbitrarily un-$\mu$-balanced. **Proof Idea**: Fill the right subtree with as many nodes as possible and the left with as few nodes as possible for a given number $k$ of black nodes on every root-leaf path. **Proof**: Define a sequence $T_k$ of red-black trees so that $T_k$ has $...
**Claim**: No, there is no such $\mu$. **Proof**: We give an infinite sequence of AVL trees of growing size whose weight-balance value tends to $0$, contradicting the claim. Let $C_h$ the complete tree of height $h$; it has $2^{h+1}-1$ nodes. Let $S_h$ the *Fibonacci tree* of height $h$; it has $F_{h+2} - 1$ n...
A unipathic graph is a directed graph such that there is at most one simple path from any one vertex to any other vertex. Unipathic graphs can have cycles. For example, a doubly linked list (not a circular one!) is a unipathic graph; if the list has $n$ elements, the graph has $n-1$ cycles of length 2, for a total o...
How many edges can a unipathic graph have?
|graphs|
Do not forget that $\log n$ still grows exponentially (in $\log(n)$) faster than $\log(\log n)$! Indeed, if you look at the quotient of $\log(n)$ and $\log(\log(n))$, there is not much impressive to see: ![log(n)/log(log(n))][1] <sup>[[source](http://verrech.net/sefiles/cs_654.gnuplot)]</sup> But still, you...
First of all, $2$ should not be a final state. As it is (assuming $1$ is starting state), `/` is accepted. Furthermore, you can not accept comments that contain `*` because after reading `*` you can never get back into $3$ (without reading `/`). Consider this automaton instead: ![automaton][1] <sup>[[source](h...
An important application are [Hidden Markov Models](https://en.wikipedia.org/wiki/Hidden_Markov_model) which essentially assume the underlying random distribution follows a Markov chain. One exiting application of HMMs is [gene prediction](https://en.wikipedia.org/wiki/Gene_prediction) in bioinformatics. The task is to...
Consider directed graphs. We call a node $v$ *superstar* if and only if no other node can be reached from it, but all other nodes have an edge to $v$. Formally: $\qquad \displaystyle $v$ \text{ superstar } :\Longleftrightarrow \mathrm{outdeg}(v) = 0 \land \mathrm{indeg}(v) = n-1$ with $n$ the number of nodes in t...
Let $S \subseteq \mathbb{N}^3$ with $|S| < \infty$ and $P_1(S)$ where $\quad \displaystyle P_1(S)\ \ :\Longleftrightarrow\ \ \forall (i,j,k)\in S. i,j,k \text{ mutually coprime }.$ $P_1$ is clearly non-trivial as requested. We say furthermore $\quad \displaystyle P_2(S)\ \ :\Longleftrightarrow\ \ \forall (i,j,...
Fredman and Saks in "The cell probe complexity of dynamic data structures" showed that you can do no better than $\Theta\left(\frac{\lg m}{\lg \lg m}\right)$ on this problem, which they called simply "list representation" [Dietz presented a data structure in "Optimal Algorithms for List Indexing and Subset Rank"](h...
Fredman and Saks in ["The cell probe complexity of dynamic data structures"](http://dl.acm.org/citation.cfm?id=73007.73040) showed that you can do no better than $\Theta\left(\frac{\lg m}{\lg \lg m}\right)$ on this problem, which they called simply "list representation" [Dietz presented a data structure in "Optimal ...
2-4 trees have amortized $O(1)$ modifications at known locations. That is to say, if you have a pointer to some location in the tree, you can remove or add an element there in $O(1)$ amortized time. You can thus just keep a pointer to the minimum element and the root node in a 2-4 tree. Inserts should go through the...
In a nutshell, Markov chains are used to model correlated stochastic processes; a broad class of signals. If the value of the signal at any moment can be well approximated by a function of the signal values at a limited number of the the preceding moments, then a Markov model is appropriate.
In terms of (balanced) trees (say, binary tree, so all $\log$'s are base 2): - $O(1)$ is getting the root of the tree - $O(\log n)$ is a walk from root to leaf - $O(n)$ is traversing all nodes of the tree - $O(n^2)$ is actions on all the subsets two nodes in the tree, e.g., the number of different paths betwe...
|probability-theory|randomness|randomized-algorithms|
Turing machines are indeed more powerful than regular PDAs. However in special case of a PDA with two stacks (TPDA or 2-PDA) the TPDA is equally powerful than a turing automata. The basic idea is that you can simulate the TM's tape using two stacks: in the left stack everything is stored which is left from the h...
null
Assume we are working in a Turing-complete, referentially-transparent, higher-order language that supports arbitrary dataflow unification. Shouldn't it then be possible to construct the following function (using Haskell-like syntax, because that's what I'm most familiar with)? -- Takes an arbitrary pure functio...
Delimited Continuations + Dataflow Unification = Arbitrarily invertible (pure, nonrecursive) functions?
|programming-languages|
null
Dataflow unification behaves as you expect on first-order data (numbers, booleans, lists, trees, etc.) but can fail for higher-order data such as functions. In general, unifying functions requires using full higher-order unification, which has terrible performance, up to and including frequent failure to terminate (as ...
Assume we are working in a Turing-complete, referentially-transparent, higher-order language that supports arbitrary dataflow unification. Shouldn't it then be possible to construct the following function (using Haskell-like syntax, because that's what I'm most familiar with)? -- Takes an arbitrary pure functio...
The thing is that even if you know nothing about $m_1$ and $m_2$, you might be able to recover them both from $m_1 \oplus m_2$. Actually, for many cases, it is very simple. [Here's](http://www.cryptosmith.com/book/export/html/78) a simple visualization.
Fredman and Saks show in [The cell probe complexity of dynamic data structures](http://dl.acm.org/citation.cfm?id=73007.73040) that you can do element lookup (by index) no better than $\Theta\left(\frac{\lg m}{\lg \lg m}\right)$ amortised number of element accesses in this setting, which they called simply "list repres...
I believe I have a reasonable grasp of complexities like $\mathcal{O}(1)$, $\Theta(n)$ and $\Theta(n^2)$. In terms of a list, $\mathcal{O}(1)$ is a constant lookup, so it's just getting the head of the list. $\Theta(n)$ is where I'd walk the entire list, and $\Theta(n^2)$ is walking the list once for each element i...
The usual proof is one with detour. 1. Show that pushdown-automata accept exactly the [context-free languages](https://en.wikipedia.org/wiki/Context-free_languages), the set of languages accepted by context-free grammars. (found in any text book on the matter) 2. Note that Turing machines accept all recursive lan...
|graphs|combinatorics|
If I understand well, NFA has the same expressive power as regular expressions. However, Consider the following NFA. Its intial states is its leftmost node, terminating states are all the other. Its transition rules are expressed by te arcs. This NFA recognizes words like "x f g i f g h j g i f g" etc. But I find ...
How can we express this NFA as regular expressions?
|untagged|
|automata|regular-languages|
If I understand well, NFA has the same expressive power as regular expressions. However, Consider the following NFA. Its intial states is its leftmost node, terminating states are all the other. Its transition rules are expressed by te arcs. This NFA recognizes words like `x f g i f g h j g i f g` etc. But I find ...
There are canoncial methods to do this. By far the nicest I have seen is one that expresses the automaton as equation system of (regular) languages which can be solved. It is in particular nice as it seems to yield more concise expressions than other methods. I wrote [this document](http://lmazy.verrech.net/wp-conte...
If I understand well, NFA has the same expressive power as regular expressions. However, Consider the following NFA. ***Its intial states is its leftmost node, terminating states are all the others***. Its transition rules are expressed by te arcs. This NFA recognizes words like `x f g i f g h j g i f g` etc. Coul...
null
If I understand correctly, NFA have the same expressive power as regular expressions. However, consider the following NFA; it recognizes words like `x f g i f g h j g i f g` etc. Could you give me the regular expression that is equivalent to the NFA? Thank you. ![enter image description here][1] <sup>[[sou...
null
|finite-automata|regular-expressions|
If I understand correctly, NFA have the same expressive power as regular expressions. Often, reading off equivalent regular expressions from NFA is easy: you translate cycles to stars, junctions as alternatives and so on. But what to do in this case: ![enter image description here][1] <sup>[[source](http://verre...
How to convert an NFA with overlapping cycles into a regular expression?
Rather than "reading off" you should employ one of several canoncial methods to do this. By far the nicest I have seen is one that expresses the automaton as equation system of (regular) languages which can be solved. It is in particular nice as it seems to yield more concise expressions than other methods. I wrote ...
Short Answer ====== The cache efficiency argument has already been explained in detail. In addition, there is an intrinsic argument, why Quicksort is fast. If implemented like with two “crossing pointers”, [e.g. here](http://algs4.cs.princeton.edu/23quicksort/Quick.java.html), the inner loops have a very small body. ...
Short Answer ====== The cache efficiency argument has already been explained in detail. In addition, there is an intrinsic argument, why Quicksort is fast. If implemented like with two “crossing pointers”, [e.g. here](http://algs4.cs.princeton.edu/23quicksort/Quick.java.html), the inner loops have a very small body. ...
If there was just a chain of states with no loop, would you know what to do? If there was a simple loop without this overlapping branching, would you know what to do? (If the answer is “no”, think about these cases first.) Now, the idea is to transform the automaton progressively to put it in a form where you ...
Rather than "reading off" you should employ one of several canoncial methods to do this. By far the nicest I have seen is one that expresses the automaton as equation system of (regular) languages which can be solved. It is in particular nice as it seems to yield more concise expressions than other methods. I wrote ...
A unipathic graph can have $\Theta(n^2)$ edges. There's a well-known kind of graph that's unipathic and has $n^2/4$ edges. >! Consider a complete bipartite graph, with oriented edges $\forall (i,j) \in [1,m]^2, a_i \rightarrow b_j$. This graph is unipathic and has no cycle: all its paths have length $1$. It has $2m$...
null
In a standard algorithms course we are taught that **quicksort** is $O(n \log n)$ on average and $O(n^2)$ in the worst case. At the same time, other sorting algorithms are studied which are $O(n \log n)$ in the worst case (like **mergesort** and **heapsort**), and even linear time in the best case (like **bubblesort**)...
Rather than "reading off" you should employ one of several canoncial methods to do this. By far the nicest I have seen is one that expresses the automaton as equation system of (regular) languages which can be solved. It is in particular nice as it seems to yield more concise expressions than other methods. I wrote ...
Short Answer ====== The cache efficiency argument has already been explained in detail. In addition, there is an intrinsic argument, why Quicksort is fast. If implemented like with two “crossing pointers”, [e.g. here](http://algs4.cs.princeton.edu/23quicksort/Quick.java.html), the inner loops have a very small body. ...