instruction
stringlengths
0
29.8k
⌀
Morandini, [NP-complete problem: partition into triangles](http://profs.sci.univr.it/~rrizzi/classes/Complexity/provette/Mirko/pt_fine.pdf) shows that the following problem is NP-complete: Given a tripartite graph $G$ on $3n$ vertices (given together with a tripartition), determine whether $G$ contains $n$ vertex-disjo...
You should add, as stated in the book, that, in a path, "all moves must move away from the ground" (meaning that a path cannot contains two children of the same node). That is an important information. Now, you should consider a path from a leaf of maximal depth, delete it and rince and repeat. For the correctnes...
Not only does it make sense, it's a common data structure in operating systems to implement the ready queue for tasks. Operating systems typically have a fixed number of priority levels, so it makes sense. One optimisation if you have a lot of priority levels (say, 64 to 256 of them) is to also maintain a bit vector...
null
Cheers, I am trying to solve the problem of minimum length cycle in a graph, and I came across a solution that suggested that I should tweak the Floyd-Warshall algorithm to solve that. It stated that instead of setting `path[i][i] = 0` I should instead set `path[i][i] = INFINITY`, but I don't exactly understand why tha...
Tweaking Floyd-Warshall Algorithm to detect cycles
|algorithms|graphs|greedy-algorithms|weighted-graphs|
null
Yves's answer will give you exactly the answer you are looking for. An alternative is to use [stochastic rounding][1] which will give you the rounded sum *in expectation*, and may have nicer properties for the individual numbers, although you say that is not important. The idea is to round the number up to the ne...
null
Consider the language $$L = \{\langle M \rangle \mid \text{$\exists$ an input $x$, where $|x|<i$, such that $M$ halts on $x$, but it takes at least $j$ steps} \}$$ where $i$ and $j$ are fixed non-zero natural number for L I am trying to prove that $L$ is **undecidable**. My thought is that reduce the **Universa...
As in, given a regular language $V$, does there exist a deterministic Büchi automaton $\mathcal{A}$, or equivalently a regular language $W$ such that $\mathcal{L}(\mathcal{A})=\vec{W}=V^\omega$? For clarity, if $L$ is a finite-word language, then $L^\omega$ and $\vec{L}$ are resp. the $\omega$-closure and the limit ...
As in, given a regular language $V$, does there exist a deterministic Büchi automaton $\mathcal{A}$, or equivalently a regular language $W$ such that $\mathcal{L}(\mathcal{A})=\vec{W}=V^\omega$? For clarity, if $L$ is a finite-word language, then $L^\omega$ and $\vec{L}$ are resp. the $\omega$-closure and the limit ...
As in, given a regular language $V$, does there exist a deterministic Büchi automaton $\mathcal{A}$, or equivalently a regular language $W$ such that $\mathcal{L}(\mathcal{A})=\vec{W}=V^\omega$? For clarity, if $L$ is a finite-word language, then $L^\omega$ and $\vec{L}$ are resp. the $\omega$-closure and the limit ...
Suppose given a tree $T=(V,E)$ with $|V|=n $ and $k\in \mathbb{N}$ that each node has degree at most $3$. How we can find a path on $T$ that has length $k$ and minimum number of edges in $O(n\log^2n)$? I think we can use BFS because BFS give us shortest path in term of number of edges.
Find a path with length $k$ and minimum number of edges on a tree
|algorithms|
null
As in, given a regular language $V$, does there exist a deterministic Büchi automaton $\mathcal{A}$, or equivalently a regular language $W$ such that $\mathcal{L}(\mathcal{A})=\vec{W}=V^\omega$? For clarity, if $L$ is a finite-word language, then $L^\omega$ and $\vec{L}$ are resp. the $\omega$-closure and the limit ...
There are [many rounding methods that round an integer to the nearest integer](https://en.wikipedia.org/wiki/Rounding#Rounding_to_the_nearest_integer), all of which are the same except on the half-integers. The sum of integers returned will be close to the sum of the original numbers on average when the distribution of...
Fix $i$ and $j$ as two positive integers, as per your comment. Consider the language $H$ containing all pairs $\langle T, y\rangle$ where $T$ is (encoding of) a Turing machine, $y \in \Sigma^*$, and $T$ halts when its input is $y$. Notice that, given $\langle T, y\rangle$, you can compute (the description of) a T...
null
Fix $i$ and $j$ as two positive integers, as per your comment. Consider the language $H$ containing all pairs $\langle T, y\rangle$ where $T$ is (encoding of) a Turing machine, $y \in \Sigma^*$, and $T$ halts when its input is $y$. Notice that, given $\langle T, y\rangle$, you can compute (the description of) a T...
Suppose given a weighted positive tree $T=(V,E)$ with $|V|=n $ and $k\in \mathbb{N}$ that each node has degree at most $3$. How we can find a path on $T$ that has length $k$ and minimum number of edges in $O(n\log^2n)$? I think we can use BFS because BFS give us shortest path in term of number of edges.
Suppose the optimal color assignment of graph $G$ is given. Does there exist any polynomial-time algorithm that provides the optimal color assignment of its complement graph $\overline{G}$? A relation between $\chi(G)$ and $\chi(\overline{G})$ is present [here][1]. But it is not providing the exact value of $\chi(\...
Given the optimal coloring of a graph how will we find the optimal coloring of its complement graph?
|algorithms|complexity-theory|graphs|colorings|polynomial-time-reductions|
Suppose given a positive weighted tree $T=(V,E,w)$,$w$ is weight function $E$, $w:\mathbb{N}\to\mathbb{N}$ with $|V|=n $ and $k\in \mathbb{N}$ that each node has degree at most $3$. How we can find a path on $T$ that has length $k$ and minimum number of edges in $O(n\log^2n)$? I think we can use BFS because BFS give...
Suppose given a positively-weighted tree $T=(V,E,w)$ and $k\in \mathbb{N}$, where $|V|=n$, the weight function $w:E\to\mathbb{N}$, and each node has degree at most $3$. How we can find a path on $T$ that has weight $k$ and the minimum number of edges in $O(n\log^2n)$? I think we can use BFS because BFS give us the s...
|algorithms|time-complexity|trees|
Find a path with given weight and the minimum number of edges on a tree
null
There might have been confusion on the meaning of "return the opposite of what it returns" when you run $M$ on $w$. When $M$ runs forever, nothing can be returned by $M$. Then that rule does not make sense! Not only there is no way to specify "the opposite of" nothing<!-- especially when there is a choice between "a...
There might have been confusion on the meaning of "return the opposite of what it returns" when you run $M$ on $w$. When $M$ runs forever, nothing can be returned by $M$. Then that rule does not make sense! Not only there is no way to specify "the opposite of" nothing<!-- especially when there is a choice between "a...
null
Bellmon Ford is used by distance vector routing protocol (DVR). In DVR technique router keep knowledge of only next router which is adjacent that's why exchange of routing database only with neighbors. So in DVR no need of shortest path. But in DVR every router will be able to find shortest path very slowly after stabi...
Bellmon Ford is used by distance vector routing protocol (DVR). In DVR technique router keep knowledge of only next router which is adjacent that's why exchange of routing database only with neighbors. So in DVR no need of shortest path. But in DVR every router implicitly will able to find shortest path very slowly...
null
I am absolutely stumped on this one. I am unsure of how to start with this one. I have thought to reducing the problem to Atm. Another thought I have had is to convert M1 to a PDA and use the complement of EQPDA to solve this but I am honestly really unsure. Any tips that could point me in the right direction or soluti...
Prove that DIFFERENTDFA, PDA {<M1, M2> | Where M1 is a DFA and M2 is a PDA where L(M1)≠L(M2)} is undecidable
|reductions|undecidability|theory|mapreduce|
You know something about logic gates since I see them in your question. I believe that computers can do much more than add, but let me play devil's advocate and try to show you that we could think of most of what computers do is adding. So the main logic gates in classical computers (the ones that use electricity) ...
null
I came across this recent Reddit thread, _[Thoughts on Botton vs Unit Types](https://www.reddit.com/r/ProgrammingLanguages/comments/ue4arp/thoughts_on_bottom_vs_unit_types/)_, but I don't understand what the similarities and differences are in regards to when you are creating a programming language. If you are creat...
Similarities and differences between Unit and Bottom types?
|programming-languages|type-theory|
For instance can we categorize the following problems into NP-Hard ? 1. Is the Universe finite ? 2. Is there life after death ? 3. What came first, the chicken or the egg ? My question is more around what can be modelled into the PSPACE category of problems ?
Can every problem in the world be classified into PSPACE categories?
|np-hard|np|decision-problem|
I'm not sure if this question is meant seriously, but it actually relates to a common misunderstanding in computability. Recall that a problem is formally captured as a formal language, i.e. a set of strings that are, intuitively, the "yes" instances of the problem. For example, $$SAT=\{\langle \phi\rangle: \phi \...
I am absolutely stumped on this one. I am unsure of how to start with this one. I have thought to reducing the problem to Atm. Another thought I have had is to convert M1 to a PDA and use the complement of EQPDA to solve this but I am honestly really unsure. Any tips that could point me in the right direction or soluti...
null
**Hint 1**: Given - distinct numbers $a_1, \cdots, a_s$ are in a balanced binary tree with $s$ nodes and - distinct numbers $b_1, \cdots, b_t$ are in another balanced binary tree with $t$ nodes. We can find all pairs $(a_i, b_j)$ such that $a_i+b_j=k$ in $O(\min(s,t)\log(\max(s,t))$ time. **Hint 2**: Let - $...
*This is cross-posted from [a similar question][1] on Mathematics Stack Exchange, on the advice of a commenter.* In mathematical logic, a **formal system** is a structure which includes, amongst other things, a set of axioms, and which is able to determine the truth or falsehood of statements with respect to those a...
Is it coherent to treat the C programming language as a formal system?
|logic|
If you let it, running the algorithm will produce, in `path[i][i]`, the length of the shortest path from node `i` to `i`. The length of the shortest cycle will be the smallest value on the diagonal. This requires - updating `path[i][i]`, instead of skipping it, like [that visualization][1] does; - initializing `pat...
The number of iterations of the body of the loop is $\max(0,n-1)$. The number of comparisons performed at line $3$ is $\max(1,n)$. For both, best case and worst case are identical. If the answer sheet says otherwise, it is wrong.
"[Balanced binary search tree](https://en.wikipedia.org/wiki/Self-balancing_binary_search_tree)" will be written as "BBST" **Hint 1**: Given - distinct numbers $a_1, \cdots, a_s$ are in a BBST with $s$ nodes and - distinct numbers $b_1, \cdots, b_t$ are in another BBST with $t$ nodes. We can find all pairs $(a...
I think you are conflating several different issues, in addition to conflating concepts from mathematical type theory with concepts from practical, "real-world" programming language design. In practical programming language design, the defining feature of a bottom type is not that it has no members. The defining fea...
Reading the Wikipedia pages on these topics, it seems that sparse conditional constant propagation (SCCP) is a more powerful form of constant propagation (CP)? E.g all optimizations available in CP are subsumed in SCCP.
What is the difference between sparse conditional constant propagation and constant propagation?
|program-optimization|
null
For example, if it takes 1 cycle to read the cache and 3 cycles to write the cache, is the hit time equal to 4 cycles? Also, does this vary based on whether the cache is an instruction cache or a data cache?
Does cache hit time include both time to read a cache and time to write a cache?
|computer-architecture|cache|
Observe that after index is incremented from n to n+1 by line 6, the condition in line 3 is tested one last time (this condition evaluates to False because index=n+1, which is not <=n) before the while loop exists. Line 3 is executed for the first time when index = 2, and executed for the last time when index = n ...
null
I was given a question in Automata that I need to prove or disprove, and I thought about this language: $$L=\{w \in \{0,1\} ~~ \mathbb{s.t} ~~ |w|=2^i , \forall i=0,...,6 \}$$ Can you please help me to figure out if its minimal DFA contains only 6 states? How can I get intuition about DFA sizes? Thanks a lo...
DFA for $L=\{w \in \{0,1\} | |w|=2^i , \forall i=0,...,6 \}$
|computability|automata|finite-automata|
I answer assuming the language is $L = \{w\in \{0, 1\}^*\mid \exists i\in \{0, …, 6\} : |w| = 2^i\}$. Suppose the minimal DFA $(Q, \delta, q_0, F)$ contains strictly less than $2^6$ states. Then there exists a state $q$ and two words $u$, $v$ such that $|u| < |v| \leqslant 2^6$ and $\delta(q_0, u) = \delta(q_0, v) =...
null
I am wondering about the complexity of the following SAT related problem: Given a CNF with $n$ clauses containing exactly $k$ literals with the following properties: - The intersection of any pair of different clauses only contains 1 variable. - Every variable is only contained in one intersection. So every variab...
Complexity of a restricted SAT problem
|complexity-theory|time-complexity|3-sat|constraint-satisfaction|
Jörg W Mittag gives an excellent answer. But I think it does miss the heart of the question. The quote says "For the sake of this discussion, let's call the bottom type a type that has no members." So while Jorg is right that the "the defining feature of a bottom type is not that it has no members" and that "it is p...
I am reading Michael Sipser's "Theory of Computation". In one of the proofs he talks about converting "DFA to Regular Expression" and he talks about "GNFAs". I understand one method of converting DFA to Regular Expression that is using Arden's Theorem. I assume GNFA is a medium between DFA and Regular Expression. Can s...
Converting Deterministic Finite Automata to Regular Expression
|automata|finite-automata|regular-expressions|theory|
You should add, as stated in the book, that, in a path, "all moves must move away from the ground" (meaning that a path cannot contains two children of the same node). That is an important information. Now, you should consider a path from a leaf of maximal depth, delete it and rince and repeat. For the correctnes...
Jörg W Mittag gives an excellent answer. But I think it does miss the heart of the question. The quote says "For the sake of this discussion, let's call the bottom type a type that has no members." So while Jorg is right that the "the defining feature of a bottom type is not that it has no members" and that "it is p...
null
Jörg W Mittag gives an excellent answer. But I think it does miss the heart of the question. The quote says "For the sake of this discussion, let's call the bottom type a type that has no members." So while Jorg is right that the "the defining feature of a bottom type is not that it has no members" and that "it is p...
Suppose we have $n$ candidates from a candidate pool $\{1,2, .., n\}$ and we have $m$ departments. Suppose each department $d$ is considering hiring some $C_d \subseteq \{1, 2, ... n\}$ candidates (with possible overlap between departments), and that each department $d$ *must* hire exactly $r_d$ of the $|C_d|$ many can...
Checking NP-completeness of the following problem(s)- Assigning candidates to departments
|algorithms|complexity-theory|np-complete|np-hard|decision-problem|
Jörg W Mittag gives an excellent answer. But I think it does miss the heart of the question. The quote says "For the sake of this discussion, let's call the bottom type a type that has no members." So while Jorg is right that the "the defining feature of a bottom type is not that it has no members" and that "it is p...
Jörg W Mittag gives an excellent answer. But I think it does miss the heart of the question. The quote says "For the sake of this discussion, let's call the bottom type a type that has no members." So while Jorg is right that the "the defining feature of a bottom type is not that it has no members" and that "it is p...
Your problem is not $NP$-complete because it is not a decision problem and hence it is not even in $NP$. Moreover your problem is not $NP$-hard, unless $P=NP$. In fact, your problem can be solved in polynomial time. To do so, create a bipartite graph $G=(U+V, E)$ where $U=\{1,\dots,n\}$ represents candidates and $V...
You should add, as stated in the book, that, in a path, "all moves must move away from the ground" (meaning that a path cannot contains two children of the same node). That is an important information. Now, you should consider a path from a leaf of maximal depth, delete it and rince and repeat. For the correctnes...
Suppose we have $n$ candidates from a candidate pool $\{1,2, .., n\}$ and we have $m$ departments. A candidate can be assigned to at most one department (so not being assigned is possible). Each department $d$ is considering candidates in $C_d \subseteq \{1, 2, ... n\}$ (with possible overlap between departments), and ...
NP-completeness of some problems on assigning candidates to departments
Suppose we are at the centre of a $k$ road intersection (i.e, there are $k$ different roads radiating out from where we are standing, infinitely). Suppose along one of these roads is a treasure. This treasure is along one of these roads at distance $d \in \mathbb{Z}$ from the center. We do not know which road and...
Deterministic Algorithm for searching for object $d$ units down one road in a $k$ road intersection
|algorithms|complexity-theory|algorithm-analysis|competitive-ratio|
Consider a function $C(n, d)$ which counts the number of well formed, i.e, balanced, parenthetical 'words' of length $n$ and maximal nested depth $\leq d$. That is, $(())$ has $n = 4, d = 2$. $()((())())$ has $n = 10, d = 3$ and so on. $C(n, d)$ counts all well formed strings above (i.e, $($ and $)$ are bal...
A recursive relation for the number of well formed nested parentheses of length $n$ and depth $\leq d$
|algorithms|recurrence-relation|recursion|