instruction
stringlengths
0
29.8k
⌀
Your second idea is good, there is no need to start at $n = 1$: You already proved that for $n\geqslant 3$, $T(n) \leqslant n - 1$. You can now say that since $n-1 \leqslant n$ and since $T(1)\leqslant 1$ and $T(2)\leqslant 2$, then for all $n$, $T(n) \leqslant n$. (You can consider $T(n) \leqslant n +1$ if yo...
i figured out this is what i want to know: in Cook's theorem it is shown that SAT is NP-hard. he shows it by showing that sat is at least as difficult like the word problem for nondet. Polynomial Time Machines. I want to know how i would proof that 2-sat is P-hard while showing that 2-sat is at least as difficult like...
in the cook-levin theorem a nondet. Turingmachine is translated into a formula of the form $\phi$ = y$_{1}$ $\land$ y$_{2}$ $\land$ y$_{3}$ $\land$ y$_{4}$. I want to know what difference in the formula there is if i would do the same for a DET. Turingmachine and why these differences may occure. Thanks in advance
Translate det. Turingmachine into formula
|turing-machines|nondeterminism|
in the cook-levin theorem a nondet. Turingmachine is translated into a formula of the form: $\phi$ = $\phi$$_{1}$ $\land$ $\phi$$_{2}$ $\land$ $\phi$$_{3}$ $\land$ $\phi$$_{4}$. I want to know what difference in the formula there is if i would do the same for a DET. Turingmachine and why these differences may occure...
The problem in the question is a good example for two points. - You can change the base case in a mathematical induction so that the base case will succeed. <!-- Accordingly, the domain of the proposition or even the whole proposition to be proved should be updated.--> Thanks to your substitution method in your t...
2SAT is NL-complete (with respect to logspace reductions). [Wikipedia](https://en.wikipedia.org/wiki/2-satisfiability#Complexity_and_extensions) outlines a proof: 1. We start by describing Krom's algorithm for 2SAT, using the *implication graph*. In this directed graph, the vertices are all literals, and each clause...
Given the algorithm ``` MYSTERY-ALG(n >= 0) 1 if n < 3 then 2 return 1 3 else 4 return MYSTERY-ALG(n/2) + MYSTERY-ALG((n/2) + 1) ``` I defined a recurrence $ T(n) = \begin{cases} 1 & 0 \leq n < 3 \\ T(\frac{n}{2}) + T(\frac{n}{2} + 1) & \text{otherwise} \end{cases} ...
[![The network topology for the question][1]][1] I am trying to understand count-to-infinity avoidance techniques, and came across this topology. Now, suppose the **interface eth1 on R1 has gone bad**, and assuming that split horizon, triggered updates and poison reverse are all enabled, what is the effect of hold-­...
Count-to-infinity avoidance techniques and hold-down timeout based question
|computer-networks|routing|
null
word problem: given a language L, is the word w in the language L? I want to know if there is a way to reduce the word problem to sat / cnf-sat or 2-sat. can't think of a way that i could do that so i wanted to ask on here. my professor said i should take a look at the proof for cnf-sat / 3-sat in NP and then see wh...
reducing the word problem for dtm to sat / cnf-sat / 2-sat
|reductions|satisfiability|2-sat|
The answer is no because the problem seems undecidable. You can reduce the halting problem to it.
The problem is that the resulting formula does not have a length that is polynomial in the original formula since you are doubling the size of the formula every time you remove a quantifier. Even though $QBF_k \le QBF_{k-1}$, you cannot compose the reductions the way you are doing and still get a polynomial reductio...
In the universal relation $UR_n$ problem [1] of communication complexity, there are two players Alice and Bob. Alice gets a string $x \in \{0,1\}^n$, Bob gets a string $y \in \{0,1\}^n$ with the promise that $x \ne y$. The players exchange messages and the last player to receive a message must output an index $i \in [n...
The universal relation problem in communication complexity
|randomized-algorithms|communication-complexity|
If public randomness is allowed, then the two parties apply a common random permutation on their inputs.
I am wondering as to how to efficiently encode the following subcircuit for a binary satisfiability solver (cnf, and optionally xor clauses, if this helps): ``` eq2 = sum(a, b, c, d, e, f, g, h) == 2 eq3 = sum(a, b, c, d, e, f, g, h) == 3 ``` (All variables binary. That is, `eq2` should be set if and o...
Effecient encoding of sum equality in cnf+xor
|satisfiability|xor|
word problem: given a language L through a deterministic turing machine, is the word w in the language L? I want to know if there is a way to reduce the word problem to sat / cnf-sat or 2-sat. can't think of a way that i could do that so i wanted to ask on here. my professor said i should take a look at the proof fo...
I'm reading CLRS and there is something I don't understand regarding counting the number of parenthesization, in the Matrix-chain multiplication chapter, the book says: > Denote the number of alternative parenthesizations of a sequence of $n$ matrices by $P(n)$. When $n$ = 1, we have just one matrix and therefore on...
Counting the number of parenthesization
|dynamic-programming|matrices|
null
null
word problem: given a language L through a deterministic turing machine, is the word w in the language L? the problem should be decidable, since if there is a deterministic turing machine i can simply turn that into a dfa take the word w go through the dfa step by step and see if i end in an accepting state? I no...
If we have a BST but want to keep it balanced, how much more expensive does adding an element to it become? Clearly adding an element (without maintaining balance) is of time complexity O(log(n)), as we traverse the tree down to the point where we should add the element, but if we want to maintain a balanced tree such ...
What is the time complexity of adding to a BST if we are to maintain balance
|binary-search-trees|
Suppose you have $n$ matrices $M_1, M_2, …, M_n$. The product of all matrices is $M_1\times M_2\times…\times M_n$ and since the matrix product is associative, there is no need for parentheses from a mathematical point of view. However, from a complexity perspective, the product may not takes the same amount of co...
null
Checking if a tree is balanced is clearly in time linear in the size of the tree. However, balancing when inserting or deleting nodes can indeed be done in $\mathcal{O}(\log n)$, using [AVL trees](https://en.wikipedia.org/wiki/AVL_tree) or [red-black trees](https://en.wikipedia.org/wiki/Red%E2%80%93black_tree) for e...
The problem in the question is a good example for two related principles. - Thanks to the substitution method in your try 2, you have found $c=b=1$ will enable the induction step for $T(n)\le cn-b$ to work. However, *if* the base case is $T(1)$, the inequality does not hold. Instead of sticking to proving "$T(...
null
I have a metric space $(V,d)$ described by a tree $T$. And I have $k$ pair of vertices $\{s_i,t_i\}$ ($i \in [k]$) s.t. each of the vertices $s_i$ and $t_i$ are leaves of $T$. There is a car at one of the leaf $s$ of $T$. The car has to deliver a package from $s_i$ to $t_i$ (for each $i$). But at any time the car can ...
I have a metric space $(V,d)$ described by a tree $T$. And I have $k$ pair of vertices $\{s_i,t_i\}$ ($i \in [k]$) s.t. each of the vertices $s_i$ and $t_i$ are leaves of $T$. There is a car at one of the leaf $s$ of $T$. The car has to deliver a package from $s_i$ to $t_i$ (for each $i$). But at any time the car can ...
Suppose there are $m$ elements in a sequence containing $n$ distinct elements, and the distinct elements are stored in an AVL tree. Then, each of the $m$ Lookups will take $O(\log n)$ time. Each of the $n$ inserts will take $O(\log n)$ time, for a total cost of $O(m \log n + n \log n) = O(m \log n)$. However, sin...
The cost of inserting into a height-balanced binary search tree (i.e. an AVL tree) is $O(\log n)$. You would first augment the BST’s data structure so that a height value is stored for each node. For an insert operation, finding the insertion point takes $O(\log n)$ time. Then, rebalancing the tree requires retrac...
The split in a product is between the two outermost pairs of parantheses. For example, in $((a*b)*(c*d))*(e*f)$, the split is between the $d$ and $e$ because the last muplitication that is performed is between the results of the products $abcd$ and $ef$. The split tells you where the last multiplication is performed a...
The split in a product is between the two outermost pairs of parantheses. For example, in $((a*b)*(c*d))*(e*f)$, the split is between the $d$ and $e$ because the last multiplication that is performed is between the results of the products $abcd$ and $ef$. The split tells you where the last multiplication is performed ...
If public randomness is allowed, then the two parties apply a common random permutation on their inputs, and XOR their inputs with a common random string.
$I(X_1,X_2;Y)$ is $I(X;Y)$, where $X = (X_1,X_2)$. For example, suppose that $X_1,Y$ are two independent uniformly random bits, and $X_2 = X_1 \oplus Y$. Then $I(X_1;Y) = 0$ while $I(X_1,X_2;Y) = 1$. In more detail, the joint distribution of $(X_1,X_2,Y)$ is the uniform distribution over the vectors $(0,0,0),(0,1...
If public randomness is allowed, then the two parties apply a common random permutation on their inputs, and XOR their inputs with a common random string. Suppose that the inputs are $x,y$, and that they differ on the index set $I = \{i_1,\ldots,i_k\}$. For each permutation $\pi$ of $1,\ldots,k$, we can find a permu...
I'm trying to understand the implementation of the algoritm [here][1]. Please see GammaLowerRegularized(a, x) function. I understand 1st part of the function for `x <= 1 || x <= a`. The authors use Kummer's confluent hypergeometric function `M(1,a,x)`, because it converges under the specified conditions. But don'...
Algorithm to calculate lower incomplete gamma function
|numerical-algorithms|numerical-analysis|
I'm trying to understand the implementation of the algoritm [here][1]. Please see GammaLowerRegularized(a, x) function. I understand 1st part of the function for `x <= 1 || x <= a`. The authors use Kummer's confluent hypergeometric function `M(1,a,x)`, because it converges under the specified conditions. But don'...
I was learning about decidability when I thought of this question: If P is partially decidable, is ¬P decidable, partially decidable or undecidable? I think it is Undecidable since if ¬P holds then P doesn't hold, and the characteristic function of P is undefined when P doesn't hold so we can't come up with a charac...
If predicate P is partially-decidable, is ¬P decidable, partially decidable or undecidable?
|undecidability|semi-decidability|decidability|
Complete graph with n vertices. Walk from vertex u to vertex v of length k. I don't understand how the number of walks between the two of length k is $n^{k-1}$ I've tried this formula on an example where n =5 and k = 2 and I can't even find 5 walks. Any help understanding this formula and example would be greatl...
Walk from vertex u to vertex v on complete graph, formula for number of walks of length k
|graphs|discrete-mathematics|graph-traversal|
I'm trying to understand the implementation of the algoritm [here][1]. Please see GammaLowerRegularized(a, x) function. I understand 1st part of the function for `x <= 1 || x <= a`. The authors use Kummer's confluent hypergeometric function `M(1,a,x)`, because it converges under the specified conditions. But don'...
I want to construct a context free grammar for this language: \begin{align*} L = \{uc^nb^nv\mid \ u,v \in \{a,b\}^* \text{ and the number of a's and b's in } uv \text{ are equal}\} \end{align*} I know how to contruct a grammar for a language that has words with an equal number of a's and b's: \begin{align*} &...
I need help finding a context free grammar for this language
|formal-languages|context-free|
I want to construct a context-free grammar for this language: \begin{align*} L = \{uc^nb^nv\mid \ u,v \in \{a,b\}^* \text{ and the number of a's and b's in } uv \text{ are equal}\} \end{align*} I know how to contruct a grammar for a language that has words with an equal number of a's and b's: \begin{align*} &...
Find a context-free grammar for uc^nb^nv where the number of a's and b's in uv are equal
I want to construct a context-free grammar for this language: \begin{align*} L = \{uc^nd^nv\mid \ u,v \in \{a,b\}^* \text{ and the number of a's and b's in } uv \text{ are equal}\} \end{align*} I know how to contruct a grammar for a language that has words with an equal number of a's and b's: \begin{align*} &...
Find a context-free grammar for uc^nd^nv where the number of a's and b's in uv are equal
I'm trying to understand the implementation of the algoritm [here][1]. Please see GammaLowerRegularized(a, x) function. I understand 1st part of the function for `x <= 1 || x <= a`. The authors use Kummer's confluent hypergeometric function `M(1,a,x)`, because it converges under the specified conditions. But don'...
I think there may be a mistake in your statement: unless you allow a walk to stay in the same vertex on a step, instead of crossing an edge (but that's not the usual definition of [walk](https://en.wikipedia.org/wiki/Path_(graph_theory)#Walk,_trail,_and_path)). I think you could do a proof by induction on $k$, disti...
I think there may be a mistake in your statement, unless you allow a walk to stay in the same vertex on a step, instead of crossing an edge (but that's not the usual definition of [walk](https://en.wikipedia.org/wiki/Path_(graph_theory)#Walk,_trail,_and_path)). I think you could do a proof by induction on $k$, disti...
Given that #∉Σ and L⊆Σ^* # Σ^*, prove that if L is context-free language then L' = {w2#w1 | w1#w2∈L} is context-free. I'm trying to prove this in this way: 1) because L is context-free then G is context-free grammar for L, then L(G)=L. 2) by showing that the reversed grammar F of G is the same grammar of L and becau...
prove that if L is context-free then L' = {w2#w1 | w1#w2∈L} is context-free
|regular-languages|context-free|computation-models|
A few days ago, my tutor recommend [Stanford cs265][1] to me. I have read some lectures and watched some videos, I think it's really a great course for those who want to study rndomizede algorithm. [1]: https://web.stanford.edu/class/cs265/#classes
Given that $\#\notin \Sigma$ and $L\subseteq \Sigma^*\#\Sigma^*$, prove that if $L$ is context-free language then $L' = \{w_2\#w_1 \mid w_1\#w_2\in L\}$ is context-free. I'm trying to prove this in this way: 1) because $L$ is context-free then $G$ is context-free grammar for $L$, then $L(G)=L$. 2) by showing that th...
I think there may be a mistake in your statement, unless you allow a walk to stay in the same vertex on a step, instead of crossing an edge (but that's not the usual definition of [walk](https://en.wikipedia.org/wiki/Path_(graph_theory)#Walk,_trail,_and_path)), or unless you consider each vertex in a complete graph to ...
I am creating a tool for validating, parsing and interpreting flowchart diagrams on [diagrams.net][1], and it is neccessary to give users an opportunity to define a set of rules for the diagram. So, in the end I want to achieve something like ANTLR for diagrams with the following features: - Some kind of DSL for de...
I have a large list (around 200k) of element pairs `(e.g. A-B, A-C, B-C, ...)`. How can I find the largest subset of elements amongst which none are paired? Example of pairs: ``` A-B A-C A-F B-C C-D E-F F-G ``` Here the largest subset would be of size 4, and one of the subsets with size 4 would be: `{A...
Find the largest subset of unpaired elements
|algorithms|optimization|np-complete|sets|
In static routing where the network parameters dont change, we can use Djikstra's or Bellman-Ford's algorithm to find the shortest path to send data from source to destination.However in dynamic routing how do we do that?
Dynamic routing algorithm
|computer-networks|weighted-graphs|dynamic-graphs|
There is a unique path in the derivation tree that leads from the axiom $S$ to the terminal symbol $\#$. An idea would be to turn this tree upside down along that path. This solution follows the construction for the [closure under cyclic shift for context-free languages][1], as suggested in the book by Hopcroft and ...
Let $G$ be the graph whose edges are the given pairs. Then, the problem is to find a maximum independent set in $G$. There exist algorithms for this, but this problem is NP-hard in general.
This isn't really about "advantages", but appropriateness. Sometimes it's more appropriate to use an array, and sometimes to use a linked list. If it helps, take a look at [this large table][1] of the complexity of various operations of a bunch of data structures from the C++ standard library so you can compare them...
null
Bellman-Ford(used by DVR in RIP) and Dijkstra algorithm (used by OSPF in Link state) is the example of dynamic routing protocol. In dynamic routing routers exchanges the routes (routing database) periodically with neighbors (for DVR) or with whole entire topology(for OSPF) to confirm that "is there any change has made ...
null
null
Consider the following operation on context-free languages. For $L\subseteq \{a,b\}^*$, we have $L_\square = \{ u\square v \mid uv\in L\}$, where $\square$ is a new symbol. Thus $L_\square$ adds a single symbol $\square$ at an arbitrary position in the strings of $L$. That position of $\square$ can be used for the axi...
My lecture notes for complexity says that $ASPACE(f (n)) = DTIME(2^{O(f (n))})$ I can prove the forward direction ($ASPACE(f (n)) \subseteq DTIME(2^{O(f (n))})$) by building a computation tree of the alternating turing machine and rejecting after $>= 2^{f(n)}$ timesteps and then merging nodes of the same configurati...
Showing that $ASPACE(f (n)) = DTIME(2^{O(f (n))})$
|complexity-theory|turing-machines|
null
Let me add to the previous questions that BQP capture the power of quantum computers for decision problems, but there are other algorithmic tasks to consider. It is a reasonable conjecture that equipping a BPP computer with an oracle for BQP complete problems does not enable performing quantum sampling (or even just bo...
I think there may be a mistake in your statement, unless you allow a walk to stay in the same vertex on a step, instead of crossing an edge (but that's not the usual definition of [walk](https://en.wikipedia.org/wiki/Path_(graph_theory)#Walk,_trail,_and_path)), or unless you consider each vertex in a complete graph to ...
I am trying to create a PDA with at most 7 states that accepts the following language L over the alphabet Σ. The tricky part is that multiple push allowed but multiple pop is not allowed. I was able to find the easy solution when multi push/pop is allowed. I am looking for solutions where ***multi push/pop is not allow...
Pushdown Automata that accepts a^2k b^3k, without multiple pop
|pushdown-automata|