instruction
stringlengths
0
29.8k
⌀
Permute rows of a matrix to minimize total number of inversions of its column vectors
|algorithms|sorting|
I want to show that the language $L=\{a^p ~|~ p\mathbb{~is~not~prime}\}$ is not a CFL. If I look at $\bar{L}=\{a^p ~|~ p\mathbb{~is~prime}\}$, it is pretty straightforward to show that it is not a CFL with the pumping lemma, by choosing the word $w=a^p$, and with $w_{p+1}=a^{p+sp}=a^{p(1+s)}\notin L$ because $p(1+s)...
How to show that $\{a^p ~|~ p\mathbb{~is~not~prime}\}$ is not a CFL?
|formal-languages|regular-languages|automata|context-free|pumping-lemma|
The statistical distance (SD) has been widely used as a 'measure' of the closeness of two distributions $D_1$ and $D_1$. Suppose that the statistical distance (here, total variation with $\ell_1$ norm) between distributions $D_1$ and $D_2$ is less than $s$. Then, as I know, there is a polynomial-time algorithm to dis...
Distinguishing two distributions with f-divergence
|algorithms|discrete-mathematics|
Considering a function $f$ such that: $$ f(x_1, x_2, x_3) = f(f(x_1, x_2), x_3) $$ and $$ f(x_1, x_2) = f(x_2, x_1) $$ and a set $X = \{ x_1, \dots, x_n \}$; how to compute $$f(x_1, \dots, x_{i - 1}, x_{i + 1}, \dots, x_{j-1}, x_{j+1}, \dots, x_n)$$ for all pairs $i, j \in 1, \dots, n$ while minimizing the num...
Compute recursive function efficiently
|recursion|
Considering a function $f$ such that: $$ f(x_1, x_2, x_3) = f(f(x_1, x_2), x_3) $$ and $$ f(x_1, x_2) = f(x_2, x_1) $$ and a set $X = \{ x_1, \dots, x_n \}$; how to compute $$f(x_1, \dots, x_{i - 1}, x_{i + 1}, \dots, x_{j-1}, x_{j+1}, \dots, x_n)$$ for all pairs $i, j \in 1, \dots, n$, $i \neq j$ while minimi...
null
Count how many times each $x_i$ occurs in the argument list. Suppose $X_1$ is the set of $x_i$ that occur once, $X_2$ is the set of $x_i$ that occur twice, ..., $X_m$ is the set of $x_i$ that occur $m$ times, ... etc. Suppose $y \in X_j$, eventually you will have to evaluate $f(y)$ $j$ times. So instead of comput...
I want to show that the language $L=\{a^p ~|~ p\text{ is not prime}\}$ is not a CFL. If I look at $\bar{L}=\{a^p ~|~ p\text{ is prime}\}$, it is pretty straightforward to show that it is not a CFL with the pumping lemma, by choosing the word $w=a^p$, and with $w_{p+1}=a^{p+sp}=a^{p(1+s)}\notin L$ because $p(1+s)$ is...
How to show that $\{a^p ~|~ p\text{ is not prime}\}$ is not a CFL?
Count how many times each $x_i$ occurs in the argument list. Suppose $X_1$ is the set of $x_i$ that occur once, $X_2$ is the set of $x_i$ that occur twice, ..., $X_m$ is the set of $x_i$ that occur $m$ times, ... etc. Suppose $y \in X_j$, eventually you will have to evaluate $f(y)$ $j$ times. So instead of comput...
Count how many times each $x_i$ occurs in the argument list. Suppose $X_1$ is the set of $x_i$ that occur once, $X_2$ is the set of $x_i$ that occur twice, ..., $X_m$ is the set of $x_i$ that occur $m$ times, ... etc. Suppose $y \in X_j$, eventually you will have to evaluate $f(y)$ $j$ times. So instead of comput...
Count how many times each $x_i$ occurs in the argument list. Suppose $X_1$ is the set of $x_i$ that occur once, $X_2$ is the set of $x_i$ that occur twice, ..., $X_m$ is the set of $x_i$ that occur $m$ times, ... etc. Suppose $y \in X_j$, eventually you will have to evaluate $f(y)$ $j$ times. So instead of comput...
Let $A$ be an $n \times k$ matrix of real numbers. I'm looking for an exact algorithm to find a permutation of the rows of $A$, in such a way that the total number of inversions found in the resulting $k$ column vectors is minimal. That is, if $B$ is a row-wise permutation of $A$, I want to minimize: $$ L(B) = \...
Instead of just checking "if a binary number is bigger than two", check whether the input is 0, 1, 2 or "big", where "big" means greater than 2. ------ Assume the most significant digit in the input is to the left. Let the Turing machine (TM) read the input from left to right, remembering the value of the bin...
Suppose towards a contradiction that $L$ is regular and let $p$ be a prime number larger than $L$'s pumping length. Since $a^{p^2} \in L$, by the pumping lemma we know that there is some $1 \le k < p$ such that $a^{ki+p^2} \in L$ for all $i \ge -1$. Since $k$ cannot have $p$ as a prime factor, $k$ and $p^2$ must be ...
null
Imagine you trained a text-from-image reader, similarly to the one described in this article https://medium.com/analytics-vidhya/image-text-recognition-738a368368f5 Now you want to port the trained network, or at least the bottom CNN layers, to process huge images (large photograph with tiny street name in the corne...
Convolutional Neural Network : how to ignore swaths of uninteresting areas? Or make it focus to interesting regions only?
|neural-networks|
{"OriginalQuestionIds":[151184],"Voters":[{"Id":6759,"DisplayName":"Steven"},{"Id":91753,"DisplayName":"John L."},{"Id":683,"DisplayName":"Yuval Filmus","BindingReason":{"GoldTagBadge":"formal-languages"}}]}
null
The constraints on $w, x,y, z$ are not given, I choose everyone $\geq 0.$ The strings could be equal $a$ and equal $d,$ equal $b$ and equal $c,$ equal $b$ and equal $d,$ equal $a$ and equal $c $ etc.(since $w, x,y, z\geq 0.$) $S\to aSd$ $X\to aXc$ $Y\to bYd$ $Z\to bZc$ Now from start symbol we cou...
Considering a function $f$ such that: $$ f(x_1, x_2, x_3) = f(f(x_1, x_2), x_3) = f(x_1, f(x_2, x_3)) $$ and $$ f(x_1, x_2) = f(x_2, x_1) $$ and a set $X = \{ x_1, \dots, x_n \}$; how to compute $$f(x_1, \dots, x_{i - 1}, x_{i + 1}, \dots, x_{j-1}, x_{j+1}, \dots, x_n)$$ for all pairs $i, j \in 1, \dots, n$, $...
This answer on purpose is more complicated than necessary. My goal is to apply a general property of regular and context-free languages, see: [Prove that the equal-length concatenation of regular languages is context free][1]. > Given regular languages $A$ and $B$, then $A@B=\{xy\mid x\in A, y\in B \text{ and } |x|=...
The constraints on $w, x,y, z$ are not given, I choose everyone $\geq 0.$ The strings could be equal $a$ and equal $d,$ equal $b$ and equal $c,$ equal $b$ and equal $d,$ equal $a$ and equal $c $ etc.(since $w, x,y, z\geq 0.$) $S\to aSd$ $X\to aXc$ $Y\to bYd$ $Z\to bZc$ Now from start symbol we cou...
Without any hard maths: log n! = log 1 + log 2 + log 3 + … + log n. We are adding n numbers, each at most log n, so the sum is at most n log n. On the other hand, log ( sqrt (n)) = (log n) / 2, so all but sqrt(n) of the numbers we are adding are at least (log n) / 2, giving a lower bound. For n>= 4, sqrt(n) <= n/2 ...
null
null
### Definitions Define the *density* $\rho_L$ of a language $L$ to be a function $\rho_L : \mathbb{N} \rightarrow \mathbb{N}$ where $\rho_L(n)$ is the number of words in $L$ of length $n$. ### Question Let $L \subseteq \Sigma^*$ be a regular language with density $\rho_L(n) \leq b^n$ for some constant $b \in \...
Object detection is responsible for finding regions of interest in a large image. You will have to train it on labelled images, that are labelled with bounding boxes on all of the regions of interest in each of the images in the training set.
### Definitions Define the *density* $\rho_L$ of a language $L$ to be a function $\rho_L : \mathbb{N} \rightarrow \mathbb{N}$ where $\rho_L(n)$ is the number of words in $L$ of length $n$. ### Question Let $L \subseteq \Sigma^*$ be a regular language with density $\rho_L(n) \leq b^n$ for some constant $b \in \...
Considering a function $f$ such that: $$ f(x_1, x_2, x_3) = f(f(x_1, x_2), x_3) = f(x_1, f(x_2, x_3)) $$ and $$ f(x_1, x_2) = f(x_2, x_1) $$ and a set $X = \{ x_1, \dots, x_n \}$; how to compute $$f(x_1, \dots, x_{i - 1}, x_{i + 1}, \dots, x_{j-1}, x_{j+1}, \dots, x_n)$$ for all pairs $i, j \in 1, \dots, n$, $...
null
(1) You can compute $f(x_1,\dots,x_{i-1})$ for all $i$ with $n-2$ calls to $f$. (Simply iterate over $i:=1,\dots,n$.) (2) Then, using (1), you can compute $f(x_1,\dots,x_{i-1},x_{i+1},\dots,x_{j-1})$ for all $i,j$ with $n(n-1)/2$ more calls to $f$. (For each $i$, iterate over $j:=i+2,\dots,n$.) (3) You can also...
Considering a function $f$ such that: $$ f(x_1, x_2, x_3) = f(f(x_1, x_2), x_3) = f(x_1, f(x_2, x_3)) $$ and $$ f(x_1, x_2) = f(x_2, x_1) $$ and a set $X = \{ x_1, \dots, x_n \}$; how to compute $$f(x_1, \dots, x_{i - 1}, x_{i + 1}, \dots, x_{j-1}, x_{j+1}, \dots, x_n)$$ for all pairs $i, j \in 1, \dots, n$, $...
Compute a commutative and associative operation on n-2 arguments efficiently
|algorithms|optimization|recursion|
null
If you need a mathematical guarantee, you should run $k-1$ times the $N$-solver algorithm. In other words, repeat the following approach for each vertex $v_i\ \ i=2,...,k$ and take the best solution. Introduce $N-K$ new vertices $V_j\ \ j=k+1,...,N$ on the line segment between two vertices $v_1$ and $v_i$; e.g. Wi...
I'm struggling with the definitions of the push-down automata. In 2-DPDA and 3-DPDA, what do the numbers 2 and 3 stand for: for the number of stacks or of read-only tapes (and hence RO heads) ? Finally, is there a language accepted by k-DPDA but not with (k-1)-DPDA for any k ?
in 2DPDA and 3DPDA:2 and 3 is the number of tapes or of stacks?
|automata|finite-automata|pushdown-automata|
(Motivation: let $h = n/2$. Given $f_{ih} = f(x_i\dots x_{h-1}) \text{ and } f_{hj} = f(x_h\dots x_j)$ (precomputed in about $n$ evaluations of $f$), $f(x_{i+1}\dots x_{j-1})$ can be computed as $f(f_{(i+1)h}, f_{h(j-1)})$ for all $i\lt h\lt j$. This saves ?$\frac{(n-2)(n-3)} 2 - n$? evaluations. Similarly ...
null
**Lemma:** The parity of the Hamming distance between two strings is the parity of the total number of $1$s. **Proof:** If you toggle any bit in any of the strings, the parity of the distance changes. Start from two "all zeroes" strings and toggle all it takes to get to the targeted strings. **E.g.:** $$...
Arora and Barak states (p. 230) the following: > What is the relation between BQP and NP? It seems that quantum computers only offer a quadratic speedup (using Grover’s search) on NP-complete problems. There are also oracle results showing that NP problems require exponential time on quantum computers [BBBV97]. So ...
What is different between two classes are 'incomparable' or two classes are 'not equal'?
|complexity-theory|complexity-classes|quantum-computing|
Two sets $A$ and $B$ are _comparable_ if $A \subseteq B$ or $B \subseteq A$. However, if $A \neq B$, it could be that $A \subsetneq B$ or $B \subsetneq A$. If $A \neq B$ and $A$ and $B$ are comparable, we know that (wlog) all elements of $A$ also are in $B$, and this is an interesting piece of information. If $A...
Arora and Barak states (p. 230) the following: > What is the relation between $BQP$ and $NP$? It seems that quantum computers only offer a quadratic speedup (using Grover’s search) on $NP$-complete problems. There are also oracle results showing that $NP$ problems require exponential time on quantum computers [BBBV...
Why is the answer `(b + /\)(ab)*aa(ba)*(b + /\) + (a + /\)(ba)*bb(ab)*(a + /\)`? I'm confused and I request guidance Edit: Why are people in this community so damn arrogant? I simply asked a question as a beginner and almost 3 years later people remembered to downvote this? What's wrong with the title or my quest...
Why is the answer `(b + /\)(ab)*aa(ba)*(b + /\) + (a + /\)(ba)*bb(ab)*(a + /\)`? I'm confused and I request guidance
Why is $L=\{w | ~|w|~mod~3=\#_a(w)~mod~3\}$ a Regular Language? Where $\#_a(w)$ is the number of $a$'s in $w$. So far every language that I saw containing `modulo` was a regular language. Can you give me an example of a non-regular language with a `modulo` operator in it? Thanks a lot!
Why is $L=\{w | ~|w|~mod~3=\#_a(w)~mod~3\}$ a Regular Language?
|formal-languages|regular-languages|automata|finite-automata|context-free|
I'm just trying to write a little algorithm. I've got nine objects, so there's 9! permutations. My question is, is there a way of turning a number from 1 to 9! into a permutation? for example, f(1)=[1,2,3,4,5,6,7,8,9], f(2)=[1,2,3,4,5,6,7,9,8] or something similar. Each number should have a unique ordering, and v...
nth Permutation generator
|algorithms|permutations|
The following language is not regular $L = \{a^n b^m c^n \mid m = n \bmod 2\}$.
Every string of bits can be interpreted both as a two's complement or a sign-and-magnitude number. So the answer is clearly no. [Usually, sign-and-magnitude allow negative zero; if not in your context, then you could say that $100\cdots0$ is a two's complement number, anyway.]
The following language is not regular $L = \{a^n b^m c^n \mid m = n \bmod 2\}$. To see that $L$ is not regular, suppose towards a contradiction that $L$ is regular and let $p$ be its pumping length. Then, $a^{2p}c^{2p} \in L$ and there is some $1 \le k \le p$ such that $a^{2p + ik} c^{2p} \in L$ for every integer $...
Use the [factorial number system](https://en.wikipedia.org/wiki/Factorial_number_system). See also https://oeis.org/wiki/Ranking_and_unranking_functions, https://cs.stackexchange.com/q/30274/755 for more background.
$K{-}DPDA$ is equivalent to $2{-}DPDA$ for any $k \geq3.$ $\{a^nb^nc^n\}$ is recognized by $2{-}DPDA$ but not by $1{-}DPDA$ or by $DPDA$ with $1{-} stack.$
$K{-}DPDA$ is equivalent to $2{-}DPDA$ for any $k \geq3($that is $K{-}DPDA$ is equivalent to Turing Machine for any $k \geq2$$).$ $\{a^nb^nc^n\}$ is recognized by $2{-}DPDA$ but not by $1{-}DPDA$ or by $DPDA$ with $1{-} stack.$
null
$K{-}DPDA$ is equivalent to $2{-}DPDA$ for any $K \geq3($that is $K{-}DPDA$ is equivalent to Turing Machine for any $K \geq2$$).$ $\{a^nb^nc^n\}$ is recognized by $2{-}DPDA$ but not by $1{-}DPDA$ or by $DPDA$ with $1{-} stack.$
null
$K{-}DPDA$ is equivalent to $2{-}DPDA$ for any $K \geq3. $That means for example $2{-}DPDA$ do the same work as $3{-}DPDA$ do, $2{-}DPDA$ do the same work as $4{-}DPDA$ do etc$.......... ... ... .. .. ..... .. .$ And $K{-}DPDA$ is equivalent to Turing Machine for any $K \geq2$$.$ $\{a^nb^nc^n\}$ is recognized...
null
$K{-}DPDA$ is equivalent to $2{-}DPDA$ for any $K \geq3. $That means for example $2{-}DPDA$ is capable do the same work as $3{-}DPDA$ do, $2{-}DPDA$ is capable do the same work as $4{-}DPDA$ do etc$.......... ... ... .. .. ..... .. .$ And $K{-}DPDA$ is equivalent to Turing Machine for any $K \geq2$$.$ $\{a^nb...
It is known that half-GCD (https://www.csd.uwo.ca/~mmorenom/CS424/Lectures/FastDivisionAndGcd.html/node6.html) is can be used to compute the GCD of two polynomials over a finite field. Is it possible to parallelize it? Or, are there any practical polynomial GCD algorithms that can run on clusters (like mpi, Hadoop)?
Parallel algorithm for Polynomial GCD
|algorithms|parallel-computing|
$K{-}DPDA$ is equivalent to $2{-}DPDA$ for any $K \geq3. $That means for example $2{-}DPDA$ is capable of do the same work as $3{-}DPDA$ do, $2{-}DPDA$ is capable of do the same work as $4{-}DPDA$ do etc$.......... ... ... .. .. ..... .. .$ And $K{-}DPDA$ is equivalent to Turing Machine for any $K \geq2$$.$ $...
### Definitions Define the *density* $\rho_L$ of a language $L$ to be a function $\rho_L : \mathbb{N} \rightarrow \mathbb{N}$ where $\rho_L(n)$ is the number of words in $L$ of length $n$. ### Question Let $L \subseteq \Sigma^*$ be a regular language with density $\rho_L(n) \leq b^n$ for some constant $b \in \...
null
The constraints on $w, x,y, z$ are not given, I choose everyone $\geq 0.$ The strings could be equal $a$ and equal $d,$ equal $b$ and equal $c,$ equal $b$ and equal $d,$ equal $a$ and equal $c $ etc(since $w, x,y, z\geq 0.$) $S\to aSd. $ $X\to aXc. $ $Y\to bYd. $ $Z\to bZc. $ Now from start symbol...
You have a grammar where it is natural to build sentences from the outside to the inside. You'll have a symbol in the middle, and in each derivation step you add a terminal at the left and one at the right, so the number of symbols on the left and on the right are the same. Initially you produce a's and d's. Then y...
$\newcommand{\m}{\operatorname{\%}}$ Define $n\m d$ to be the remainder of $n$ divided by $d$ as defined in almost every programming language. For example, $6\m3 =0$ and $8\m 3= 2$. <!-- The definition might be different for $(-1) % 2$ or $1 %(-2)$. However, both $n$ and $d$ are positive in this answer. --> $L=\{...
Why is $L=\{w \mid ~|w|\bmod3=\#_a(w)\bmod3\}$ a regular language? $\#_a(w)$ is the number of $a$'s in $w$. So far every language that I saw containing `modulo` was a regular language. Can you give me an example of a non-regular language with a `modulo` operator in it?
Why is { w | |w| mod 3 = #_a(w) mod 3 } a Regular Language?
$\newcommand{\m}{\operatorname{\%}}$ Define $n\m d$ to be the remainder of $n$ divided by $d$ as defined in almost every programming language. For example, $6\m3 =0$ and $8\m 3= 2$. <!-- The definition might be different for $(-1) % 2$ or $1 %(-2)$. However, both $n$ and $d$ are positive in this answer. --> $L=\{...
null
$\newcommand{\m}{\operatorname{\%}}$ Let $d(w)=(|w|-\#_a(w))\m3$, where $n\m 3$ is the remainder of dividing $n$ by $3$ as defined in almost every programming language. <!-- The definition might be different for $(-1) % 2$ or $1 %(-2)$. However, both $n$ and $d$ are positive in this answer. --> Note $L=\{ w\mid d(w)=...
Lucky enough, your case is quite easy. The language is defined by the rule "total number of letters, modulo 3, equals total number of a's, modulo 3". This is equivalent to "number of letters that are not a's is divisible by 3". Same language, but a lot easier. You build a state machine with three states $S_0$, $S_1...
$K{-}DPDA$ is equivalent to $2{-}DPDA$ for any $K \geq3. $That means for example $2{-}DPDA$ is capable of do the same work as $3{-}DPDA$ do, $2{-}DPDA$ is capable of do the same work as $4{-}DPDA$ do etc$.......... ... ... .. .. ..... .. .$ And $K{-}DPDA$ is equivalent to Turing Machine for any $K \geq2$$.$ $...
You always need an initial solution. If you don't have one, you create another problem to get the initial solution. In your case: Imagine you don't ship enough cars. Customer 1 misses $x_7$ and customer 2 misses $x_8$ cars. So you change two equations : $x_1 + x_5 + x_7 = 200$, $x_2 + x_6 + x_8 = 300$. And this has...
I'm struggling with the definitions of the push-down automata. In 2-DPDA and 3-DPDA, what do the numbers 2 and 3 stand for: for the number of stacks or of read-only tapes (and hence RO heads) ? Finally, is there a language accepted by k-DPDA but not with (k-1)-DPDA for any k ? It seems that the last question is...
null
null
null
$K{-}DPDA$ is equivalent to $2{-}DPDA$ for any $K \geq3. $That means for example $2{-}DPDA$ is capable of do the same work as $3{-}DPDA$ do, $2{-}DPDA$ is capable of do the same work as $4{-}DPDA$ do etc$.......... ... ... .. .. ..... .. .$ And $K{-}DPDA$ is equivalent to Turing Machine for any $K \geq2$$.$ $...
$K{-}DPDA$ is equivalent to $2{-}DPDA$ for any $K \geq3. $That means for example $2{-}DPDA$ is capable of do the same work as $3{-}DPDA$ do, $2{-}DPDA$ is capable of do the same work as $4{-}DPDA$ do etc$.......... ... ... .. .. ..... .. .$ And $K{-}DPDA$ is equivalent to Turing Machine for any $K \geq2$$.$ *...