instruction
stringlengths
0
29.8k
⌀
A context free grammar proof
|formal-languages|automata|context-free|pumping-lemma|
There is a problem which I cannot solve. If you give a tip I will be very glad. Prove that following language is *not* context free: $L= \{ a^nb^m | \gcd(n,m) = 1 \}$. It can be proven using the pumping lemma, but how?
|formal-languages|context-free|pumping-lemma|
I wonder if somebody could quickly and briefly outline some of the similarities and differences between these line search methods. I know Dichotomous has 2 functional evaluations per iteration whereas the other two only one, and that the Fibonacci search tends to the Golden Section as the number of functional evalua...
Golden Section, Fibonacci and Dichotomous Searches
|optimization|
I wonder if somebody could quickly and briefly outline some of the similarities and differences between these line search methods. I know Dichotomous has 2 functional evaluations per iteration whereas the other two only one, and that the Fibonacci search tends to the Golden Section as the number of functional evalua...
null
In the comments, Wu Yin claimed an upper bound of $\lceil \log_2 n \rceil$, although I think this is only true if the position of the maximum is known. In fact, consider the following argument. Assume $A$ is filled with $N-1$ ones and one maximal element $\max$. Any first step on a subarray $A[x,y]$ of more than 2 elem...
There is a problem which I cannot solve. If you give a tip I will be very glad. Prove that following language is *not* context free: $L= \{ a^nb^m | \gcd(n,m) = 1 \}$. It can be proven using the pumping lemma, but how? If i start with some prime numbers m and n where m>n>2; Then if I pump it up; from uVxYz;...
Hint... There may be a direct application of the pumping lemma, but I suggest you take a look at closure properties. Consider the non-CFL in the first answer to the reference post, $P=\{a^p:p \text{ prime}\}$. Can you find a (fairly simple) operation on $L$ that preserves CFLs and yields $P$? If so, you are done, e...
Hint... There may be a direct application of the pumping lemma, but I suggest you take a look at closure properties. Consider the non-CFL in the first answer to the reference post, $P=\{a^p:p \text{ prime}\}$, which is clearly a cousin of $L$. Can you find a (fairly simple) operation on $L$ that preserves CFLs and y...
Hint... There may be a direct application of the pumping lemma, but I suggest you take a look at closure properties. Consider the non-CFL in the first answer to the reference post, $P=\{a^p:p \text{ prime}\}$, which is clearly a cousin of $L$. Can you find a (fairly simple) operation on $L$ that preserves CFLs and y...
There are $n!$ ways to choose cells. The number of different possible ways of choosing cells such that we have at least two cells with the same content is at most $n \cdot (n-2)!$. For $n\ge 4$, this number always satisfies $n! \gt n\cdot (n-2)!$, so by the pigeonhole principle there are always some selections with dis...
|algorithms|optimization|computational-geometry|
|complexity-theory|terminology|complexity-classes|
null
Hint... There may be a direct application of the pumping lemma, but I suggest you take a look at closure properties. Consider the non-CFL in the first answer to the reference post, $P=\{a^p:p \text{ prime}\}$, which is clearly a cousin of $L$. Can you find a (fairly simple) operation on $L$ that preserves CFLs and m...
[Wikipedia][1] has the following definition of the pumping lemma for regular langauges... > Let $L$ be a regular language. Then there exists an integer $p$ ≥ 1 > depending only on $L$ such that every string $w$ in $L$ of length at > least $p$ ($p$ is called the "pumping length") can be written as $w$ = > $xyz$ (i...
Pumping lemma for simple finite regular languages
|regular-languages|pumping-lemma|
the thing is that the lemma says **there exists** a number $p$, but does not tell us the number. All words **longer** than $p$ can be pumped, by the lemma. For a finite $L$, we can have $p$ be larger than the length of the longest word in $L$. Thus, the lemma only holds vacuously, and cannot be applied to any word ...
You are right - we cannot allow "pumping" words of a finite $L$. The thing you are missing is that the lemma says **there exists** a number $p$, but does not tell us the number. All words **longer** than $p$ can be pumped, by the lemma. For a finite $L$, it happens so that $p$ is larger than the length of the longe...
Pumping lemma is usually used on infinite languages, i.e. languages that contain infinite number of word. For any finite language $L$, since it can always be accepted by an DFA with finite number of state, $L$ must be regular. According to wikipedia ([http://en.wikipedia.org/wiki/Pumping_lemma_for_regular_languages#...
null
$\oplus P^{\oplus P}$ denotes the class $\oplus P$ equipped with what's known as an *oracle* for $\oplus P$ — we say that it has been given the ability to determine whether or not a string $s$ is a member of a language $L$ contained in the class $\oplus P$ in a single operation. I see that another commenter (sdcwc) ...
null
There is a problem which I cannot solve. If you give a tip I will be very glad. Prove that following language is *not* context free: $L= \{ a^nb^m | \gcd(n,m) = 1 \}$. It can be proven using the pumping lemma, but how? If I start with some prime numbers $m$ and $n$ where $m>n>2$ and pump it up from $uVxYz$,...
I wonder if somebody could quickly and briefly outline some of the similarities and differences between the line search methods [Golden Section Search](http://glossary.computing.society.informs.org/ver2/mpgwiki/index.php/Golden_section_search), [Fibonacci Search](http://glossary.computing.society.informs.org/ver2/mpgwi...
Golden Section, Fibonacci and Dichotomic Searches
|algorithms|optimization|
null
This method seems to work and, if implemented efficiently, it must be O(n), because each word is processed once. As each word _must_ be processed at least once, the problem is Ω(n). So, such a solution is also efficient.
I'm trying to work out an assignment (taken from the book [Algorithms - by S. Dasgupta, C.H. Papadimitriou, and U.V. Vazirani][1], Chap 8, problem 8.6a), and I'm paraphrasing what it states: > Given that 3SAT remains **NP**-complete even when restricted to formulas in which each literal appears at most twice, show ...
How to prove that a constrained version of 3SAT in which no literal can occur more than once, is solvable in polynomial time?
|complexity-theory|satisfiability|3-sat|
I think I heard in somewhere that it has been proven that $NP$ is strictly contained in $EXP$ -> $NP \subsetneq EXP $. Is this right? Wikipedia and book resources do not seem to bring me an answer.. (+ I just found a post similar to this, but I am not sure whether $NP$ is **strictly** contained in EXP.) * cross-p...
$NP \subsetneq EXP$?
|complexity-theory|
I'm trying to work out an assignment (taken from the book [Algorithms - by S. Dasgupta, C.H. Papadimitriou, and U.V. Vazirani][1], Chap 8, problem 8.6a), and I'm paraphrasing what it states: > Given that 3SAT remains NP-complete even when restricted to formulas in which each literal appears at most twice, show that...
I'm trying to work out an assignment (taken from the book [Algorithms - by S. Dasgupta, C.H. Papadimitriou, and U.V. Vazirani][1], Chap 8, problem 8.6a), and I'm paraphrasing what it states: > Given that 3SAT remains NP-complete even when restricted to formulas in which each literal appears at most twice, show that...
*Strictly contained* means $\subsetneq$, i.e. it is the definition, it is not a result.
null
*Strictly contained* means $\subsetneq$, i.e. it is the definition, it is not a result. So what you are saying is $$\mathsf{NP} \subsetneq \mathsf{ExpTime} \implies \mathsf{NP} \subsetneq \mathsf{ExpTime}$$ which is trivially true.
[{"Id":98,"DisplayName":"Raphael"}]
I think I heard in somewhere that it has been proven that $\mathsf{NP}$ is strictly contained in $\mathsf{EXP}$, that is $\mathsf{NP} \subsetneq \mathsf{EXP}$. Is this right? Wikipedia and book resources do not seem to bring me an answer.. I just found a post similar to this, but I am not sure whether $\mathsf{NP}$ ...
NP $\subsetneq$ EXP?
Without loss of generality we can assume that each variables appears once positively and once negatively (if a variable only appears once set its value to satisfy the clause). We can also assume that a variable does not appear in a clause more than once (if a variable does the clause is satisfied and can be removed). T...
*Strictly contained* means $\subsetneq$, i.e. it is the definition, it is not a result. So what you are saying is $$\mathsf{NP} \subsetneq \mathsf{ExpTime} \implies \mathsf{NP} \subsetneq \mathsf{ExpTime}$$ which is trivially true. Edit: If you are asking if $\mathsf{NP}\subsetneq \mathsf{ExpTime} $ then the ...
This question was inspired by [a comment on StackOverflow][1]. Apart from knowing NP-complete the problems of the Garey Johnson book, and many others; is there a rule of thumb to know if a problem looks like an NP-complete one? I am not looking for something rigorous, but to something that works in most cases. ...
Rule of thumb to know if a problem could be NP-complete
|np-complete|soft-question|
Without loss of generality, we can assume that each variables appears exactly once positively and exactly once negatively (if a variable only appears once set its value to satisfy the clause and remove the clause). We can also assume that a variable does not appear in a clause more than once (if a variable appears both...
This question was inspired by [a comment on StackOverflow][1]. Apart from knowing NP-complete problems of the Garey Johnson book, and many others; is there a rule of thumb to know if a problem looks like an NP-complete one? I am not looking for something rigorous, but to something that works in most cases. Of ...
Since Integer Linear Programming is NP-complete, there is a Karp reduction from any problem in NP to it. I thought this implied that there is always a polynomial-sized ILP formulation for any problem in NP. But I've seen papers on specific NP problems where people write things like "this is the first poly-sized form...
Does every NP problem have a poly-sized ILP formulation?
|complexity-theory|np-complete|linear-programming|
null
Hash table is very good if you have few words that are repeated many times. Let's suppose that your hash function is very good, that means that the distribution of elements inside various buckets is close to the uniform distribution. Even in that case, if the number of buckets is much smaller than the number of ele...
|algorithms|time-complexity|strings|word-combinatorics|string-metrics|
|algorithms|strings|string-metrics|
|algorithms|combinatorics|string-metrics|
|data-structures|strings|string-metrics|
Questions related to the design of computer hardware.
Hash table is very good if you have few words that are repeated many times. Let's suppose that your hash function is very good, that means that the distribution of elements inside various buckets is close to the uniform distribution. Even in that case, if the number of buckets is much smaller than the number of ele...
When we compare the complexity of two algorithms, it's usually the case that either $f(n) = O(g(n))$ or $g(n) = O(f(n))$ (possibly both), where $f$ and $g$ are the running times (for example) of the two algorithms. Is this always the case? That is, does at least one of the relationships $f(n) = O(g(n))$ and $g(n) = ...
Are the asymptotic runtimes of two algorithms always comparable?
|complexity-theory|asymptotics|
When we compare the complexity of two algorithms, it is usually the case that either $f(n) = O(g(n))$ or $g(n) = O(f(n))$ (possibly both), where $f$ and $g$ are the running times (for example) of the two algorithms. Is this always the case? That is, does at least one of the relationships $f(n) = O(g(n))$ and $g(n) =...
Are the functions always asymptotically comparable?
|asymptotics|mathematical-analysis|
Popular examples include: * [Hamming Distance](https://en.wikipedia.org/wiki/Hamming_distance) * [Edit Distance](https://en.wikipedia.org/wiki/Edit_distance) * [Levenshtein Distance](https://en.wikipedia.org/wiki/Levenshtein_distance) * [Damerau–Levenshtein Distance](https://en.wikipedia.org/wiki/Damerau%E2%8...
Questions about different distance metrics on strings.
Let $A_P = (Q,\Sigma,\delta,0,\{m\})$ the *string matching automaton* for pattern $P \in \Sigma^m$, that is * $Q = \{0,1,\dots,m\}$ * $\delta(q,a) = \sigma_P(P_{0,q}\cdot a)$ for all $q\in Q$ and $a\in \Sigma$ with $\sigma_P(w)$ the length of the longest prefix of $P$ that is a Suffix of $w$, that is $\qqu...
Connection between KMP prefix function and string matching automaton
null
This is my personal approach to determine whether a problem (i.e. a language $L$) is NP-complete or not. If both these conditions are verified: - I feel that testing if an instance $I$ is in $L$ implies that I need to check all combinations of some sort - **and** that there is no way to split such a combination int...
|complexity-theory|np-complete|intuition|
null
null
I am trying to understand Hoare logic presented at Wikipedia, [Hoare logic at Wikipedia][1] Apparently, if I understand correctly, a Hoare triple $$\{P\}~ C ~\{Q\}$$ means > if P, then Q, as long as C terminates. (A) However, the assignment axiom schema seems to be interpreted in a different way: $$\frac{}{...
Hoare triple for assignment P{x/E} x:=E {P}
|semantics|hoare-logic|
It means more something like > if P was true before C then Q will be true after that. There are time considerations because usually C will change the environment. Think of this example: $C=($`x := 42`$)$ and $P=($`x` > 10$)$. Then the instance of your rule makes sense.
I am trying to understand Hoare logic presented at Wikipedia, [Hoare logic at Wikipedia][1] Apparently, if I understand correctly, a Hoare triple $$\{P\}~ C ~\{Q\}$$ means > if P, then Q, as long as C terminates. (A) However, the assignment axiom schema seems to be interpreted in a different way: $$\frac{}{...
I am trying to understand Hoare logic presented at Wikipedia, [Hoare logic at Wikipedia][1] Apparently, if I understand correctly, a Hoare triple $$\{P\}~ C ~\{Q\}$$ means > if P just before C, then Q holds immediately after C, as long as C terminates. (A) However, the assignment axiom schema seems to be inter...
Notice that what Wikipedia is saying is that > The assignment axiom means that the truth of $\{P[x/E]\}$ is equivalent to the **after-assignment truth** of $\{P\}$. In other words, ($P$ holds after the execution of $x:= E$) if and only if ($P[x/E]$ holds before the execution). This is equivalent to the definition...
If you count a CPU (as you imply in your text) as an unbounded memory and the processor, then no you can't model it as a PDA. A push down automaton (with one stack) can only recognize context-free languages, for example $\{a^n b^n c^n | n \geq 0\}$ cannot be recognized by a PDA, but presumably could be recognized by yo...
Yes this is a question I have stumbled upon in my exam revision and it is intriguing. Question : My computer is blue and it has a massive graphics card and a DVD and every- thing so which is more powerful: my computer or a Pushdown Automaton? **My Thoughts** When we talk about power I have assumed this to be...
Is a PDA as powerful as a CPU?
|computability|computable-analysis|
If you count a CPU (as you imply in your text) as an unbounded memory and the processor, then no you can't model it as a PDA. A push down automaton (with one stack) can only recognize context-free languages, for example $\{a^n b^n c^n | n \geq 0\}$ cannot be recognized by a PDA, but presumably could be recognized by yo...
This is a question I have stumbled upon in my exam revision and I find it intriguing: __My computer is blue and it has a massive graphics card and a DVD and every- thing so which is more powerful: my computer or a Pushdown Automaton?__ - - - - ##My Thoughts When we talk about power I have assumed this to b...
|computability|computation-models|computable-analysis|
null
You are right if your CPU has bounded memory. A CPU can do basically exactly what a turing machine can do. But: The reality it is build in gives the CPU limitations, such as the amount of memory it can access. If we assume the CPU has only finite memory available, it resembles to a TM with constant space, making your ...
Not every pair of functions is comparable with $O(\cdot)$ notation; consider the functions $f(n) = n$ and $$ g(n) = \begin{cases} 1 & \text{if $n$ is odd}, \\\ n^2 & \text{if $n$ is even}. \end{cases} $$ Moreover, functions like $g(n)$ do actually arise as running times of algorithms. Consider the obvious b...