instruction
stringlengths
0
29.8k
⌀
|algorithms|distributed-systems|
I am solving a problem where I got an observation that, the vertices of the graph has an outdegree of atmost one, but My questions is using this observation ,Can it be proved that graph has either a cycle or a sink vertex in its components?
A directed graph in which each vertex has out degree atmost one ,then the graph contains either a single sink vertex or a single cycle
|graphs|
**Assumption** :The cake is not 'cut' but 'marked' because cut result in partitions and hence there will be no overlaps. An Interval tree can be used to solve this problem. Interval tree is a self-balancing BST. Each cake piece P(i,S) forms a node with range values i and i+S. **The structure of an Interval tre...
null
The usual many-one reduction involves Turing machines transforming an input, $w$, of some language to an input, $f(w)$, of some other language in polynomial time. (Where $w \in L_1 \iff f(w) \in L_2$). But for $P$-completeness, logspace or NC reductions are often used instead (taken from [wikipedia](https://en.wikip...
Hey I had this question and am stuck on part (b). I don't see how its possible to find a graph with 7 vertices and 15 edges that does **not** have the half-clique problem. If there is a way, could someone share their thought process rather than the answer as I would like to figure it out on my own. Thanks a lot...
Half Clique Property question
|algorithms|graphs|clique|
null
Consider a clique $C$ with vertex-set $V = \{1,2,3,4,5,6,7\}$. $C$ has $\binom{7}{2} = \frac{6 \cdot 7}{2} = 21$ edges. For any $S \subseteq V$ with $|S| \ge \lceil V/2\rceil =4$, either: - $S$ contains at least two vertices in $\{1,2,3\}$; or - $S$ contains at least $2$ vertices in $\{4,5,6\}$. Then you can s...
Consider a clique $C$ with vertex-set $V = \{1,2,3,4,5,6,7\}$. $C$ has $\binom{7}{2} = \frac{6 \cdot 7}{2} = 21$ edges. For any $S \subseteq V$ with $|S| \ge \lceil V/2\rceil =4$, either: - $S$ contains at least two vertices in $\{1,2,3\}$; or - $S$ contains at least $2$ vertices in $\{4,5,6\}$. Then you can s...
Consider a clique $C$ with vertex-set $V = \{1,2,3,4,5,6,7\}$. $C$ has $\binom{7}{2} = \frac{6 \cdot 7}{2} = 21$ edges. For any $S \subseteq V$ with $|S| \ge \lceil V/2\rceil =4$, either: - $S$ contains at least two vertices in $\{1,2,3\}$; or - $S$ contains at least $2$ vertices in $\{4,5,6\}$. From the above...
null
null
Could You please recommend ordered data structures with the complexity of reading/writing/deleting not slower than O(Log2(n)), traversing O(n*Log2(n))? SkipList, Red-Black Tree, what else?
Ordered containers with O(Log2(n)) operations
|time-complexity|data-structures|
I am trying to optimize a building layout in a game, and it seems like the problem could be solved by a computer much quicker than by my own trial and error. However, I only have a cursory understanding of programming (mostly JavaScript), so I'm hoping some software exists which can do most of the work for me, or some ...
The language for the grammar in the question is the set of all words with equal number of $a$'s and $b$'s. I am afraid your intuition is incorrect. Here is an $LL(1)$ grammar for the language. $\qquad S \to AS \mid BS \mid \epsilon$ $\qquad A \to aXb$ $\qquad X \to AX \mid \epsilon$ $\qquad B \to bYa$ ...
The language for the grammar in the question is the set of all words with equal number of $a$'s and $b$'s. I am afraid your intuition is incorrect. Here is an $LL(1)$ grammar for the language. $\qquad S \to AS \mid BS \mid \epsilon$ $\qquad A \to aXb$ $\qquad X \to AX \mid \epsilon$ $\qquad B \to bYa$ ...
Consider the following CFG. $S \rightarrow \epsilon\ |\ aSbS\ |\ bSaS$ Can we prove formally that an equivalent $LL(1)$ grammar does not exist? I feel that intuitively an equivalent $LL(1)$ grammar doesn't exist, but I'm unable to prove this formally.
Is there a LL(1) grammar for the language with equal number of a's and b's?
|formal-languages|context-free|parsers|
The language for the grammar in the question is the set of all words with equal number of $a$'s and $b$'s. I am afraid your intuition is incorrect. Here is an $LL(1)$ grammar for the language. $\qquad S \to AS \mid BS \mid \epsilon$ $\qquad A \to aXb$ $\qquad X \to AX \mid \epsilon$ $\qquad B \to bYa$ ...
Great question! To try to give a slightly shorter answer: Fist, we know that for any formal system, no matter how powerful, there **are** TMs A and B such that A cannot be proven to halt on B. Given your argument, how can this be? To be concrete, we can define "provable" formally as "provable in ZFC" (any other p...
I have a network of 1,000 computers that are sharing processing jobs. There are a few constraints: 1. Each computer has a maximum ratio of jobs it can perform - Can be higher than an equal share 2. Computers are not obligated to do work 3. Not all of these computers will be online at any given time 4. ...
Let $L$ be a regular language over the alphabet $\sum$, prove that the language defined by $\hat{L} = \{uv \in \sum^* | u^Rv \in L \}$ is regular. There is guidance in the exercise that instructs us to define for every $p \in Q$ the language: $L_p = \{uv\in\sum^* | \delta(q_0,u^R) = p \space\space and \space\spac...
Proving a certain language is regular by constructing a DFA
|regular-languages|finite-automata|
null
The usual many-one reduction involves Turing machines transforming an input, $w$, of some language to an input, $f(w)$, of some other language in polynomial time. (Where $w \in L_1 \iff f(w) \in L_2$). But for $P$-completeness, logspace or NC reductions are often used instead (taken from [wikipedia](https://en.wikip...
Why is sorting numbers Omega(nlogn)? I'm thinking of an reduction algorithm where: For all the numbers x_i, we create a point (x_i, 0) on a 2d graph. Fit a line directly to the right starting from the leftmost point. Sorted numbers are the order in which we encounter the points. Would this not be an O(n) ...
Sorting Numbers in O(N)?
|reductions|sorting|
null
null
null
I'm not going to analyse your algorithm; it's very instructive for you to discover if it will work or not. But let's talk about the computational complexity of sorting. Let's assume for a moment that you have $n$ items, all of which are distinct. There are $n!$ possible ways to put these in order. You can think o...
That translation isn’t done by the CPU when it executed the instructions. It is done a lot earlier, when a program called “assembler” translates the assembler instructions into sequences of bits that the CPU can execute. You say “it’s stored in binary”. Yes, it is translated from assembler to binary, and the binary...
null
Let $L$ be a regular language over the alphabet $\sum$, prove that the language defined by $\hat{L} = \{uv \in \sum^* | u^Rv \in L \}$ is regular. There is guidance in the exercise that instructs us to define for every $p \in Q$ the language: $L_p = \{uv\in\sum^* | \delta(q_0,u^R) = p \space\space and \space\spac...
null
You can sort _some_ arrays in O(n). One case is an array of n elements, created by starting with a sorted array of n elements, and modifying O (n / ln n) of those elements. An obvious case is an array that is already sorted, or sorted in reverse order, or the concatenation of two arrays that are each sorted or sorted i...
null
I am using past materials to review for an upcoming assignment and came across this question: Disjoint Subset Sum: Input: A set of integers S and a goal g(in the set of natural numbers) Output: YES if there are at least two disjoint(non-overlapping) subsets of S where the elements of each subset sum to exactly...
Disjoint Subset Sum Reduction (NP-Complete)
|np-complete|np-hard|subset-sum|
Let $f$ be a continuous real function on $[-1,1]$. The function is accessible via *queries*: for any $x$, the value of $f(x)$ can be computed in constant time. If $f(-1)<0$ and $f(1)>0$, then by the intermediate value theorem, $f$ has a *zero* --- an $x \in [-1,1]$ for which $f(x)=0$. Suppose we want to find a zero a...
[This paper][1] studies a similar problem: finding an approximate fixed-point of a two-dimensional function from the unit square to itself, which is accessible via value queries. The authors prove that computing a fixed point with $p$ decimal digits requires $\Omega(2^p)$ queries. Equivalently, computing a square of si...
I'm studying finite state machines and trying to make this table but i don't know where to start. Isn't it necessary to know what happens when for example both inputs A and B from state s1 are active? The exercise in question doesn't say more, it just says to not consider the outputs, encode the states and inputs in bi...
Truth table of the next state function of a Moore machine
|finite-sets|
null
null
You are almost there. First of all it is useless to add $0$, even if it were allowed by the problem statement. Second, if the subset-sum instance is trivially a yes-instance because its set of integers already contains the target value (notice that you can detect this in polynomial time) then you can return any fixed y...
You are almost there. First of all it is useless to add $0$, even if it were allowed by the problem statement. Second, if the subset-sum instance is trivially a yes-instance because its set of integers already contains the target value (notice that you can detect this in polynomial time) then you can return any fixed y...
You are almost there. First of all it is useless to add $0$, even if it were allowed by the problem statement. Second, if the subset-sum instance is trivially a yes-instance because its set of integers already contains the target value (notice that you can detect this in polynomial time) then you can return any fixed y...
In the following discussion, we use the term *old programming language* to refer to programming languages which had their first release prior to the year 1990. In *old programming languages*, there was a strong distinction between: > 1. run-time functions. > 2. compile-time macros. In a running example,...
What name is used in the literature for an interpreter or compiler which compiles and executes all function calls which have constant literal inputs?
|programming-languages|language-design|
I'm not going to analyse your algorithm; it's very instructive for you to discover if it will work or not. But let's talk about the computational complexity of sorting. Let's assume for a moment that you have $n$ items, all of which are distinct. There are $n!$ possible ways to put these in order. You can think o...
This is known as [partial evaluation](https://en.wikipedia.org/wiki/Partial_evaluation). See also [constant propagation](https://en.wikipedia.org/wiki/Constant_folding) and [compile-time function evaluation](https://en.wikipedia.org/wiki/Compile-time_function_execution).
Here's what Wiki says: [![wiki screenshot][1]][1] And here's what Mike Sipser says in his Introduction to Theory of Computation: [![enter image description here][2]][2] The problem arises when you try to read the two definitions - Mike Sipser seems to be suggesting that for a grammar to be in Chomsky's normal form,...
Mike Sipser and Wikipedia seem to disagree on Chomsky's normal form
|formal-languages|computability|context-free|formal-grammars|pushdown-automata|
Sipser doesn't require that both of those forms be used. It just requires that every rule fit one of those two patterns.
null
You are thinking in terms of a putative geometric computer, that implements an implicit order axiom, and is operated by an observer. What you are missing is that the observer has a synoptic view on that data, with an apparent $O(1)$ complexity, and is similar to parallel computing. This is not how a computer works.
You are thinking in terms of a putative geometric computer, that implements an implicit order axiom, and is operated by an observer. What you are missing is that the observer has a *synoptic* view on that data, with an apparent $O(1)$ complexity, and is similar to parallel computing. This is not how a sequential comput...
You are thinking in terms of a putative geometric computer, that implements an implicit order axiom, and is operated by an observer. What you are missing is that the observer has a *synoptic* view on that data, with an apparent $O(1)$ complexity, and is similar to parallel computing. This is not how a sequential comput...
You are thinking in terms of a putative geometric computer, that implements an implicit order axiom, and is operated by an observer. What you are missing is that the observer has a *synoptic* view on that data, with an apparent $O(1)$ complexity, and is similar to parallel computing. This is not how a sequential comput...
Sipser clearly implied an *or* between those two rules. The two definitions say the same thing. Meanwhile, in formal language theory, it is quite common for two textbooks or article to *not* say the say thing when defining terms. For instance, some definitions of context-free grammars do not permit $\epsilon$ rules...
null
The computational model is implicit in the question: the basic operations is the $=k \,?$ query, and taken as the unit. Whatever any actual implementation. Just like when you rate a sorting algorithm based on the number of comparisons.
The computational model is implicit in the question: the basic operations is the $=k \,?$ query, and taken as the unit. Whatever any actual implementation. In fact, you don't evaluate a time-complexity, but a query-complexity. Just like when you rate a sorting algorithm based solely on the number of comparisons.
A hash-table seems a good option. As the keys are long, collisions should be minimized. So don't fear to be generous on the number of buckets (low fill factor). Unless your strings have long prefixes in common, a sequential search among the colliding strings should not be very costly (early termination in case of st...
A hash-table seems a good option. As the keys are long, collisions should be minimized. So don't fear to be generous on the number of buckets (low fill factor). Unless your strings have long prefixes in common, a sequential search among the colliding strings should not be very costly (early termination in case of mi...
null
null
A hash-table seems a good option. As the keys are long, collisions should be minimized. So don't fear to be generous on the number of buckets (low fill factor). Unless your strings have long prefixes in common, a sequential search among the colliding strings should not be very costly (early termination in case of mi...
Sipser clearly implies an *or* between those two rules. The two definitions say the same thing. Meanwhile, in formal language theory, it is quite common for two textbooks or article to *not* say the same thing when defining terms. For instance, some definitions of context-free grammars do not permit $\epsilon$ rule...
The computational model is implicit in the question: the basic operation is the $=k \,?$ query, and taken as the unit. Whatever any actual implementation. In fact, you don't evaluate a time-complexity, but a query-complexity. Just like when you rate a sorting algorithm based solely on the number of comparisons.
I'm inclined to disagree with McBride here, for the simple reason that while you can express program semantics totally via coinduction, it is not enough to solve the halting problem for the object language (because you would need to run the coinductive trace to exhaustion, which of course may be infinite). I think h...
My lecture notes for gomory-hu trees says that it's easy to see that every GHT of the utility graph $K_{3,3}$ is a star with 5 edges. Is there any easy way to see this without manually computing every gomory-hu tree of the graph? Could I make use of the symmetry of the graph?
I am trying to optimize a building layout in a game, and it seems like the problem could be solved by a computer much quicker than by my own trial and error. However, I only have a cursory understanding of programming (mostly JavaScript), so I'm hoping some software exists which can do most of the work for me, or some ...
Hint. $$ T\left(2^{\log_2 n}\right) = T\left(2^{\frac 12\log_2 n}\right)+5n $$ or recasting $$ R(z) = R\left(\frac z2\right)+5\cdot 2^z $$ and recasting again $$ C(m) = C(m-1) + 5\cdot 2^{2^m} $$ and after solving, backwards...
Hint. Making $n = a^m$ we have $$ T(a^m) = T(a^{m+1})+a^m $$ or recasting $$ R(m+1) = R(m) - a^m $$ etc.
This is a simple variation on precedence parsing for which I haven't been able to prove the existence of an efficient algorithm. Is this a known problem? The setup is as follows: we are given $n$ operator nodes $x\ast_1 x\ast_2\dots\ast_n x$ connecting $n+1$ leaves (whose identity is not important, here denoted by $...
Constrained precedence parsing
|algorithms|complexity-theory|dynamic-programming|parsers|
To resolve $$T(n)=T(\tilde{a}n)+n$$ you can apply the Master Theorem(https://en.wikipedia.org/wiki/Master_theorem_(analysis_of_algorithms)): the recurrence: \begin{equation} T(n) = \begin{cases} a T(n / b) + f(n) & n > 1 \\ T_1 & n = 1 ...
To resolve $$T(n)=T(\tilde{a}n)+n$$ you can apply the Master Theorem(https://en.wikipedia.org/wiki/Master_theorem_(analysis_of_algorithms)): the recurrence: \begin{equation} T(n) = \begin{cases} a T(n / b) + f(n) & n > 1 \\ T_1 & n = 1 ...
To resolve $$T(n)=T(\tilde{a}n)+n$$ you can apply the Master Theorem(https://en.wikipedia.org/wiki/Master_theorem_(analysis_of_algorithms)): the recurrence: \begin{equation} T(n) = \begin{cases} a T(n / b) + f(n) & n > 1 \\ T_1 & n = 1 ...
To resolve $$T(n)=T(\tilde{a}n)+n$$ you can apply the Master Theorem(https://en.wikipedia.org/wiki/Master_theorem_(analysis_of_algorithms)): the recurrence: \begin{equation} T(n) = \begin{cases} a T(n / b) + f(n) & n > 1 \\ T_1 & n = 1 ...
To resolve $$T(n)=T(\tilde{a}n)+n$$ you can apply the Master Theorem(https://en.wikipedia.org/wiki/Master_theorem_(analysis_of_algorithms)): the recurrence: \begin{equation} T(n) = \begin{cases} a T(n / b) + f(n) & n > 1 \\ T_1 & n = 1 ...
To resolve $$T(n)=T(\tilde{a}n)+n$$ you can apply the Master Theorem(https://en.wikipedia.org/wiki/Master_theorem_(analysis_of_algorithms)): the recurrence: \begin{equation} T(n) = \begin{cases} a T(n / b) + f(n) & n > 1 \\ T_1 & n = 1 ...
To resolve $$T(n)=T(\tilde{a}n)+n$$ you can apply the Master Theorem(https://en.wikipedia.org/wiki/Master_theorem_(analysis_of_algorithms)): the recurrence: \begin{equation} T(n) = \begin{cases} a T(n / b) + f(n) & n > 1 \\ T_1 & n = 1 ...
When a simulating halt decider correctly simulates N steps of its input it derives the exact same N steps that a pure UTM would derive because it is itself a UTM with extra features. Because of this we can know that the first N steps of ⟨Ĥ⟩ simulated by embedded_H are the actual behavior that ⟨Ĥ⟩ presents to embedde...