instruction
stringlengths
0
29.8k
⌀
For counting many types of combinatorial objects, like trees in this case, there are powerful mathematical tools (the symbolic method) that allow you to mechnically derive such counts from a description how the combinatorial objects are constructed. This involves generating functions. An excellent reference is [Anal...
No, this is not the same as a DFS. Consider the graph ![enter image description here][1] If you push the nodes in right to left order, the algorithm gives you a traversal: $A, B , E, C , D$ while a DFS would expect it to be $A,B,E,D,C$ The problem occurs because you mark it as seen at the time of...
First we must assume that Eve is only passive. By this, I mean that she truthfully sends the card to Bob, and whatever she brings back to Alice is indeed Bob's response. If Eve can alter the data in either or both directions (and her action remains undetected) then anything goes. (To honour long-standing traditions,...
For counting many types of combinatorial objects, like trees in this case, there are powerful mathematical tools (the symbolic method) that allow you to mechnically derive such counts from a description how the combinatorial objects are constructed. This involves generating functions. An excellent reference is [Anal...
Here is the answer which elaborates upon the algorithm from the paper linked by Joe: http://arxiv.org/abs/0805.1598 First let us consider a $\Theta(n \log n)$ algorithm which uses divide and conquer. **1) Divide and Conquer** We are given $$a_1, a_2, \dots , b_1, b_2, \dots b_n$$ Now to use divide and...
http://cs.stackexchange.com/questions/367/how-can-it-be-decidable-whether-pi-has-some-sequence-of-digits inspired me to ask whether the following innocent-looking variation is computable: $$f(n) = \begin{cases} 1 & \text{if \(\bar n\) occurs in the decimal representation of \(\pi\)} \\ 0 & \text{otherwise} \\ ...
Is a function looking for subsequences of digits of $\pi$ computable?
|computability|real-numbers|
Here is the answer which elaborates upon the algorithm from the paper linked by Joe: http://arxiv.org/abs/0805.1598 First let us consider a $\Theta(n \log n)$ algorithm which uses divide and conquer. **1) Divide and Conquer** We are given $$a_1, a_2, \dots , b_1, b_2, \dots b_n$$ Now to use divide and...
I apologize in advance for that I give way too many details, but I'm about to contradict people. <h3>About $K(x)≤K'(x)+c$</h3> The fact that $K_1(x)≤K_2(x)+c$ usually comes from an **interpreter** of the description language #2 into the description language #1 and **not** from a translation from programs of #2 in...
To my knowledge the pumping lemma is *by far* the simplest and most-used technique. If you find [it][1] hard, try the [regular version][2] first, it's not that bad. There are some other means for languages that are far from context free. For example undecidable languages are trivially not context free. That said, I ...
I apologize in advance for that I give way too many details, but I'm about to contradict people. <h3>About $K(x)≤K'(x)+c$</h3> The fact that $K_1(x)≤K_2(x)+c$ usually comes from an **interpreter** of the description language #2 into the description language #1 and **not** from a translation from programs of #2 in...
I'm learning programming in ML (OCaml), and earlier I asked about [ML functions of type `'a -> 'b`](http://cs.stackexchange.com/questions/302/ml-function-of-type-a-b). Now I've been experimenting a bit with functions of type `'a list -> 'b list`. There are some obvious simple examples: let rec loop l = loop l ...
Here is the answer which elaborates upon the algorithm from the paper linked by Joe: http://arxiv.org/abs/0805.1598 First let us consider a $\Theta(n \log n)$ algorithm which uses divide and conquer. **1) Divide and Conquer** We are given $$a_1, a_2, \dots , b_1, b_2, \dots b_n$$ Now to use divide and...
I'm pretty sure I've found an algorithm that does not rely on number theory or cycle theory. Note that there are a few details to work out (possibly tomorrow), but I'm quite confident they will work out. I handwave as I'm supposed to be sleeping, not because I'm trying to hide problems :) Let's take an array of 16 n...
Note that $f$ can be the constant $1$ even if $\pi$ is not a normal number. (In French we say if $f$ is constant that $\pi$ is a _[nombre univers][1]_. I don't know the corresponding term in English) For what it's worth: _it could be_, in the following way: Proving $f$ is computable would not necessarily imply th...
For the second example, you can't claim that $$i = O(1)$$ since $i$ varies with $n$. After few steps it will be the case that $i>n/2$. A more appropriate way is to say that $i = O(n)$ since indeed, throughout the summation $i$ never exceeds $1\cdot n$. By this reasoning, $$\sum_{i=1}^n i = \sum_{i=1}^n O(n)= nO(n)...
If you like to visualize it, use the venn diagrams. See [this][1], for instance. I find it more simple just to memorize the basic 2 laws: everytime you "break" a negation line, you replace the AND to OR (or vice versa). Adding two negation lines changes nothing (but gives you more "lines" to break). It just works. ...
It seems that for this model, non-determinism and determinisn are not equivalent, for basically the same reason that works for PDAs. Consider the language $$L =\\{ x\$y \mid |x|=|y| \wedge x\ne y\\}$$ (where $\$$ is a special sign not contained in $x$ and $y$. I don't have the formal proof, but here're my thoug...
Given an instance of SAT, I would like to be able to estimate how difficult it will be to solve the instance. One way is to run existing solvers, but that kind of defeats the purpose of estimating difficulty. A second way might be looking a the ratio of clauses to variables, as is done for phase transitions in rando...
Measuring the difficulty of SAT instances
|complexity-theory|satisfiability|heuristics|
It seems that for this model, non-deterministic machines are not equivalent to deterministic ones, for basically the same reason that deterministic PDAs are not equivalent to non-deterministic ones. I don't have the formal proof, but here are my thoughts: Consider the language $$L =\\{ x\$y \mid |x|=|y| \wedge x...
|algorithms|cryptography|
|complexity-theory|np-hard|encryption|cryptography|
|information-theory|encryption|cryptography|otp|
|cryptography|pseudo-random|
|asymptotics|landau-notation|
|cryptography|information-theory|encryption|
|formal-languages|automata|nondeterminism|
|formal-languages|automata|regular-languages|nondeterminism|
|automata|compilers|dfa|
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...
How to find a superstar in linear time?
|algorithms|graphs|
* Store your graph as a pair of adjacency list and reverse adjacency list, where each list contains in addition the length of the list. * Traverse the lists and select any node where the number of out-edges is $0$ and the number of in-edges is $n-1$.
* Store your graph as a pair of adjacency list and reverse adjacency list, where each list contains in addition the length of the list, hence the number out- and in-edges, respectively. * Traverse the lists and select any node where the number of out-edges is $0$ and the number of in-edges is $n-1$.
Here is another idea that aims at (injectively) encoding the structure of trees into numbers, rather than just labelling them arbitrarily. For that, we use that any number's prime factorisation is unique. For our purposes, let $E$ denote an empty position in the tree, and $N(l,r)$ a node with left subtree $l$ and ri...
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...
_This answer addresses the version of the question where any graph representation was possible, not the current version of the question._ * Store your graph as a pair of adjacency list and reverse adjacency list, where each list contains in addition the length of the list, hence the number out- and in-edges, respect...
_This answer addresses the version of the question where any graph representation was possible, not the current version of the question._ * Store your graph as a pair of adjacency list and reverse adjacency list, where each list contains in addition the length of the list, hence the number out- and in-edges, respect...
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...
|formal-languages|automata|regular-languages|finite-automata|nondeterminism|
|automata|compilers|finite-automata|
Consider unlabeled, rooted binary trees. We can *compress* such trees: whenever there are pointers to subtrees $T$ and $T'$ with $T = T'$ (interpreting $=$ as structural equality), we store (w.l.o.g.) $T$ and replace all pointers to $T'$ with pointers to $T$. See [uli's answer](http://cs.stackexchange.com/a/177/98) for...
Efficiently compression of unlabeled trees
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: ![enter image description here][1] ...
Efficient compression of unlabeled trees
|formal-languages|regular-languages|
|formal-languages|automata|formal-grammars|pushdown-automata|
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] It is straight f...
Construction and analysis of protocols and algorithms for secure communication.
null
**Claim**: $\mathrm{HAL}$ is *not* closed against complement. **Proof Idea**: We have [agreed](http://cs.stackexchange.com/a/114/98) that $\mathrm{EPAL}$ (the language of even palindromes over a non-unary alphabet) is not in $\mathrm{HAL}$. We show that $\overline{\mathrm{EPAL}} \in \mathrm{HAL}$. **Proof**: Note...
**Claim**: $\mathrm{HAL}$ is *not* closed against complement. **Proof Idea**: We have [agreed](http://cs.stackexchange.com/a/114/98) that $\mathrm{EPAL}$ (the language of even palindromes over a non-unary alphabet) is not in $\mathrm{HAL}$. We show that $\overline{\mathrm{EPAL}} \in \mathrm{HAL}$. **Proof**: Note...
Minimum bandwidth problem is to a find an ordering of graph nodes on integer line that minimizes the largest distance between any two adjacent nodes. The decision problem is NP-complete even for binary trees. Complexity Results for Bandwidth Minimization. Garey, Graham, Johnson and Knuth, SIAM J. Appl. Math., Vol. ...
Approximation of minimum Bandwidth on binary trees
|complexity-theory|approximation|
http://cs.stackexchange.com/questions/367/how-can-it-be-decidable-whether-pi-has-some-sequence-of-digits inspired me to ask whether the following innocent-looking variation is computable: $$f(n) = \begin{cases} 1 & \text{if \(\bar n\) occurs in the decimal representation of \(\pi\)} \\ 0 & \text{otherwise} \\ ...
EDIT: 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 qu...
OK, I got this. We can do it looking at each node between once and twice. Store the graph as an adjacency matrix, a table of `[from, to]`, each spot being a boolean: from v 1 2 3 4 t 1 - o 2 - 3 - 4 - The theory is that we can eliminate one possibility with each...
[A simple solution would be:][1] Both Alice and Bob agree on the same colour. and it's no problem if Eve knows that one, we'll call this P. Let's say it's yellow. Now, Alice and Bob both randomly choose a private colour, say "x". Alice chooses red, and Bob chooses blue. Now they mix them together with the P. Alice n...
We can eliminate all but one of the vertices by checking for the existence of $n-1$ edges because we can eliminate one possibility for each edge we check. If there is an edge going from $x$ to $y$, we eliminate $x$ and move on to $y$ (as another vertex can be reached from it); if not, we eliminate $y$ (as it cannot be ...
Isn't this the [Celebrity Problem][1]? There will only be one superstar(celebrity) if there is one. We use the adjacency matrix representation, where $A[i,j] = 1$ if there is a directed edge from $i$ to $j$, otherwise it is $0$. (I am guessing that is allowed). By looking at $A[i,j]$ (can be done in $\mathcal{...
I've always thought vaguely that the answer to the above question was affirmative along the following lines. Gödel's incompleteness theorem and the undecidability of the halting problem both being negative results about decidability and established by diagonal arguments (and in the 1930's), so they must somehow be two ...
Is there any concrete relation between Gödel's incompleteness theorem, the halting problem and universal Turing machines?
|computability|logic|
Neel Krishnaswami's answer here points to references connecting the above results under the umbrella of category theory: http://cstheory.stackexchange.com/questions/10635/halting-problem-uncomputable-sets-common-mathematical-proof/10636#10636
In a previous [question][1] there was a definition of weight balanced trees and a question regarding red-black trees. This question is to ask the same question, but for AVL trees. The question is, given the definition of $\mu$-balanced trees as in the other question, > Is there some $\mu \gt 0$ such that all...
AVL trees are not weight-balanced?
|data-structures|binary-trees|
In a previous [question][1] there was a definition of weight balanced trees and a question regarding red-black trees. This question is to ask the same question, but for [AVL trees][2]. The question is, given the definition of $\mu$-balanced trees as in the other question, > Is there some $\mu \gt 0$ such tha...
Neel Krishnaswami's answer to [*Halting problem, uncomputable sets: common mathematical proof?* on CSTheory](http://cstheory.stackexchange.com/questions/10635/halting-problem-uncomputable-sets-common-mathematical-proof/10636#10636) points to references connecting the above results under the umbrella of category theory...
One of the most basic things you can do is a [Diffie-Hellman key exchange](https://en.wikipedia.org/wiki/Diffie%E2%80%93Hellman_key_exchange). It does not require you to have keys set up before the communication starts as it negotiates one in a way that listeners can not derive the key themselves. See the comprehensive...
Universal Turing machines are useful for some diagonal arguments, e.g in the separation of some classes in the [hierarchies of time][1] or [space][2] complexity: the universal machine is used to prove there is a decision problem in $\mbox{DTIME}(f(n)^3)$ but not in $\mbox{DTIME}(f(n/2))$. (Better bounds can be found in...
There is an easy polynomial algorithm to decide whether there is a path between two nodes in a directed graph (just do a routine graph traversal with, say, depth-first-search). However it seems that, surprisingly, the problem gets much harder if instead of testing for the existence we want want to *count* the number...
How hard is counting the number of simple paths between two nodes in a directed graph?
|time-complexity|graphs|
**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...
We can eliminate all but one of the vertices by checking for the existence of $n-1$ edges because we can eliminate one possibility for each edge we check. In particular, if there is an edge going from $x$ to $y$, we eliminate $x$ and move on to $y$ (as another vertex can be reached from it); if not, we eliminate $y$ (a...
Just for reference, this is pseudocode of a recursive version of what Kevin posted. superstar(V, E) { if ( |V| == 1 ) { return V.pop } a = V.pop b = V.pop if ( (a,b) ∈ E ) { no_ss = a keep = b } else { no_ss = b ...
There is an easy polynomial algorithm to decide whether there is a path between two nodes in a directed graph (just do a routine graph traversal with, say, depth-first-search). However it seems that, surprisingly, the problem gets much harder if instead of testing for the existence we want want to *count* the number...
We can eliminate all but one of the vertices by checking for the existence of $n-1$ edges because we can eliminate one possibility for each edge we check. In particular, if there is an edge going from $x$ to $y$, we eliminate $x$ and move on to $y$ (as another vertex can be reached from it); if not, we eliminate $y$ (a...
Definition from wikipedia: > A graph is an ordered pair G = (V, E) comprising a set V of vertices together with a set E of edges, which are 2-element subsets of V. The sets of all finite graphs is countable and could be enumerated. But what would be an *efficient* (low-complexity, from a programming point of view) ...
An indexing function for graphs
|algorithms|graphs|
Show that the language of non-squares is context-free
An (unlabeled) graph $G$ is uniquely described by its adjacency matrix. Concatenating the matrix's rows yields a natural number $\cal{G}$ in binary representation; in order to deal with leading $0$, prepend a $1$. This mapping is obviously injective. For easier decoding, you might want to use [Cantor's pairing function...
Definition from wikipedia: > A graph is an ordered pair G = (V, E) comprising a set V of vertices together with a set E of edges, which are 2-element subsets of V. The sets of all finite graphs (modulo isomorphism) is countable and could be enumerated. But what would be an *efficient* (low-complexity, from a progra...
Definition from wikipedia: > A graph is an ordered pair $G = (V, E)$ comprising a set $V$ of vertices together with a set $E$ of edges, which are two-element subsets of $V$. The sets of all finite graphs (modulo isomorphism) is countable and could be enumerated. But what would be an *efficient* (low-complexity, fro...
An (unlabeled) graph $G$ is uniquely described by its adjacency matrix. Concatenating the matrix's rows yields a natural number $\cal{G}$ in binary representation; in order to deal with leading $0$, prepend a $1$. This mapping is obviously injective. For easier decoding, you might want to use [Cantor's pairing function...
Definition from wikipedia: > A graph is an ordered pair $G = (V, E)$ comprising a set $V$ of nodes together with a set $E$ of edges, which are two-element subsets of $V$. The set of all finite graphs (modulo isomorphism: we don't want nodes to have identities) is countable and could be enumerated. But what would be...
Definition from wikipedia: > A graph is an ordered pair $G = (V, E)$ comprising a set $V$ of nodes together with a set $E$ of edges, which are two-element subsets of $V$. The set of all finite graphs (modulo isomorphism: we don't want nodes to have identities) is countable and could be enumerated. But what would be...
A graph $G$ whose nodes are numbered is uniquely described by its adjacency matrix. Concatenating the matrix's rows yields a natural number $\cal{G}$ in binary representation; in order to deal with leading $0$, prepend a $1$. This mapping is obviously injective. For easier decoding, you might want to use [Cantor's pair...
null
**Claim**: $L$ is context-free. **Proof Idea**: There has to be at least one difference between the first and second half; we give a grammar that makes sure to generate one and leaves the rest arbitrary. **Proof**: For sake of simplicity, assume a binary alphabet $\Sigma = \{a,b\}$. The proof readily extends to o...
In one of the programming tutorial at my university, we asked students to compare the performance of quicksort, mergesort, insertion sort vs. the built-in list.sort (called [Timsort][1]). The experimental results surprised me deeply since the built-in list.sort performed so much better than other sorting algorithms, ev...
I was searching for interesting and easy to state open problems in computability (understandable by undergraduate students taking their first course in computability) to give examples of open problems (and obviously I want the students to be able to understand the problem without needing too much new definitions and al...