instruction stringlengths 0 29.8k ⌀ |
|---|
Is detecting "doubly" arithmetic progressions 3SUM hard? |
|algorithms| |
Wlog let $g$ be a strong one way function.
Since $g$ is PPT computable by assumption, there is a polynomial $p$ s.t $|f(x)| \le p(|x|)$ for all $x$
Define
$$g'(x) = g(x)||10^{p(|x|) - |g(x)|}$$ this function always has $|g'(x)| = p(|x|)$. and is trivially strongly one way.
We now have to force $|x| = |f(x)|$.... |
Why is $A(L) = \{x \in L \mid x = x^R \}$ context-free if $L$ is a regular language?
Trying to understand the approach to determining whether a regular language is context-free. |
Why is the subset of palindromes of a regular language context-free? |
|formal-languages|regular-languages|context-free|closure-properties| |
Regular language is always context-free (but not vice-versa). The language you ask for, $A(L)$, is based on a regular language $L$, but need not be regular.
To show that $A(L)$ (or any other language) is context free, you need to come up with either a context-free grammar that generates $A(L)$, or a PDA that accepts... |
This is inspired by an [interview question](http://www.careercup.com/question?id=15877680).
We are given an array of integers $a_1, \dots, a_n$ and have to determine if there are distinct $i \lt j \lt k$ such that
- $a_k - a_j = a_j - a_i$
- $k - j = j - i$
i.e, the sequences $\{a_i, a_j, a_k\}$ and $\{i,j,... |
Is detecting "doubly" arithmetic progressions 3SUM-hard? |
|algorithms|complexity-theory|lower-bounds| |
null |
null |
Say I want to find the n-th prime. Is there an algorithm to directly calculate it or must I do with sieving? I know always calculate the next prime with a sieve principle, but what if I want the n-th prime? |
Find n-th prime time complexity? |
|algorithms| |
A flip-flop is implemented as a bi-stable multivibrator; therefore, Q and Q' are guaranteed to be the inverse of each other. The excitation table for the SR flip-flop is helpful in understanding what occurs when signals are applied to the inputs.
S R Q(t) Q(t+1)
----------------
0 x 0 0 ... |
Public-key cryptography as we know it today are built on [one-way](http://en.wikipedia.org/wiki/One-way_function) [*trapdoor*](http://en.wikipedia.org/wiki/Trapdoor_one-way_function) permutations, and the trapdoor is essential.
For a protocol to be publicly secure, you need a key available to anyone, and a way to en... |
Say I want to find the n-th prime. Is there an algorithm to directly calculate it or must I do with sieving? I know always calculate the next prime with a sieve principle, but what if I want the n-th prime?
Duplicate:
http://math.stackexchange.com/questions/1257/is-there-a-known-mathematical-equation-to-find-the-... |
The following deterministic (without the comparator) algorithm works:
1. Do the [Fisher-Yates shuffle][1] using your comparator with some static pair (say $a_1 < a_2$) as a coin flip (doing acceptance-rejection sampling). If the comparator outputs $1$ the first time, use it inverted to avoid an endless rejection lo... |
null |
I need to find a minimal DFA given the following information:
> $ \{a^nb : n >= 0\} \bigcup \{b^na: n >= 1\}$
Now, maybe I'm not seeing this properly, but I don't see how this is possible: the first one will take 0 or more a's followed by one b, whereas the second one will take a 1 or more b's followed by one ... |
Union of 2 automata |
|automata| |
As [@vonbrand](http://cs.stackexchange.com/users/6447/vonbrand) suggested, using one automata (without attempting to combine them) is sufficient. Combining them will prove to be more work than it's worth.
Basically, here's the idea:
- If you get an $a$, begin looping on $a^nb$. If you get a $b$ after this, accept... |
As [@vonbrand](http://cs.stackexchange.com/users/6447/vonbrand) suggested, using one automata (without attempting to combine them) is sufficient. Combining them will prove to be more work than it's worth.
Basically, here's the idea:
- If you get an $a$, begin looping on $a^nb$. If you get a $b$ after this, accept... |
Here is an elaboration of your approach. Every $m$ iterations, we use the FFT algorithm to compute $m$ values of the convolution in time $O(n\log n)$, assuming that the subsequent $m$ values are zero. In other words, we are computing
$$
\sum_{i=0}^{n-1} w_i a_{t-i+k}, \quad 0 \leq k \leq m-1,
$$
where $w_i$ are the... |
null |
The following deterministic (without the comparator) algorithm works for an input tuple $(a_1,\dots,a_n)$:
1. Do the [Fisher-Yates shuffle][1] using your comparator with some static pair (say $a_1 < a_2$) as a coin flip (doing acceptance-rejection sampling). If the comparator outputs $1$ the first time, use it inve... |
The following deterministic (without the comparator) algorithm works for an input tuple $(a_1,\dots,a_n)$:
1. Do the [Fisher-Yates shuffle][1] using your comparator with some static pair (say $a_1 < a_2$) as a coin flip (doing acceptance-rejection sampling). If the comparator outputs $1$ the first time, use it inve... |
JIT compilers compiles the code on the fly, right before their execution or even when they are already executing. This way, the VM where the code is running can check for patterns in the code execution to allow optimizations that would be possible only with run-time information. Further, if the VM decide that the compi... |
A flip-flop is implemented as a bi-stable multivibrator; therefore, Q and Q' are guaranteed to be the inverse of each other except for when S=1, R=1, which is not allowed. The excitation table for the SR flip-flop is helpful in understanding what occurs when signals are applied to the inputs.
S R Q(t) Q(t+1) ... |
null |
A flip-flop is implemented as a bi-stable multivibrator; therefore, Q and Q' are guaranteed to be the inverse of each other except for when S=1, R=1, which is not allowed. The excitation table for the SR flip-flop is helpful in understanding what occurs when signals are applied to the inputs.
S R Q(t) Q(t+1) ... |
Public-key cryptography as we know it today si built on [one-way](http://en.wikipedia.org/wiki/One-way_function) [*trapdoor*](http://en.wikipedia.org/wiki/Trapdoor_one-way_function) permutations, and the trapdoor is essential.
For a protocol to be publicly secure, you need a key available to anyone, and a way to enc... |
When, $n$ is not too big, I think sieve method is good, just take a list of size $n \log n + O(1)$, then run one of a well known sieve algorithm. but in the case $n$ is big, you can use in-place sieve method or I prefer to have a small list of primes and then by [miller rabbin][1] test iterate through possible primes. ... |
Public-key cryptography as we know it today is built on [one-way](http://en.wikipedia.org/wiki/One-way_function) [*trapdoor*](http://en.wikipedia.org/wiki/Trapdoor_one-way_function) permutations, and the trapdoor is essential.
For a protocol to be publicly secure, you need a key available to anyone, and a way to enc... |
When, $n$ is not too big, I think sieve method is good, just take a list of size $n \log n + O(1)$, then run one of a well known sieve algorithm. but in the case $n$ is big, you can use in-place sieve method or I prefer to have a small list of primes and then by [miller rabbin][1] test iterate through possible primes. ... |
null |
A CPU is not a microprocessor. So if you look at early mechanical computers such as Korad Zuse's mechanical computer and Charles Babbage's mechanical computer, those were computers with a CPU that was not a microprocessor and did not have an ALU. |
For this question (call it `W`):
Input: A multi-set of numbers S, and a number t.
Question: What is the smallest subset s of S such that the sum of all the numbers in s equals t, if none return none.
I am trying to find some polytime equivalent decision problem `D` and provide a polytime algorithm ... |
How to prove polynomial time equivalence? |
|proof-techniques|np-hard|check-my-proof|np| |
A CPU is not a microprocessor. So if you look at early mechanical computers such as Konrad Zuse's Z3 and Charles Babbage's mechanical computer, those were computers with a CPU that was not a microprocessor and did not have an ALU.
John von Neumann proposed the ALU concept in 1945, there were functional computers be... |
Say I want to find the n-th prime. Is there an algorithm to directly calculate it or must I do with sieving? I know always calculate the next prime with a sieve principle, but what if I want the n-th prime?
Duplicate:
http://math.stackexchange.com/questions/1257/is-there-a-known-mathematical-equation-to-find-the-... |
|algorithms|primes| |
What do you mean "directly"? It is not well defined. And why would you care? What we care about in practice is not that but time and space efficiency. If you are asking if there is a provably correct and efficient algorithm to find $n$th prime given $n$ in binary the answer is that it is open. We don't know if there is... |
What is the time complexity of generating n-th prime number? |
What do you mean "directly"? It is not well defined. Arguing that an algorithm doesn't do something in solving another problem is not a well defined concept. It is probably one of the most common mistakes that people make when thinking about algorithms because they look at obvious cases and think it is simple to formal... |
The problems you mention here are variations of a problem called SUBSET-SUM, FYI if you want to read some literature on it.
What is $S_i$ in your algorithm? If it's the $i$-th element, then you assume that the minimal set will use the smaller elements, which is not necessarily true - there could be a large element t... |
null |
Superscalar processors have several execution units which often are not equivalent. I'd not be surprised if there has been some design where the repartition of responsibilities between the execution units was such that none of them would merit the name ALU for some definitions of the term. |
When, $n$ is not too big, I think sieve method is good, just take a list of size $n \log n + O(1)$, then run one of a well known sieve algorithm. but in the case $n$ is big, you can use in-place sieve method or I prefer to have a small list of primes and then by [miller rabbin][1] test iterate through possible primes. ... |
null |
How are these Context-Free Pumping Lemma Approaches differ?
Maybe this might help understand pumping lemma better
$(a^{i}b^{i}c^{j}d^{j} \mid i, j \geq 0$}
$(a^{i}b^{j}c^{i}d^{j} \mid i, j \geq 0$}
$(a^{i}b^{j}c^{j}d^{i} \mid i, j \geq 0$}
I understand we use contradiction with these conditions
1. $|v... |
How are these Context-Free Pumping Lemma Approaches differ? |
|context-free|pumping-lemma| |
How do these Context-Free Pumping Lemma approaches differ? |
Not all three languages are in fact non-context-free. Try to spot those that have a CF-grammar, and apply pumping to the remaining example(s). That is the diffrence I presume? |
When, $n$ is not too big, I think sieve method is good, just take a list of size $O(n \log n)$, then run one of a well known sieve algorithm. but in the case $n$ is big, you can use in-place sieve method or I prefer to have a small list of primes and then by [miller rabbin][1] test iterate through possible primes. Ther... |
When, $n$ is not too big, I think sieve method is good, just take a list of size $O(n \log n)$, then run one of a well known sieve algorithm. but in the case $n$ is big, you can use in-place sieve method or I prefer to have a small list of primes and then by [miller rabin][1] test iterate through possible primes. There... |
Not all three languages are in fact non-context-free. Try to spot those that have a CF-grammar, and apply pumping to the remaining example(s). That is the difference you mean, I presume?
(added) The grammars you give in a comment seem correct to me. General hints for applying the pumping lemma are given in various a... |
I need to find a minimal DFA given the following information:
> $ \{a^nb : n >= 0\} \cup \{b^na: n >= 1\}$
Now, maybe I'm not seeing this properly, but I don't see how this is possible: the first one will take 0 or more a's followed by one b, whereas the second one will take a 1 or more b's followed by one a.
... |
Union of two automata |
|automata|finite-automata| |
How are these Context-Free Pumping Lemma Approaches differ?
Maybe this might help understand pumping lemma better
$(a^{i}b^{i}c^{j}d^{j} \mid i, j \geq 0$}
$(a^{i}b^{j}c^{i}d^{j} \mid i, j \geq 0$}
$(a^{i}b^{j}c^{j}d^{i} \mid i, j \geq 0$}
I understand we use contradiction with these conditions
1. $|v... |
Define the problem $W$:
> **Input:** A multi-set of numbers $S$, and a number $t$.
> **Question:** What is the smallest subset $s \subseteq S$ so that $\sum_{k \in s} k = t$, if there is one? (If not, return `none`.)
I am trying to find some polytime equivalent decision problem $D$ and provide a polytime a... |
|complexity-theory|reductions|p-vs-np| |
null |
{"Voters":[{"Id":98,"DisplayName":"Raphael"}]} |
How do you apply Context-Free Pumping Lemma to these problems, and how do the approaches differ? |
When $n$ is not big, then I think the sieve-based algorithms perform well. We just need to keep a list of size $O(n \log n)$ and run one of a well-known sieve-based algorithms for generating primes.
When $n$ is big and we can't afford to keep a list of size $O(n \log n)$, we can use an *in-place sieve method*. But I... |
What do you mean by "directly"? This is not well-defined. Arguing that an algorithm doesn't do something during its computation is not a nice well-defined concept (when that something is a semantic condition).
It is probably one of the most common mistakes that people make when thinking about algorithms because they... |
What do you mean by "directly"? This is not well-defined. Arguing that an algorithm doesn't do something during its computation is not a nice well-defined concept (when that something is a semantic condition).
It is probably one of the most common mistakes that people make when thinking about algorithms because they... |
null |
null |
I'm looking for resources on getting started with [program analysis][1].
The only book I've found on the topic is the [Nielson & Nielson][2] book.
Other than that, it seems like there's only "compiler" books where "program analysis" would be a chapter, or something along those lines.
Do people know of any oth... |
Getting started with Program Analysis |
|compilers|semantics| |
This field is extremely broad... look for proofs of program correctness (there are a few tools around, like [Klee][1]). Then there are all sorts of "program checkers" of varying sophistication (see for example [splint][2] or [flawfinder][3] for a sampling of the range), programs that check for "programming guidelines c... |
I'm looking for resources on getting started with [program analysis][1].
The only book I've found on the topic is the [Nielson & Nielson][2] book.
Other than that, it seems like there are only "compiler" books where "program analysis" would be a chapter, or something along those lines.
Do people know of any o... |
The fastest algorithm I can think of is applying LCS in a creative way. It can solve this problem in O(N^2) time and O(N^2) space where N is the size of string.
LCS (S, reverse (S)) will give you the largest palindromic subsequence, as the largest palindromic subsequence will be the largest common subsequence bet... |
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 $ \Omega(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, wi... |
null |
null |
null |
I need to find a minimal DFA given the following information:
> $ \{a^nb : n\geq 0\} \cup \{b^na: n \geq 1\}$
Now, maybe I'm not seeing this properly, but I don't see how this is possible: the first one will take 0 or more a's followed by one b, whereas the second one will take a 1 or more b's followed by one ... |
Some frontmatter: I'm a recreational computer scientist and employed software engineer. So, pardon if this prompt seems somewhat out of left field -- I routinely play with mathematical simulcra and open problems when I have nothing better to do.
While playing with the [Riemann hypothesis][1], I determined that the ... |
###Update:
**This solution is not correct.**
The solution is unfortunately only true (and straightforward) for trees! Finding the diameter of a tree does not even need this. Here is a counterexample for graphs (diameter is 4, the algorithm returns 3 if you pick this $v$):
![enter image description here][4]
-... |
In a circular linked list, if an elements needs to be inserted at front [just before the node pointed by head], can be done in O(1) (see the answer [here][1])
But in a book currently, I have, it is mentioned that it is done in O(n) (the usual method)
My question is :
1. In practical scenarios which method is u... |
Complexity of algorithm inserting an element in a circular linked list at the front end |
|linked-lists| |
In a circular linked list, if an elements needs to be inserted at front [just before the node pointed by head], can be done in O(1) (see the answer [here][1])
But in a book currently, I have, it is mentioned that it is done in O(n) (the usual method). I also saw few lecture ppts, they all mention the usual method of... |
The following deterministic (without the comparator) algorithm works for an input tuple $(a_1,\dots,a_n)$:
1. Do the [Fisher-Yates shuffle][1] using your comparator with some static pair (say $a_1 < a_2$) as a coin flip (doing acceptance-rejection sampling). If the comparator outputs $1$ the first time, use it inve... |
The Halting problem is a natural undecidable language which is complete for the set of recursivly enumrable sets. I am interested in undecidable but not Turing-complete language such that we can not reduce the Halting problem to it.
What is the most **natural** undecidable RE problem which is not Turing-complete?
... |
null |
null |
The trick to the reduction is to use numbers to encode statements about the 3CNF formula, crafting those numbers in such a way that you can later make an arithmetic proposition about the numbers that is only true if the original 3CNF formula is satisfiable. Using the 3SAT -> SUBSET SUM reduction from your [lecture not... |
So I'm trying to understand P/NPC problems. The one I'm trying to tackle now is subset sum (we have a collection of integers $S$ and a $k$ param: is there a subset of $S$ that sum of all it's elements is equal to $k$?) problem and the proof that ss is an NPC problem by reduction from 3SAT.
I've found two PDF's that... |
Proving NP Completeness of a subset-sum problem - how? |
|algorithms| |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.