instruction
stringlengths
0
29.8k
⌀
Suppose we're receiving numbers in a stream. After each number is received, a weighted sum of the last N numbers needs to be calculated, where the weights are always the same, but arbitrary. How efficiently can this done if we are allowed to keep a data structure to help with the computation? Can we do any better than ...
I can't wrap my head around how the SR Latch works. Seemingly, you plug an input line from R, and another from S, and you are supposed to get results in $Q$ and $Q'$. However, both R and S require input from the other's output, and the other's output requires input from the other other's output. What comes first ...
How to understand the SR Latch
|circuits|sequential-circuit|
null
I'm trying to understand the theory of quantum computing, and I'm a bit confused on a particular circuit: ![https://i.stack.imgur.com/WWvxr.png][1] Would the controlled NOT gate be a type of measurement, causing Q1 to be either |0> or |1>, or would the circuit be in a superposition of the |00> and |11> states u...
Controlled NOT gate a type of measurement?
|quantum-computing|
null
From an answer to a [related question on **NP**-hard problems which are not contained in **NP**](http://cs.stackexchange.com/a/9064/2152): probably the most natural example is determining whether two regular expressions (including the Kleene star for arbitrary repetition, and a squaring operation to allow compact expre...
I'm doing a practice test for a course on routing problems. There's a question asking to infere the time complexity of the 2-opt method. I can see that the complexity per iteration is in O(n^2) because you need to check all combinations of 2 arcs. I don't know how to calculate the worst case number of iterations tho...
Time complexity 2-opt method
|algorithms|heuristics|routing|
I'll elaborate what I wrote in my comment above: A controlled-NOT gate is meant to be a reversible operation which, for ordered pairs of bits $(a,b) \in \{0,1\}^2$, performs the operation $$ \mathrm{CNOT} (a,b)\; = \;(a, b \oplus a)$$ where conventionally we represent the "control" by the first bit and the "target...
I'm doing a practice test for a course on routing problems. There's a question asking to infere the time complexity of the 2-opt method. I can see that the complexity per iteration is in $O(n^2)$ because you need to check all combinations of 2 arcs. I don't know how to calculate the worst case number of iterations t...
A controlled-NOT gate is meant to be a reversible operation which, for ordered pairs of bits $(a,b) \in \{0,1\}^2$, performs the operation $$ \mathrm{CNOT} (a,b)\; = \;(a, b \oplus a)$$ where conventionally we represent the "control" by the first bit and the "target" by the second. (In a physical implementation, esse...
Let $A= \{L \mid \text{L is accepted by 1-counter automata and L' is accepted by some other 1-counter automata} \}$ clearly $\text{Deterministic 1-Counter} \subset A$ Is it the case that $ A = \text{Deterministic 1-Counter} ?$ I know that for PDA, this is not the case. $P =\{ ww^r\}$ Then P and P' b...
defining a class for one counter automata
|automata|pushdown-automata|
Let $A= \{L \mid L \;\text{is one-counter and}\; \bar{L} \;\text{is also one-counter} \}$ clearly $\text{Deterministic one-counter} \subseteq A$ Is it the case that $ A = \text{Deterministic one-counter} ?$ I know that for context-free languages the analogue is not the case. For example: Let $P =\{ ww^...
Does there exist a strictly non-deterministic one-counter language whose complement is one-counter?
null
Let $A= \{L \mid L \;\text{is one-counter and \(\bar{L}\) is also one-counter} \}$ Clearly, $\text{Deterministic one-counter} \subseteq A$ Is it the case that $ A = \text{Deterministic one-counter}$? I know that for context-free languages the analogue is not the case. For example, let $P =\{ ww^r\}$. Then ...
Is there a strictly non-deterministic one-counter language whose complement is one-counter?
null
Given any graph $G$ on $V(G)=\{1,\dots,n\}$ and its adjacency matrix $$A(G)=\left(\matrix{ A_{1,1} & A_{1,2} & \dots & A_{1,n}\\ A_{2,1} & A_{2,2} & \dots & A_{2,n}\\ &&\dots&\\ A_{n,1} & A_{n,2} & \dots & A_{n,n} }\right)$$ any permutation on $\{1,\dots,n\}$ defines a new isomorphic graph $G'$. A common approa...
Let $P$ be the set of people and $\mathcal{S}$ be the modified multi-set of subsets. By checking if a $P$-saturated matching into $\mathcal{S}$ exists (i.e. [Hall's condition](http://en.wikipedia.org/wiki/Hall's_marriage_theorem)) you are indeed checking that your groups are diverse. If you are "checking" if some group...
Here is an EBNF grammar with precedence of operators enforced. $\text{exp} \to \text{term } \{ \text{OR term}\};$ $\text{term} \to \text{factor } \{\text{AND factor}\};$ $\text{factor} \to \text{id};$ $\text{factor} \to \text{NOT factor};$ $\text{factor} \to \text{LPAREN exp RPAREN};$ TRUE and FALSE a...
Here is another version of Yuval's algorithm that uses two loops only. int number_of_ones = 0; for(int i = 0; i < 100; ++ i) { number_of_ones += A[i]; A[i] = 0; } for(i = 100 - number_of_ones; i < 100; ++ i) { A[i] = 1; }
Graph searching: Breadth-first vs. depth-first
Suppose we're receiving numbers in a stream. After each number is received, a weighted sum of the last $N$ numbers needs to be calculated, where the weights are always the same, but arbitrary. How efficiently can this done if we are allowed to keep a data structure to help with the computation? Can we do any better...
null
Decidability of prefix language
One reason for CISC was to have dense encoding for instructions (memory was _expensive_). The whole RISC idea was to speed up the CPU by fetching the same size instructions all the time (no complex, slow "figure out instruction size" step), have them do simple things (so it is fast to figure out what to do). Memory was...
everyone! This is a tough question about recurrence relation that contains sum inside the recursion.I am totally stuck and feeling depressed about it. Can anyone help ? The problem asks to solve the following recursion $T(n)=\frac{1}{n} \sum_{i=1}^{n-1}(T(i)+T(n-i))+cn$. The problem also warns that unwrapping is ...
recurrence relation with sum
|recurrence-relation|
I was reading about Universal Turing Machines. I see that the maching lemma states, that between two symbols X and Y, if there are only 1-s and blanks, then a TM exists, which can count the number of ones. This is used to match strings of ones between two tapes. Now I wonder, would there also be a TM or a meth...
Maching Lemma with infinitely many symbols
|turing-machines|
null
The trick here is to get rid of the sum. Note that the sum is up and down, it can be replaced by twice up: $$ \begin{align*} (n + 1) T(n + 1) &= 2 \sum_{1 \le k \le n} T(k) + c (n + 1)^2 \\ n T(n) &= 2 \sum_{1 \le k \le n - 1} T(k) + c n^2 \\ (n + 1) T(n + 1) - n T(n) &= 2 T(n) + c (2 n + 1) \end{...
Turing machines can simulate whatever algorithm you can actually program. So if you can solve your problem by writing a program in C or python (for example), then a Turing machine can also solve your problem. The most general statement of this principle - everything that is computable can be computed using a Turing ...
I was reading about Universal Turing Machines. I see that the matching lemma states, that between two symbols X and Y, if there are only 1-s and blanks, then a TM exists, which can count the number of ones. This is used to match strings of ones between two tapes. Now I wonder, would there also be a TM or a met...
Matching Lemma with infinitely many symbols
Turing machines can simulate whatever algorithm you can actually program. So if you can solve your problem by writing a program in C or python (for example), then a Turing machine can also solve your problem. The most general statement of this principle - everything that is computable can be computed using a Turing ...
null
null
I was just reading from wikipedia the following about [information][1]: > From the stance of information theory, information is taken as a > sequence of symbols from an alphabet, say an input alphabet χ, and an > output alphabet ϒ. Information processing consists of an input-output > function that maps any input ...
How are data types related to information theory?
|untagged|
null
E.g. **Matching Problem** The DFA of regex `good` is like a chain. match: "good" not match: "people do not give good comments are not good people" **Searching Problem** The DFA used in searching regex `good` could be: ![enter image description here][1] 1 matching: "good" 2 matching...
Difference between pattern matching and pattern searching in terms of DFA/Regex
|regular-expressions|finite-automata|
**Interpretation: The Link Between Data Types and Information Theory**<br> I believe the missing link between these two topics, information theory and data types, is interpretation. Interpretation is essentially the "input-output function" for which output (meaning) is derived from input (data). Whether the interpreta...
Consider the language $$L_{\times 2} = \big\{ x\bot y\bot z \mid x,y,z\in \{0,1\}, \#_0(x)=\#_0(y) \text{ and } |x|+|y|=z\big \}$$ (where $\#_0(x)$ denotes the number of zeros in $x$). It is easy to decide $L_{\times 2}$ using a HAL machine — observe that the machine needs to keep track of two properties: the nu...
null
$L = \{ a^ib^j \mid j\neq i \ and \ j\neq2i \ \} $ Is this language a context free language? If yes give a PDA. If no, give a proof. The pumping lemma for context free languages doesn't seem to work here. Let $p>1$ be the pumping length. Let the string be divided into five parts according to pumping lemma as ...
Is this language context free?
|context-free|pumping-lemma|pushdown-automata|
Given [[1,4,7],[2,5,8],[3,6,9]] which is a list of the column vectors of matrix |1, 2, 3| |4, 5, 6| |7, 8, 9| is the best case for transpose O(n^2)? Assume matrix is not always square. I have to touch each element at least once, because going from 2 x 5 to 5 x 2 matrix for example, will mean going f...
Complexity of transpose of matrix represented as list of row or column vectors
|matrices|
I've been self-studying the Expectation Maximization lately, and grabbed myself some simple examples in the process: http://cs.dartmouth.edu/~cs104/CS104_11.04.22.pdf There are 3 coins 0, 1 and 2 with P0, P1 and P2 probability landing on Head when tossed. Toss coin 0, if the result is Head, toss coin 1 three times...
Expectation Maximization coin toss examples
|algorithms|machine-learning|probability-theory|data-mining|
It is context Free. You can see it as a union of two languages: $L_1$ where $j>2i$ and $L_2$ which is very similar to the one of [this question](http://cs.stackexchange.com/q/9831/157). More information you can find in [this question](http://cs.stackexchange.com/q/9804/157).
Is $L= \{ a^ib^j \mid j\neq i \ and \ j\neq2i \ \} $ context free?
|formal-languages|context-free|pushdown-automata|
Unfortunately my background in computational complexity is still weak, but I am working on it... As I understood the question of existence of one-way function is very important in the field. Assume there are one way-functions how it can be shown that there exist one-way functions that are length preserving?
Length Preserving One Way Function
|complexity-theory|
This is a question about recurrence relation that contains sum inside the recursion.I am totally stuck. Can anyone help? The problem asks to solve the following recursion $T(n)=\frac{1}{n} \sum_{i=1}^{n-1}(T(i)+T(n-i))+cn$. The problem also warns that unwrapping is going to be the wrong approach and the right strate...
Recurrence relation with sum
In all computer architecture books we study that Cache memory could be divided into 3 levels (L1,L2 and L3) and its very beneficial to do so. Why don't we use the same approach in case of main memory (RAM). Is there any particular reason that we avoid this?
Computer Architecture-3 level RAM hierarchy
|computer-architecture|
null
|formal-languages|automata|closure-properties|pushdown-automata|
|turing-machines|machine-models|
I was reading about Universal Turing Machines. I see that the matching lemma states, that between two symbols X and Y, if there are only 1-s and blanks, then a TM exists, which can count the number of ones. This is used to match strings of ones between two tapes. Now I wonder, would there also be a TM or a met...
You can allow inifite alphabets because they can be modeled to fit the original Turing machine model. Assume without loss of generality¹ that the alphabet is $\mathbb{N}$. Then, any tape content $\qquad n_1 n_2 \dots n_k$ can be translated to a $\{0,1\}$-encoded TM tape like this: $\qquad \# \operatorname{b...
Here is a simple trial. Let $f: \{0,1\}^{i(n)} \to \{0,1\}^{o(n)}$ with $i(n) \ne o(n)$. be a one way function. We can assume wlog that $|x| \ge |f(x)|$ since $h(x) = f(x)^{p(|x|)}$ is also a one way function for all polynomials $p$. We can assume wlog that $f(x)$ allways ends with 1 for if $f$ is one way $f...
|programming-languages|information-theory|
|finite-automata|regular-expressions|search-algorithms|
Given [[1,4,7],[2,5,8],[3,6,9]] which is a list of the column vectors of matrix |1, 2, 3| |4, 5, 6| |7, 8, 9| is $O(n^2)$ a lower bound for transposing? Assume the matrix is not always square. I have to touch each element at least once, because going from 2 x 5 to 5 x 2 matrix for example, will mean...
Complexity of transposing matrices represented as list of row or column vectors
|algorithms|lower-bounds|matrices|
I've been self-studying the Expectation Maximization lately, and grabbed myself some simple examples in the process: From [here](http://cs.dartmouth.edu/~cs104/CS104_11.04.22.pdf): There are three coins $c_0$, $c_1$ and $c_2$ with $p_0$, $p_1$ and $p_2$ the respective probability for landing on Head when tossed. Tos...
|probability-theory|statistics|
Applying Expectation Maximization to coin toss examples
Unfortunately my background in computational complexity is still weak, but I am working on it. As I understand, the question of existence of one-way functions is very important in the field. Assume there are one way-functions, how it can be shown that there exist one-way functions which are length preserving?
Length-peserving one-way functions
|complexity-theory|one-way-functions|
{"OriginalQuestionIds":[2789],"Voters":[{"Id":98,"DisplayName":"Raphael"}]}
Here is a simple trial. Let $g: \{0,1\}^{i(n)} \to \{0,1\}^{o(n)}$ with $i(n) \ne o(n)$. be a one way function. We can assume that $g(x)$ ends with 1 as $p(x) = g(x)||1$ otherwise has this property. Define $$g'(x) = g(x)||0^{o(|x|) - |f(x)|}$$ this function always has $|g'(x)| = o(|x|)$. We now have to f...
Here is a simple trial. Let $g: \{0,1\}^{i(n)} \to \{0,1\}^{o(n)}$ with $i(n) \ne o(n)$. be a one way function. We can assume that $g(x)$ ends with 1 as $p(x) = g(x)||1$ otherwise has this property. Define $$g'(x) = g(x)||0^{o(|x|) - |g(x)|}$$ this function always has $|g'(x)| = o(|x|)$. and is trivially on...
Here is a simple trial. Let $g: \{0,1\}^{i(n)} \to \{0,1\}^{o(n)}$ with $i(n) \ne o(n)$. be a one way function. We can assume that $g(x)$ ends with 1 as $p(x) = g(x)||1$ otherwise has this property. Define $$g'(x) = g(x)||0^{o(n) - |g(x)|}$$ this function always has $|g'(x)| = o(n)$. and is trivially one wa...
Here is a simple trial. Let $g: \{0,1\}^{i(n)} \to \{0,1\}^{o(n)}$ with $i(n) \ne o(n)$ be a one way function. We can assume that $g(x)$ ends with 1 for all $x$ as $p(x) = g(x)||1$ otherwise has this property. Define $$g'(x) = g(x)||0^{o(n) - |g(x)|}$$ this function always has $|g'(x)| = o(n)$. and is trivi...