instruction
stringlengths
0
29.8k
⌀
|formal-languages|automata|finite-automata|context-free|
No. Adding rules can only add options for generating strings; all preexisting derivations are still possible.
Let $G$ and $H$ be your two context-free grammars, respectively. If the set of all rules in $G$ is a subset of the set of all rules in $H$, then all derivations possible in $G$ are also possible in $H$. In other words, the language accepted by $G$ is also accepted by $H$. Therefore, it is impossible for the language...
null
Several years ago, I tried to get two identical pairs of DDR4 RAM to run together in my computer. I have since bought a set of four, but I've always wondered why the RAM didn't work. Its been long enough that I don't have images from the MemTest, but I keenly recall the errors the test was throwing constantly from the ...
Why do two pairs of identical DDR4 RAM not work together?
|computer-architecture|memory-hardware|
This might be considered cheating, but I think it's possible to define such grammars if the set of terminals/non-terminals isn't required to be the same for both of them. Using [wikipedias formulation](https://en.wikipedia.org/wiki/Context-free_grammar#Formal_definitions), define the CFGs $G_1 = (V_1, \Sigma_1, R_1,...
null
There is an integer array $a_1 \dots a_n$ and an integer $1 \leq k \leq n$, we need to figure out the minimized cost to group this integer array into $k$ groups. The cost per group is mean($a_i \dots a_j$) for a group from $i$ to $j$. Give an algorithm in $O(nk)$ I am currently trying to do dynamic programming for t...
Minimize Cost to Group Integer Arrays
|dynamic-programming|
Minimize Cost to Split Integer Arrays
Is it required that your finite automaton accepts empty strings? The only requirement appears to be the non-occurrence of $10$. If so, $a$ must be an accepting state. The idea is that whenever your finite automaton accepts a $1$, it cannot accept any more $0$s. The following DFA is my suggestion. [![enter image d...
I have only begun studying this subject and have only completed the first few chapters of the *Elements of the Theory of Computation*. I have seen the answers (on this site and elsewhere) saying that the set of all Turing machines is countably infinite. Intuitively, this makes sense to me, as I can imagine the equi...
If the set of Turing machines is countably infinite, how can a Turing machine always have a finite set of states
|turing-machines|computability|infinity|
If the set of Turing machines is countably infinite, how can a Turing machine always have a finite set of states?
If the set of integers is infinite, how can any integer be finite? If the set of words over $\{0,1\}^*$ is infinite, how can any word be finite? You get the idea.
Maybe consider a simpler example. All Strings over the alphabet $\Sigma = \{0, 1\}$ have finite length, but there are an infinite number of strings over $\Sigma$. The reason for this is simple, suppose the longest String $x \in \Sigma^*$ has length $|x| = m \in \mathbb{N}$. Then we can build a new string $y = x1$ of...
null
Think about an algorithm to solve the problem. Then write a Turing-machine that implements this algorithm. For instance, checking if a binary number is even can be done by examining its rightmost bit. That gives you an algorithm: First you look for the rightmost bit, then when you have found it, you check whet...
There is a sorted integer array $a_1 \dots a_n$ and an integer $1 \leq k \leq n$, we need to figure out the minimized cost to group this integer array into $k$ groups. The cost per group is mean($a_i \dots a_j$) for a group from $i$ to $j$. Give an algorithm in $O(nk)$. Group here means partitioning and there's no requ...
There is a sorted integer array $a_1 \dots a_n$ and an integer $1 \leq k \leq n$, we need to figure out the minimized total cost to group this integer array into $k$ groups. The cost per group is mean($a_i \dots a_j$) for a group from $i$ to $j$. Give an algorithm in $O(nk)$. Group here means partitioning and there's n...
The problem you describe (for $r=1$) falls under the $[\sigma,\rho]$-partitioning framework with several hardness results available (see e.g., [1]). In such a problem, we want to color the vertices of a graph in $k$ colors such that for each vertex, the number of neighbors it has with its own color in in $p$ and the nu...
null
How does the computational complexity of the Subset Sum problem depend on the parameter $\alpha(S)$ of the input $(S, t)$, defined as follows? Considering $S$ under the divisibility partial order, i.e. $s_1 \prec s_2 \iff s_1 \mid s_2$, define $\qquad\qquad \displaystyle \alpha(S) = \max \{|V| \mid V\subseteq S,...
Subset Sum problem with many divisibility conditions
null
My very very first computer that came with BASIC built-in, had a random number generator that replaced the previous value x with the fractional part of (x + pi)^5. It wasn’t very random. It had the interesting property that of two consecutive random numbers the second was larger with a probability of about 60% (or ...
My original answer below takes "not $\mathsf{NP}$-complete" in the OP's title and text at face value. As far as I can tell it is correct, and not incompatible with Arno's answer, whose interpretation of "not $\mathsf{NP}$-complete" is less "strict" — though probably closer to what the OP wanted and yielding more intere...
Just curioius, I wanted to know when $S$ ={set of divisors of N} and we're given $N$ a target product. Our goal is to decide if a combination in $S$ has product equal to N. Does the problem remain NP-complete in this restriction? Assuming only positive integers?
Does the Subset Product Problem remain NP-complete if repetition in S is not allowed?
|np-complete|decision-problem|subset-product|
If the group elements do not need to be consecutive, then here is a simple approach: Take the first element and place it in group 1; the second in group 2; and so on for the first $k$ elements. Then $(k+1)$-th element is placed in group 1, so on and so forth. In general $i$-th element in placed into group $((i-1) ~\te...
Let $S = \{s_1,\dots,s_m\}$ (this is a multiset!), without loss of generality not containing any $1$s (if it does, remove them), and let $p_1,\dots,p_m$ be distinct primes which don't divide $N$ or any number in $S$. Let $$ S' = \{ p_i, s_i p_i : i = 1, \dots, m \}, \quad N' = p_1 \cdots p_m N. $$ Suppose that ther...
This one is a classic textbook problem. You can build your required DFA as follows: step 1: build a complete DFA $M$ that accepts all strings containing `10` as a substring step 2: just swap the status of final/non-final states in this DFA to get another DFA $M'$ step 3: argue that $M'$ has to be your required...
null
Each individual Turing machine has a *finite fixed* number of states. But not every two Turing machines have the same number of states. There are Turing machines with one state, there are Turing machines with two states, there are Turing machines with three states, and this up to (excluding) infinity. If we forge...
If the set of integers is infinite, how can any integer be finite? If the set of words of $\{0,1\}^*$ is infinite, how can any word be finite? You get the idea.
According to this link [binary variables - absolute values][1] the formula of some binary variables like absolute value is : y = | x1 - x2| for two variables x1, x2 with 0 ≤ xi ≤ U Introduce binary variables d1, d2 to mean d1 : 1 if x1 - x2 is the positive value d2 : 1 if x2 - x1 is the positive value MIP ...
What is the value range for absolute value formulation of binary variable
|binary|
I don't know if this post belongs in this site because I feel it might be a programming question, but also I feel it might be related to the way **Color Spaces** work, if it does't belong here I can change it. I would like to know how many different **HSV colors** are possible to generate using **OpenCV**. HSV color...
null
null
null
null
In the Chomsky hierarchy, level 0 grammars include all languages that can be recognized by a Turing machine. There is no level -1 (which would represent the class of languages that cannot be recognized by a Turing machine, but can be recognized by something more computationally powerful than a Turing machine). Turing m...
What is the name of the theory that says that Turing equivalence is universal, and Turing machines are maximally computationally powerful?
|turing-machines|computability|formal-grammars|turing-completeness|chomsky-hierarchy|
This problem can be trivially solved for a forest. However it is $\mathrm{NP}$-complete even for a single cycle. Let's reduce the [partition problem](https://en.wikipedia.org/wiki/Partition_problem) to this one. Given a multiset $S$ of positive integers we build a cycle graph $G \cong C_{|S|}$ on $|S|$ vertices and ...
You are mentally reversing two logical quantifiers, that are implicit in the statement "Turing machines must always have a finite set of states". You read this sentence as "there exists a finite set $S$ of states such that all Turing machines $M$ use only states in $S$". Logically, this is a "$\exists S \forall M$" ...
Every state and every item from the set $\{a,b\}$ has a transition to another state, and every state is an accepting state. Therefore, all states are equivalent and the regular expression (in your notation) is just $(a ∪ b)^*$. The automaton in question is equivalent to the following [Kleene Algebraic](https://en.wi...
I believe that the questioner is inquiring about the [Church-Turing thesis][1]. [1]: https://en.wikipedia.org/wiki/Church%E2%80%93Turing_thesis
Every state and every item from the set $\{a,b\}$ has a transition to another state, and every state is an accepting state. Therefore, all states are equivalent and the regular expression (in your notation) is just $(a ∪ b)^*$. The automaton in question is equivalent to the following [Kleene Algebraic](https://en.wi...
Consider a uniquely designed museum where rooms are arranged in a tree structure. Each room can have up to two child rooms connected by a path. The task is to develop an algorithm to place a minimum number of security guards so that the entire museum is guarded. A guard placed in a room can guard that room, its pare...
DFS to assign guards to nodes in a tree structure
|algorithms|graphs|graph-traversal|depth-first-search|
First, your intuition about this language being co-semi-decidable is incorrect, since whether some word of odd length is accepted makes no difference on whether the Turing machine belongs to the language. To prove that a Turing machine is not in $L$, you need to show that it does *not* accept some *even* length word. T...
null
This looks like the [dominating set problem](https://en.wikipedia.org/wiki/Dominating_set), but in a tree. If the tree has more than two nodes, note that it is never interesting to put a guard in a leaf, because putting the guard in its parent will cover more rooms. Conversely, since you need a guard to check the le...
This looks like the [dominating set problem](https://en.wikipedia.org/wiki/Dominating_set), but in a tree. If the tree has two nodes or more, note that it is never interesting to put a guard in a leaf, because putting the guard in its parent will cover more rooms. Conversely, since you need a guard to check the leaf...
null
null
null
Since tmp is never used, an optimising compiler may not calculate it at all - you would get a result of 0. That needs fixing. Making tmp static and printing it at the very end is enough. Clock() returns time not in seconds, but units of CLOCKS_PER_SEC. Divide the elapsed time by CLOCKS_PER_SEC. When you try to ...
The term I was looking for, that collects research on my original question as to whether there was a proof that Turing completeness is the most powerful model of computing, is hypercomputation: https://en.wikipedia.org/wiki/Hypercomputation It seems that it is controversial as to whether hypercomputation models c...
null
null
That's just basic inequalities, there is no trick. - if $d_1 = 1$, then $d_2 = 0$, and $y = x_1 - x_2$. That means that: $$y - (x_1 - x_2) = 0 \leqslant 2 \times U \times d_2 = 0$$ - if $d_1 = 0$, then $d_2 = 0$, and $y = x_2 - x_1$. That means that: $$y - (x_1 - x_2) = 2x_2 - 2x_1 \leqslant 2\times U - 2\times 0...
I am currently writing a tool that will be used in an industrial process to place components with physical requirements. It boils down to the following: - I have a set of points (typically, a few thousands); - I need to place these points on a (2D) plane; - for each pair A, B of points, I have a constraint that is...
Resolving distance constraints in 2D
|graphs|computational-geometry|constraint-satisfaction|
I am currently writing a tool that will be used in an industrial process to place components with physical requirements. It boils down to the following: - I have a set of points (typically, a few thousands); - I need to place these points on a (2D) plane; - for each pair A, B of points, I have a constraint that is...
In my recent question, I asked why do we consider Turing Machines as a limit of computation, you can check it here, good answer was provided for it: https://cs.stackexchange.com/questions/166998/is-the-turing-machine-the-only-framework-to-analyse-limits-of-computation
In [cuckoo hashing][1], an insertion failure occurs when there is an infinite loop of displacements. This is detected by a “max iterations” count on the insert function. When the insert fails, the table is rehashed using two new hash functions. These are selected from a given hash family. My question - how are th...
How to select hash functions for cuckoo hashing?
|hash-tables|hashing|
null
Let me narrow down your question: is it always possible to write a Turing Machine that solves any **mathematical** problem? We can make this more precise by reviewing some terms: - Let $\Sigma = \{0, 1\}.$ Denote $\Sigma^*$ as the set of binary strings (including the empty string). A **language** $L$ is a subset of $...
null
null
There is a theorem stating that, given a random algorithm with a binary output that has a success probability $\geq 2/3$, you can always create the another algorithm that solves the same problem but with a success probability $\geq 1-\delta$ by just repeating the original algorithm $\mathcal{O}(1/\log\delta)$ times and...
Proof for boosting success probability of a random algorithm with binary output
|complexity-theory|randomized-algorithms|
The proof I know of uses a weak version of [Chernoff bound](https://en.wikipedia.org/wiki/Chernoff_bound#Sums_of_independent_Bernoulli_random_variables): > If $X_1, X_2, …, X_n$ are independent Bernoulli random variables of same parameter $p$, and $X = \sum\limits_{i=1}^nX_i$, then: > $$\mathbb{P}(X \geqslant n/2)\...
There are python modules available for the NUFFT, the NUFFT function can be used for this sort-of inverse operation by exchanging the frequencies and times, and multiplying the times by negative 1. This can be shown from the definition of the NUDFT: $X_k = \sum_{n=0}^{N-1} x_n e^{-2\pi i p_n f_k}, \quad 0 \leq k \leq ...
null
There are python modules available for the NUFFT, the NUFFT function can be used for this sort-of inverse operation by exchanging the frequencies and times, and multiplying the times by negative 1. Note that this requires the NUFFT moduThis can be shown from the definition of the NUDFT: $X_k = \sum_{n=0}^{N-1} x_n e...
There are python modules available for the NUFFT, the NUFFT function can be used for this sort-of inverse operation by exchanging the frequencies and times, and multiplying the times by negative 1. This can be shown from the definition of the NUDFT: $X_k = \sum_{n=0}^{N-1} x_n e^{-2\pi i p_n f_k}, \quad 0 \leq k \leq ...
There are python modules available for the NUFFT, the NUFFT function can be used for this sort-of inverse operation by exchanging the frequencies and times, and multiplying the times by negative 1. Note that this requires the NUFFT moduThis can be shown from the definition of the NUDFT: $X_k = \sum_{n=0}^{N-1} x_n e...
There are python modules available for the NUFFT, the NUFFT function can be used for this sort-of inverse operation by exchanging the frequencies and times, and multiplying the times by negative 1. Note that this requires the NUFFT moduThis can be shown from the definition of the NUDFT: $X_k = \sum_{n=0}^{N-1} x_n e...
I am looking at $L=\{a^nb^m |n\neq m \}$. I would like to prove that $L$ is not regular. This can easily done by assuming it is regular and looking at $\overline L$, or by using other theorems. Despite that, I am interested in proving its not regular by using only the pumping lemma. Let $k$ be my pumping cons...
A proof that $a^n b^m $ for $n\neq m$ is not regular by using the pumping lemma
|formal-languages|regular-languages|finite-automata|context-free|pumping-lemma|
Let me narrow down your question: is it always possible to write a Turing Machine that solves any **mathematical** problem? We can make this more precise by reviewing some terms: - Let $\Sigma = \{0, 1\}.$ Denote $\Sigma^*$ as the set of binary strings (including the empty string). A **language** $L$ is a subset of $...
null
The proof I know of uses a weak version of [Chernoff bound](https://en.wikipedia.org/wiki/Chernoff_bound#Sums_of_independent_Bernoulli_random_variables): > If $X_1, X_2, …, X_n$ are independent Bernoulli random variables of same parameter $p$, and $X = \sum\limits_{i=1}^nX_i$, then: > $$\mathbb{P}(X \geqslant n/2)\...
Any (Turing Machine, initial tape contents) pair may be transformed into a Turing machine where each tape position is either marked or unmarked (two states), and where the tape is initially blank. The complexity of any such machine may be be expressed using a single parameter: the number of states. For every number o...