instruction
stringlengths
0
29.8k
⌀
Actually, upon working on this problem for a bit more time, I discovered one method to build a size $O(n)$ and depth $O(\log n)$ CLA circuit. The key ingredient is the work-efficient parallel prefixsum network, e.g., as seen in the [Blelloch scan][1]. There, it is shown that using any associative binary operators in pl...
I will describe a polynomial time algorithm that solves both problem 1 and problem 2. I learned of the algorithm from this [paper](https://arxiv.org/abs/1604.07553). I am going to make the following assumptions: 1. No jokers (adding them is a small change). 2. There are only four colors. 3. There are at most two ...
We have a procedure $P(n)$ that makes multiple calls to a procedure $Q(m)$, and runs in polynomial time in n. Unfortunately, a significant flaw was discovered in $Q(m)$, and it had to be replaced by $R(m)$, which runs in exponential time in m. Thankfully, P is still correct when we replace each call to $Q(m)$ with a ca...
How can a $P(n)$ run in polynomial time if it calls $R(m)$ which has exponential time when m <= log n
|complexity-theory|reductions|polynomial-time-reductions|
How can a $P(n)$ run in polynomial time if it calls $R(m)$ which has exponential time
I will describe a polynomial time algorithm that solves both problem 1 and problem 2. I learned of the algorithm from this [paper](https://arxiv.org/abs/1604.07553). I am going to make the following assumptions: 1. No jokers (adding them is a small change). 2. There are only four colors. 3. There are at most two ...
null
If $R(m)$ runs in exponential time in $m$, that means that the running time of $R(m)$ is, informally, something like $O(2^m)$. More formally, its running time is $O(c^m)$ for some constant $c$. Now plug in $m=\log n$, simplify, and see what conclusions you can draw about the running time as a function of $n$.
If $R$ is exponential in $n$, it is polynomial in $\log n$. E.g. $$T(n)=4^n\to T(\log_2n)=4^{\log_2n}=n^2.$$
Prove - The spanning tree M is a minimum spanning tree for G with weights c > 0 if and only if M is a minimum spanning tree for G with weights cx for x > 0. I am confused, how to prove this, as c could be between 0 and 1, and then multiplying edge weights by c, will decrease weight. Any, quick help would be ap...
Prove this MST statement - The spanning tree M is a minimum spanning tree for G with weights c > 0 if and only if M is aMST with weights cx for x > 0
|minimum-spanning-tree|
null
If $R(n)$ is exponential in $n$, $R(\log n)$ is polynomial in $n$. E.g. $$T(n)=4^n\to T(\log_2n)=4^{\log_2n}=n^2.$$
Suppose that I have 7 different integers stored in an array. Among those arrange- ments that can be viewed as a min heap, what is the maximum number of inverse pairs within the array?
What is the maximum inverse pairs will I have when I build a heap?
|heaps|
If ETM = {<M> ∣ M is a Turing Machine and L(M) = ∅}, how can I prove that the complement of ETM is semi-decidable?
How complement of ETM is semidecidable
|semi-decidability|
|turing-machines|semi-decidability|
|turing-machines|reductions|semi-decidability|
By exhaustive search, $[1, 5, 2, 7, 6, 4, 3]$ has $9$ inversions.
In a video Noam Chomsky said, that if these LLM get bigger, than also the things they are not good at get bigger too. He doesn't explain more details about this. So is this true? In what way do their problems get bigger? Sry for the little context of in what they are getting also more bad at.
If Large Language Models like ChatGTP grow, do also their problems grow?
|artificial-intelligence|natural-language-processing|
Prove - The spanning tree M is a minimum spanning tree for G with weights c > 0 if and only if M is a minimum spanning tree for G with weights c^x for x > 0. I am confused, how to prove this, as c could be between 0 and 1, and then multiplying edge weights by c, will decrease weight. Any, quick help would be a...
Post's problem, posed in 1944 by Post, was to know if there is a recursively enumerable set, which, being undecidable, was not equivalent to the Halting problem under Turing reducibility. While I've seen the proof that such sets exist (the book [Gems of Theoretical Computer Science](https://link.springer.com/book/10.10...
Concrete example of a set with a lower degree of unsolvability
|turing-machines|computability|reductions|halting-problem|turing-completeness|
null
First, you have to find a way to enumerate the elements of $\overline{ETM}$. One way is to create a procedure which, in stage $n$, tests the first $n$ Turing machines for the first $n$ inputs for $n$ steps, outputing the code of a machine if it finds an input it accepts. If $M\in\overline{ETM}$, then, eventually, your ...
Quantum search differs from the standard boolean SAT as it is restricted to only oracle calls to a circuit (or CNF formula). Where SAT gives us the *structure* of a formula (however loosely defined that is), quantum search algorithms make queries to $U_f$. It seems pretty clear that this oracle-only SAT problem is N...
Is Quantum Search (SAT with only oracle access) NP-hard (and not NP-complete)?
|turing-machines|quantum-computing|p-vs-np|oracle-machines|oracles|
null
null
I was reading the LICM section of the book Advanced Compiler Design and Implementation and found me questioning why the expression `d = -c` wasn't tagged as invariant. It isn't hard to see that `c = 2` is invariant given its operand is a constant. Then, since `d = -c` is taking an invariant operand, then `d` also sh...
Loop Invariant Code Motion not tagging an expression correctly
|optimization|compilers|
null
TLA+ is commonly used for verification of distributed algorithms. I've seen it actively used by researchers and industry engineers/architects.
null
How can you reach from v to v using bfs? And bfs gives wrong ans for the graph-> 1 2 2 3 2 4 3 4 given that special vertex is 1. Here BFS will tell that there is a cycle but that cycle does not includes special vertex 1.
If you have $7$ (or rather $2^{n}-1$) arbitrary numbers, then brute force is the way to go. However, there are some observations if you construct a heap with all distinct numbers in the range $1 ... 2^{n}-1$. Intuitively(for the lack of a rigorous mathematical proof), a min heap formed by inserting in *reverse posto...
If you have $7$ (or rather $2^{n}-1$) arbitrary numbers, then brute force is the way to go. However, there are some observations if you construct a heap with all distinct numbers in the range $1 ... 2^{n}-1$. Intuitively(for the lack of a rigorous mathematical proof), a min heap formed by inserting in *reverse posto...
null
Quantum search differs from the standard boolean SAT as it is restricted to only oracle calls to a circuit (or CNF formula). Where SAT gives us the *structure* of a formula (however loosely defined that is), quantum search algorithms make queries to $U_f$. It seems pretty clear that this oracle-only SAT problem is N...
null
[![graph][1]][1] I get the residual graph by Ford-Fulkerson Algorithm: [![2][2]][2] I get that the minimum cut can be found by the residual graph, and when traversing this residual network from the source to all reachable nodes, these nodes define one part of the partition. Call this partition $S$, the rest ...
How to find the subset S and T and the min-cut of this graph
|graphs|network-flow|minimum-cuts|ford-fulkerson|
How to find the subsets S and T and the min-cut of this graph?
null
I have a problem $\mathsf{A}$ and I would like to analyze its (parameterized) computational complexity. I found a parameterized reduction from the complement of the independent set ($\mathsf{coIS}$) problem (i.e. given a graph $G$ and an integer $k$, is there **no** independent set of size $k$ in G?), such that the...
Is there such a thing as $coW[1]$-hardness?
|complexity-theory|reductions|complexity-classes|parameterized-complexity|
The title isn't the most explanatory or accurate since I had issues putting it into just a few words so here we go. I have a real-world problem and managed to find an inefficient solution that my computer is barely able to find before running out of RAM. I'm interested to find out if my problem is unique or if there is...
Algorithm for finding a consequtive sequence of clips with the least amount of cuts
|algorithms|
null
Let $\mathcal{F}$ be a family of pairs of the form $(A,b)$, where $A$ is an integer matrix and $b$ is an integer vector with the same number of rows. For every integer $k$, define $L(\mathcal{F}, k)$ to be the following family of decision problems. > INPUT: a pair $(A,b)\in \mathcal{F}$. > > OUTPUT: "True" if ther...
The comment by Rinkesh is correct. The expression $-c$ is loop-invariant (and can be constant-propagated to the value $-2$), but the assignment $d \leftarrow -c$ is not because the assignment in block B4 might execute instead. If you're still not convinced, try converting it to static single assignment (SSA) form.
We are require to show that a problem where the input is a system of equalities and inequalities, each involving polynomials of degree at most 2 (with integer coefficients) in n real variables x<sub>1</sub>, x<sub>2</sub>, ..., x<sub>n</sub>. The problem is to decide whether there exists an assignment to x<sub>1</sub>...
System of equalities and inequalities is NP-hard using a reduction from 3COLORING
|complexity-theory|np-complete|reductions|np-hard|3-sat|
You can express any boolean formula using a (polynomial-size) system of quadratic equalities. Indeed you can force a variable $x$ to be binary by writing $x^2 = 1$, and you can force a binary variable $z$ to be the NAND of two binary variables $x$ and $y$ by writing $z = 1 - xy$ (recall that NAND is a universal operati...
I am self teaching myself basics of AI, from the internet, I am trying to do pset3 of MIT's 6.034 here at https://ocw.mit.edu/courses/6-034-artificial-intelligence-fall-2010/pages/assignments/ the specs of the pset wants to implement a alpha-beta search algorithm with the following signature def alpha_beta...
Help regarding alpha-beta search
|algorithms|search-algorithms|
First, let me show that your proposed $A$ is equivalent to the halting problem after all. Let $a_n$ be the $n$th element of $A$ by size; we have $a_n\ge BB(n)$, and so $A$ computes a function dominating $BB$. Since any function dominating $BB$ computes $0'$, we get $A\ge_T0'$. More generally, any infinite subset of $ra...
First, let me show that your proposed $A$ is equivalent to the halting problem after all. Let $a_n$ be the $n$th element of $A$ by size; we have $a_n\ge BB(n)$, and so $A$ computes a function dominating $BB$. Since any function dominating $BB$ computes $0'$, we get $A\ge_T0'$. More generally, any infinite subset of $ra...
This is a kind of [exact cover](https://en.wikipedia.org/wiki/Exact_cover) problem, one where you want to minimize the size of the cover (i.e., minimize the number of sets selected to be in the cover). Here, each potential range forms a set, containing the clips that are found in that range. A plausible approach wo...
I want to find an appropriate structuring element so that only the indicated pixels (by X) are removed as a result of an opening operation, while all other image points remain unchanged. I know how to do opening operation but designing the kernel is very confusing. Is there a simple way to this by inspection? [![en...
Design of opening structuring element
|computer-vision|
public static void reverseFirstK(Queue<Integer> q, int k) { LinkedList<Integer> stack = new LinkedList<>(); for (int i = 0; i < k; i++) { stack.push(q.remove()); } System.out.println(q); System.out.println(stack); while (!stack.isEmpty()) { ...
What is the order of items being popped and pushed from a stack?
|stacks|queues|
You can express any boolean formula using a (polynomial-size) system of quadratic equalities. Indeed you can force a variable $x$ to be binary by writing $x^2 = x$, and you can force a binary variable $z$ to be the NAND of two binary variables $x$ and $y$ by writing $z = 1 - xy$ (recall that NAND is a universal operati...
> Prove - The spanning tree $M$ is a minimum spanning tree (MST) for $G$ with weights $c > 0$ if and only if $M$ is an MST for $G$ with weights $c^x$ for $x > 0$. I am confused, how to prove this, as $c$ could be between $0$ and $1$, and then multiplying edge weights by $c$, will decrease weight. How can I prove t...
Prove a spanning tree M is an MST for G with weights c > 0 if and only if M is an MST with weights c^x for x > 0
null
public static void reverseFirstK(Queue<Integer> q, int k) { LinkedList<Integer> stack = new LinkedList<>(); for (int i = 0; i < k; i++) { stack.push(q.remove()); } System.out.println(q); System.out.println(stack); while (!stack.isEmpty()) { ...
I was studying graphs and it got me wondering if edges with negative weights affected the outcome of Prim's Algorithm in finding a minimum spanning tree. So would the Prim's algorithm still find a suitable MST unaffected by negative weights on the edges of the graph?
Would edges with negative weights affect Prim's Algorithm?
|algorithms|graphs|minimum-spanning-tree|
null
**Preliminaries**. Let $n,m,p \in \mathbb{N}$ with $n,m,p > 1$. We allow that $p$ could be large but still bounded by a function of $n$: $p = O(2^n)$. Let our alphabet be $\Sigma = \{0,1\}$, with non-empty languages $ L_1,L_2,...L_p \subseteq \Sigma^n$ and $ L' \subseteq \Sigma^m$. The other preliminaries are the s...
Counting States in the trim automaton for $(L_1 \cup L_2 \cup \ldots \cup L_p) \circ L'$
|regular-languages|finite-automata|
With $M=3,N=2$, the expression expands to $$\begin{align}T(u,v)= &f(0,0)\,r(0,0,u,v)+f(0,1)\,r(0,1,u,v)+\\ &f(1,0)\,r(1,0,u,v)+f(1,1)\,r(0,1,u,v)+\\ &f(2,0)\,r(2,0,u,v)+f(2,1)\,r(0,1,u,v)\end{align}.$$ $f$ denotes an image (bidimensional array of pixel values), $T$ is the image transformed to another bidimensi...
null
With $M=3,N=2$, the expression expands to $$\begin{align}T(u,v)= &f(0,0)\,r(0,0,u,v)+f(0,1)\,r(0,1,u,v)+\\ &f(1,0)\,r(1,0,u,v)+f(1,1)\,r(0,1,u,v)+\\ &f(2,0)\,r(2,0,u,v)+f(2,1)\,r(0,1,u,v)\end{align}.$$ $f$ denotes an image (bidimensional array of pixel values), $T$ is the image transformed to another bidimensi...
Yes, and yes. This follows from the result in [your prior question](https://cs.stackexchange.com/q/159828/755), letting $L = L_1 \cup L_2$ or $L = L_1 \cup \dots \cup L_p$.
The multi message problem is: Let there be an undirected graph $G = (V,E)$ with $n$ vertices, and let $r \in G$. The algorithm sends a message $M_i$ of size $\Omega(\log(n))$ to each vertex $v_i$ using the shortest path. The cost of the problem is the sum of route length multiplied by the message size. Let denote ...
Universal lower bound of the multi message problem
|algorithms|complexity-theory|graphs|distributed-systems|lower-bounds|
null