instruction
stringlengths
0
29.8k
⌀
I was recently sorting a large list of names - I just ended up sorting it in Python, but it inspired in me the following question. If we're given a list $L$ of $n$ numbers, but can only see $k$ contiguous elements at a time and can shift a group of elements at once, what would be the fastest way to sort this list? I...
With $k=1$ you can solve this in $O(n \log n)$ time using sorting networks. Pick a [sorting network](https://en.wikipedia.org/wiki/Sorting_network) of size $O(n \log n)$. You can implement each comparator using $O(1)$ steps, in your model. (To compare-and-sort the items at indices $i,j$, first cut the item at $i$ ...
null
I wonder whether context-free grammar (or what else?) can be used to implement "member of" structures, which describe that **something is a member of something**. For example, I want to be able to infer the statement: > **John Lennon** is in **Beatles**. The inferring process should return True since in the gr...
When does one need an Earley parser or something else vs just a DFA?
If the language is implementable as mere DFA (i.e. it's a **regular language**), then why would one need a parsing algorithm such as Earley? Regular languages are a subset of context-free languages, but what advantages would call for Earley over a DFA in the case of a regular language? --- E.g. in this example: ...
Proving that removing unreachable states from $M$ does not change $L(M)$
Rice's theorem comments on the undesirability of non-trivial semantic properties, however there are syntactic properties that are undecidable as well, such as the "useless" states problem for Turing Machines. 1. What are some undecidable syntactic properties? 2. Can we comment on the undecidability of a syntact...
Undecidability of syntactic properties
|turing-machines|computability|undecidability|rice-theorem|
Rice's theorem comments on the undesirability of non-trivial semantic properties, however there are syntactic properties that are undecidable as well, such as the "useless" states problem for Turing Machines. 1. What are some undecidable syntactic properties? 2. Can we comment on the undecidability of a syntact...
I can't find example of L not regular language that suff(L) is regular I tried something like this: {0^n1^n|n>= 0}, but i can't prove that it's suffix is regular Suff(L) = {x ∈ Σ ∗ | ∃u ∈ Σ ∗ such that u · x ∈ L}. thank you for the help :)
Example of L not regular language that suff(L) is regular
|regular-languages|pumping-lemma|
I can't find example of L not regular language that suff(L) is regular I tried something like this: {0^n1^n|n>= 0}, but i can't prove that it's suffix is regular Suff(L) = {x ∈ Σ ∗ | ∃u ∈ Σ ∗ such that u · x ∈ L}. [![enter image description here][1]][1] thank you for the help :) [1]: https://i.stack.imgu...
I can't find example of L not regular language that suff(L) is regular I tried something like this: {0^n1^n|n>= 0}, but i can't prove that it's suffix is regular Suff(L) = {x ∈ Σ ∗ | ∃u ∈ Σ ∗ such that u · x ∈ L}. [![enter image description here][1]][1] thank you for the help :) [1]: https://i.stack.imgu...
Let $L = \{ 0^n \mid n \text{ is prime}\}$. Suppose towards a contradiction that $L$ is regular and let $p$ be a prime not smaller than the pumping length of $L$. The pumping lemma ensures that there is some $k$ such that $1 \le k \le p$ and $0^{p+ki} \in L$ for all $i \ge 0$. Choosing $i=p$ we have that $p+kp = p(k+1...
The celebrated proof that [IP = PSPACE](https://en.wikipedia.org/wiki/IP_(complexity)) relies on an interactive proof for the [QBF problem](https://en.wikipedia.org/wiki/True_quantified_Boolean_formula). Is there any other "natural" interactive proof for a PSPACE-hard problem other than QBF? (of course, since QB...
Interactive proof for PSPACE-hard problems different from QBF
|complexity-theory|interactive-proof-systems|
&nbsp; $P \rightarrow aP$ <br> &nbsp; $P \rightarrow a$ <br> &nbsp; $P \rightarrow bP$ <br> &nbsp; $P \rightarrow b$ <br> and ($P$ is the start symbol) <br> &nbsp;$P \rightarrow \epsilon$
Let the set of languages that can be represented by regular languages be $R$. And set of languages that can be generated by a context free grammar be $G$. Then surely $ R \subset G$. For the proof that every regular language has a context free grammar that generates it, I encourage you to look up Michael Sipser's book ...
I've seen that quantum computing calculations have their own complexity classes https://en.wikipedia.org/wiki/Quantum_complexity_theory, namely BQP and QMA. I've heard that this would beat any classical computer, but I wonder if it would also beat a custom-made *massively parallel computer*. By massively parallel co...
Are quantum computer strictly "faster" than any massively parallel computer in terms of computational complexity?
|parallel-computing|quantum-computing|
I've seen that quantum computing calculations have their own complexity classes https://en.wikipedia.org/wiki/Quantum_complexity_theory, namely BQP and QMA. I've heard that this would beat any classical computer, but I wonder if it would also beat a custom-made *massively parallel computer*. By massively parallel co...
null
Nope. For some problems, quantum computing is far more powerful than parallelization. If quantum computing can be made to work in practice and can scale (which is not yet known yet), then no, a massively parallel computer cannot do everything that a quantum computer can do. Intuitively, the reason is that for some...
> Lastly, I did not use the set $$ in my decision question. Therefore I am not 100% certain that it is the 'correct' formulation. It is not correct, indeed :) You are describing a decision problem, but it does not corresponding to your optimization problem. One of the questions you posted ([Optimization versio...
Here's Alan Turing's halting problem in pseudocode: function halts(f: Function, input: any): boolean { // Some logic that can supposedly solve the halting problem // ... } // A function that takes itself as an argument and does the opposite of what halts says function paradox...
How is there a paradox in the halting problem when you can trace it and it's very clearly non-halting?
|recursion|halting-problem|
Here's Alan Turing's halting problem in pseudocode: function halts(f: Function, input: any): boolean { // Some logic that can supposedly solve the halting problem // ... } // A function that takes itself as an argument and does the opposite of what halts says function paradox...
Nope. For some problems, quantum computing is far more powerful than parallelization. If quantum computing can be made to work in practice and can scale (which is not yet known yet), then no, a massively parallel computer cannot do everything that a quantum computer can do. Intuitively, the reason is that for some...
null
[1] gives an example for PDA which contains rules of: ``` (p,e,Z,q,Z) (p,e,A,q,A) ``` and says, > The third and fourth instructions say that, at any moment the automaton may move from state p to state q. So, how does PDA know when it needs to move from a state to another? [1] https://en.m.wikipedia.org/...
How PDA decide when and which state to transform to?
|pushdown-automata|
Quoting the same [Wikipedia page][1] (emphasis mine): > If, in every situation, at most one such transition action is possible, then the automaton is called a deterministic pushdown automaton (DPDA). In general, **if several actions are possible**, then the automaton is called a general, or **nondeterministic**, PDA...
> However, `halts` will also recognize that we're attempting to call paradox with paradox as a parameter, therefore invoking infinite recursion You seem to have a particular implementation of `halts` in mind. Also, your reasoning is not correct even assuming that implementation. Remember that the proof works fo...
null
With $k=1$ you can solve this in $O(n \log n)$ time using sorting networks. Pick a [sorting network](https://en.wikipedia.org/wiki/Sorting_network) of size $O(n \log n)$. You can implement each comparator using $O(1)$ steps, in your model. (To compare-and-sort the items at indices $i,j$, first cut the item at $i$ ...
null
Im designing my own CPU but I don't know how it jumps to an instruction that's no longer in ram. People have told me it puts the address in the SSD but for example, if the address were 3 in ram it would most likely not be in address 3 in the SSD. someone help me I don't understand.
How does a CPU jump to a instruction thats no longer in ram?
|computer-architecture|cpu|memory-access|memory-allocation|instruction-set|
It is often said that NP-intermediate problems, such as factoring, graph isomorphism, discrete log, and so on are "harder" than the problems in P. Meaning that they cannot be solved in polynomial time. But does this imply that all problems in P reduce to all problems in NPI? This would imply that all problems in...
Do all P problems reduce to all NPI problems?
|np|polynomial-time|np-intermediate|
It is often said that NP-intermediate problems, such as factoring, graph isomorphism, discrete log, and so on are "harder" than the problems in P. Meaning that they cannot be solved in polynomial time. But does this imply that all problems in P reduce to all problems in NPI? This would imply that all problems in...
If your notion of reduction is polytime m-reduction, then all problems in P (except the empty and full problems) reduce to all problems *whatsoever*, not just the ones in NP. In particular, any two problems in P are reducible to each other (modulo the previous parenthetical). Note that I was explicit about the choic...
You are correct; time complexity in theoretical computer science is usually measured in terms of the size of the input<sup>1</sup>. This imposes a wrinkle for working programmers using time complexity to reason about their algorithms' performance. As you note, a lot of operations on numbers have higher complexity th...
You are correct; time complexity in theoretical computer science is usually measured in terms of the size of the input<sup>1</sup>. This imposes a wrinkle for working programmers using time complexity to reason about their algorithms' performance. As you note, a lot of operations on numbers have higher complexity th...
If upward links are available, trace the path from $n_A$ to the root $r_A$, then trace back from $r_B$ to $n_B$. Otherwise, traverse $A$ until you find $n_A$, while keeping a trace of the path or performing the same moves in $B$. Note that a path can be represented as a mere bit string telling left or right on every...
If upward links are available, trace the path from $n_A$ to the root $r_A$, then trace back from $r_B$ to $n_B$. Otherwise, traverse $A$ until you find $n_A$ (using your favorite method), while keeping a trace of the path, or performing the same moves in $B$. Note that a path can be represented as a mere bit string ...
If upward links are available, trace the path from $n_A$ to the root $r_A$, then trace back from $r_B$ to $n_B$. Otherwise, traverse $A$ until you find $n_A$ (using your favorite method), while keeping a trace of the path, or performing the same moves in $B$. Note that a path can be represented as a mere bit string ...
If upward links are available, trace the path from $n_A$ to the root $r_A$, then trace back from $r_B$ to $n_B$. Otherwise, traverse $A$ until you find $n_A$ (using your favorite method), while keeping a trace of the path, or performing the same moves in $B$. Note that a path can be represented as a mere bit string ...
I've seen that quantum computing calculations have their own complexity classes https://en.wikipedia.org/wiki/Quantum_complexity_theory, namely BQP and QMA. I've heard that this would beat any classical computer, but I wonder if it would also beat a custom-made *massively parallel computer*. By massively parallel co...
null
> Lastly, I did not use the set $$ in my decision question. Therefore I am not 100% certain that it is the 'correct' formulation. It is not correct, indeed :) You are describing a decision problem, but it does not correspond to your optimization problem. One of the questions you posted ([Optimization version o...
The professor's solution differs from yours in an important way: it limits the memory size to $kn$, where $k$ is chosen by the user. Your solution does not offer this control and might lead to memory overflow.
null
We know if $NP\subseteq P/poly$ then $PH=\Sigma_2$ Then We want to show that $\Sigma_2-SAT\in P/poly$. Now $$\phi\in \Sigma_2-SAT\iff \exists\ x\in\{0,1\}^{p_1(n)}\ \forall\ y\in \{0,1\}^{p_2(n)},\ \phi(x,y)=1$$ Now consider the language $L=\{(\phi,x)\mid \forall \ y\in\{0,1\}^{p_2(n)},\ \phi(x,y)=1\}$. This language ...
$NP\ubseteq P/poly\implies PH\subseteq P/poly$
|np|circuits|
$NP\subseteq P/poly\implies PH\subseteq P/poly$
{"Voters":[{"Id":147547,"DisplayName":"Soham Chatterjee"}],"DeleteType":1}
null
According to the theorem(see reference) on the rigidity of frameworks: > A rectangular framework is rigid of and only if its associated bipartite graph is connected. Now consider the case for a 2-by-2 rectangular framework. [![enter image description here][2]][2] [![enter image description here][3]][3] In...
Is it possible to have a 2 by 2 rigid framework without having a corresponding connected bipartite graph?
|graphs|bipartite-graph|
null
Consider a Euclidean space $\mathbb{R}^d$. Consider $ X \subset \mathbb{R}^d$ where $X$ is a finite set with $|X|=n$. Consider the set of line segments $\{xy | x,y \in X\}$ . I have a process $Z$ that I want to apply to each line segment, from smallest to largest but I will stop examining line segments when a line segm...
Efficient ways to sort pairwise distances for set of points in Euclidean space?
|algorithms|efficiency|euclidean-distance|ordering|
According to the theorem(see reference) on the rigidity of frameworks: > A rectangular framework is rigid if and only if its associated bipartite graph is connected. Now consider the case for a 2-by-2 rectangular framework. [![enter image description here][2]][2] [![enter image description here][3]][3] In...
A better solution could be as follows: 1. Create a min heap over $n^2$ line segments. 2. Take the top element of the heap, check if it satisfies condition $C$. If it does not satisfy it, pop it out. If it satisfies the condition, stop. Step $1$, take $O(n^2)$ time. Step $2$ takes $O(p \log n)$ time, where $p$...
Given a problem (D, c, Min) with admissible set D={(x,y)∈R2 : |y+√3x|≤2√3,|y-√3x|≤2√3,|y|≤3} and the price function c(x, y) = x + 2y. Translate the given problem to a linear program in standard form. Determine the corresponding matrix A and the vectors ⃗b and ⃗c respectively.
How to solve a linear programming problem
|linear-programming|
In a multi commodity network, we define a demand to be a vector $d \in \mathbb{R}^{k}$, where $k$ is the number of pairs of sinks. That is, $k = \binom{S}{2}$, where $S$ is the set of sinks (aka terminals). For example, if $\left| S \right| = 3$ we have $\binom{3}{2} = 3$ possible pairs of sinks. A demand can be of...
Defining multi commodity flows as polytopes
|algorithms|graphs|network-flow|
The program counter holds an address. Period. The CPU fetches an instruction from that address. Period. Most CPUs today have a hardware unit called an MMU (memory management unit) which sits between the CPU and the RAM and messes with the addresses. The MMU takes the top many bits from the address and looks them up ...
Given two problems, $A$ and $B$, that are NP-hard. Is it true that one of the following is true? 1. $A \leq_m$ B 2. $B \leq_m$ A In other words, is there always a relationship between any two arbitrary NP-hard problems? Also, I am speaking of polynomial time reductions, but I don't think specifying that will...
Do all NP-hard problems have a reduction from one to another?
|np-complete|reductions|np-hard|np|
Clearly, $$ \frac{6}{n}\sum^{n - \frac{\log n}{3}}_{i=\frac{\log n}{3}} T(i)<\frac{6}{n}\sum^{n}_{i=1} T(i)$$ and using your integral, this is smaller than $$\frac6n\frac{n^2\log n}2=3n\log n.$$ Now, $$n\log n<3\log n+n+3n\log n.$$
Your main goal here is to rewrite your constraints as **linear constraints**. There is a good ressource to do such a translation [here](https://lpsolve.sourceforge.net/5.1/absolute.htm). You're lucky here as your constraints are of the form $|L| \leq C$ where $L$ is a linear combination of your variables and $C$ a c...
So the problem starts with a graph in which every node is connected with every node by a weighted edge. The goal is to find a weight treshold W, so that every edge that has a weight lower than or equal to W gets removed, which results in the maximum amount of connected components. A connected component is defined as at...
Find a weight treshold for edges for maximum number of connected components in a graph
|algorithms|graphs|graph-traversal|weighted-graphs|
So the problem starts with a graph in which every node is connected with every node by a weighted edge. The goal is to find a weight treshold W, so that every edge that has a weight lower than or equal to W gets removed, which results in the maximum amount of connected components. A connected component is defined as at...
In the class $IP$ we have a probabilistic polytime verifier which interacts with a nondeterministic prover polynomial times and all the messages are of length polynomial of the input. We can think of this as a $BPP$ machine asking queries to a $NP$ oracle and doing its computation. All the interactions the verifier doe...
is $IP=BPP^{NP}$
|oracle-machines|interactive-proof-systems|probabilistic-turing-machines|
null
Here's another FFT-based approach that I can confirm works. This builds off of Algorithm F in [Fast algorithms for Taylor shifts and certain difference equations](https://doi.org/10.1145/258726.258745) and has a natural extension to multivariate polynomials and shifts Assuming our polynomial is of degree $n$, given ...
Let L = { y = {0,1}* | y = code(M) for some Turing Machine M and M halts on no input} Is this language recognizable or unrecognizable?
Is this language recognizable or unrecognizable