instruction stringlengths 0 29.8k ⌀ |
|---|
|algorithms|graphs| |
I have realised that this does follow simply from some well-known results. I don't know how to vote to close. Janoma was correct, this is probably not a research level question.
I agree with the below comment, so here is the solution:
DCFL are known to be closed under quotient with regular languages, but the quot... |
For a formal language $L \subseteq \Sigma^{*}$ I define the set Pref(L) to be:
$\text{pref}(L) = \{\alpha \in \Sigma^{*} : \exists \beta \in \Sigma^{*} \text{ such that } \alpha \beta \in L\}$
ie. the set of all (not necessarily proper) prefixes of words in $L$. I know that if $L$ is context-free then pref(L) is ... |
Closure of Deterministic context-free languages under prefix |
|reference-request|formal-languages|computability| |
According the concept of context free language very context can be represented in the form of "CHOMSKY NORMAL FORM".so if in the rule we made change like
if
A->BC
change it to the
A->BC/B
now this type of replacement will generate the context free language of prefix language of the given |
The only element of depth-first search you tweak is the order in which children are investigated. The normal version proceeds in arbitrary order, i.e. in the order the children are stored.
The only feasible alternative (towards shortest paths) I can come up with is a greedy approach, that is looking at children in o... |
|formal-languages|context-free|closure-properties| |
null |
This is undecidable. It is theorem 11 in [Properties of deterministic top down grammars by Rosenkrantz and Stearns][1]. Theorem 12 in the same paper however states that the problem becomes decidable if the grammar is known to be $LR(k')$ for some (possibly different) $k'$.
[1]: http://dl.acm.org/citation.cfm?id=... |
First note that $T = c^*$ (using regular expression syntax). We can therefore rewrite your grammar to:
S --> c*a | b | Sc
Rewriting even further, we can say that $S = (c^*a | b)c^*$, so $S$ is regular. It is not hard to come up with a grammar for this language:
S --> T a T | b T
T --> c T | λ
M... |
It appears you have misunderstood your professor. "If the leftmost nonterminal is S and the input is 'b', the production is both Sa and b." means that both Sa and b are correct answers if the leftmost nonterminal is S and the input is 'b'. This means that the parser does not know which production to go to and is stuck.... |
I'm going to attempt to answer your question, risking the possibility I have misunderstood you.
If we restrict context-free grammars to only a single nonterminal per rule, then the resulting class of grammars are exactly the linear grammars (by definition). However, if we allow more than one nonterminal per rule, th... |
This is answered on <a href="http://math.stackexchange.com/questions/114334/product-of-adjacency-matrices"> Math.SE</a>; see also <a href="http://mathworld.wolfram.com/GraphPower.html"> MathWorld </a>.
Briefly,the $(i,j)$-th entry in $A^n$ gives the number of directed walks from vertex $i$ to $j$ that have length $... |
As Xodarap pointed out, if you require your algorithm with the “random oracle” to _always_ output the correct answer, then the random oracle is useless. The problem becomes more interesting if we allow small probability of error (where the probability is with respect to the random instance chosen by the oracle).
In... |
As Xodarap pointed out, if you require your algorithm with the “random oracle” to _always_ output the correct answer, then the random oracle is useless. The problem becomes more interesting if we allow small probability of error (where the probability is with respect to the random instance chosen by the oracle).
In... |
Shannon's entropy [plog(1/p)] for an image is a probabilistic method for comparing two pixels or a group of pixels.Suppose an image with a matrix of 3x3 has pixel intensity values
1 1 2
2 3 3
4 4 5
and another image with 3x3 matrix has group of pixels having intensity values
5 5 6
6 7 7
8 8 9
Then shannon's... |
Shannon's entropy for an image |
|pattern-recognition|image-processing|computer-vision| |
As Xodarap pointed out, if you require your algorithm with the “random oracle” to _always_ output the correct answer, then the random oracle is useless. The problem becomes more interesting if we allow small probability of error (where the probability is with respect to the random instance chosen by the oracle).
In... |
null |
Shannon's entropy [plog(1/p)] for an image is a probabilistic method for comparing two pixels or a group of pixels.Suppose an image with a matrix of 3x3 has pixel intensity values
1 1 2
2 3 3
4 4 5
and another image with 3x3 matrix has group of pixels having intensity values
5 5 6
6 7 7... |
null |
Shannon's entropy [plog(1/p)] for an image is a probabilistic method for comparing two pixels or a group of pixels.Suppose an image with a matrix of 3x3 has pixel intensity values
1 1 2
2 3 3
4 4 5
and another image with 3x3 matrix has group of pixels having intensity values
5 5 6
6 7 7... |
Given a graph $G = (V,E,w)$, we define $G'=(V,E,w')$ with $w'(e) = aw(e) + 1$ where $a = |E| + \varepsilon$ for some $\varepsilon \geq 0$ as proposed in the comments of the question.
> **Lemma**
> Let $P$ a path in $G$ with cost $C$, i.e. $w(P)=C$. Then, $P$ has cost $aC + |P|$ in $G'$, i.e. $w'(P) = aC + |P|$.
... |
DCFL are known to be closed under quotient with regular languages, but the quotient of $L$ with $\Sigma^{*}$ is precisely $\text{pref}(L)$ so yes, if $L$ is a DCFL then $\text{pref}(L)$ is a DCFL. |
Shannon's entropy works as a hashing or fingerprinting function here; they are not [injective](https://en.wikipedia.org/wiki/Injective_function) which means we have to be careful not to interpret too much into relations of values.
If $H(I_1) \neq H(I_2)$, then images $I_1$ and $I_2$ are certainly not the same.
If... |
I think this an awesome idea. But you don't be able to use it for image matching anymore than you can hope that one image of "white noise" will match another. But it's a great idea for finding similar *categories* of images. |
null |
I think this an awesome idea. But you won't be able to use it for image matching anymore than you can hope that one image of "white noise" will match another. But it's a great idea for finding similar *categories* of images. |
null |
Dynamic programming with LARGE number of subproblemsSo I'm trying this problem from Interview Street:
Grid Walking (Score 50 points)
You are situated in an N dimensional grid at position(x_1,x2,...,x_N). The dimensions of the grid are (D_1,D_2,...D_N). In one step, you can walk one step ahead or behind in ... |
Dynamic programming with LARGE number of subproblems |
|dynamic-programming| |
|algorithms|dynamic-programming| |
I need to find the easiest cost path between 2 vertices of a graph. Easiest: meaning the path with the lowest max weight edge.
![enter image description here][1]
In the above graph, the easiest path from 1 to 2 is:
1 > 3 > 4 > 2
Because the max edge weight is only 2, but if I take the shortest path, 1... |
"Easiest" Path in Graph between 2 given vertices |
|algorithms|graphs| |
You're right; it's essentially a MST problem. First build the minimum spanning tree, then use breadth-first or depth-first search to find the unique path in the tree between the two vertices. |
Dynamic programming with large number of subproblems. So I'm trying to solve this problem from Interview Street:
> **Grid Walking** (Score 50 points)
> You are situated in an $N$-dimensional grid at position $(x_1,x2,\dots,x_N)$. The dimensions of the grid are $(D_1,D_2,\dots,D_N$). In one step, you can walk one ... |
Dynamic programming with large number of subproblems |
|algorithms|efficiency|dynamic-programming| |
Dynamic programming with large number of subproblems. So I'm trying to solve this problem from Interview Street:
> **Grid Walking** (Score 50 points)
> You are situated in an $N$-dimensional grid at position $(x_1,x_2,\dots,x_N)$. The dimensions of the grid are $(D_1,D_2,\dots,D_N$). In one step, you can walk one... |
You are missing one thing, namely that the optimal algorithm and worst instance are not simply functions of the instance size. Also, I am not sure that minimising/maximising algorithm and instance independently of each other is doing the right thing.
The complexity of a problem is the *complexity of an optimal algor... |
Let's extract a formula for $\newcommand{\now}{\operatorname{now}}\now(s,x_1,\dots,x_n)$ from your code (for an inner cell, that is ignoring border cases):
$\qquad \begin{align}
\now(s,x_1,\dots,x_n) =
\phantom{+} &\sum_{i=0}^n \now(s-1,x_1,\dots,x_{i-1},x_i + 1, x_{i+1},\dots,x_n) \\
+ &\sum_{i=0}^n\now(s-... |
I need to find the easiest cost path between two vertices of a graph. Easiest here means the path with the smallest maximum-weigth edge.
![enter image description here][1]
In the above graph, the easiest path from 1 to 2 is:
1 > 3 > 4 > 2
Because the maximum edge weight is only 2. On the other hand, t... |
|algorithms|graphs|shortest-path| |
Finding paths with smallest maximum edge weight |
I try to solve this question.
Prove or disprove the following statements:
$1.T\left( n \right) = 2T\left( {\frac{n}{2}} \right) + f\left( n \right),f\left( n \right) = \theta \left( {{n^2}} \right)then{\rm{ }}T\left( n \right) = \theta \left( {f\left( n \right)} \right)for{\rm{ }}all{\rm{ n = }}{{\rm{2}}^k}$
$... |
The question about the constrain of master theorem 3 |
|complexity-theory| |
Prove or disprove the following statements:
$1.T\left( n \right) = 2T\left( {\frac{n}{2}} \right) + f\left( n \right),f\left( n \right) = \theta \left( {{n^2}} \right) $ then $ {\rm{ }}T\left( n \right) = \theta \left( {f\left( n \right)} \right) $ for all $ {\rm{ n = }}{{\rm{2}}^k}$
$2.T\left( n \right) = 2T\lef... |
Problems showing the constraint of master theorem case three holds |
|complexity-theory|master-theorem| |
null |
In most PL textbooks (even in language specifications) statments like **if, while, for, break** are categorized as *flow of control* statements. <br/>
However, it is not consistent; i.e. sometimes the same text uses *control-flow statement* (note the dash), or *control flow statment*, I read sentences that says *contr... |
Flow of control? or Control of flow? |
|programming-languages| |
Let's extract a formula for $\newcommand{\now}{\operatorname{now}}\now(s,x_1,\dots,x_n)$ from your code (for an inner cell, that is ignoring border cases):
$\qquad \begin{align}
\now(s,x_1,\dots,x_n) =
\phantom{+} &\sum_{i=0}^n \now(s-1,x_1,\dots,x_{i-1},x_i + 1, x_{i+1},\dots,x_n) \\
+ &\sum_{i=0}^n\now(s-... |
Prove or disprove the following statements:
1. $T\left( n \right) = 2T\left( {\frac{n}{2}} \right) + f\left( n \right),f\left( n \right) = \theta \left( {{n^2}} \right) $ then $ {\rm{ }}T\left( n \right) = \theta \left( {f\left( n \right)} \right) $ for all $ {\rm{ n = }}{{\rm{2}}^k}$
2. $T\left( n \right) = 2T... |
|asymptotics|recurrence-relation|master-theorem| |
> **Possible Duplicate:**
> [Solving $T(n)= 3T(\frac{n}{4}) + n\cdot \lg(n)$ using Master Method](http://cs.stackexchange.com/questions/3504/solving-tn-3t-fracn4-n-cdot-lgn-using-master-method)
<!-- End of automatically inserted text -->
Prove or disprove the following statements:
1. $T\left( n \right) = 2T\l... |
{"OriginalQuestionIds":[3504],"Voters":[{"Id":98,"DisplayName":"Raphael"}]} |
|terminology|programming-languages| |
I am not sure what you mean by "language-agnostic definition of this concept in CS"; such notions are rarely (if ever) rigorously defined. Someone uses them first, others pick them up and eventually they become standard vocabulary. That's ho we get conflicting notation all the time.
In this case, I don't see an eith... |
null |
The different dimensions are **independent**. What you can do is compute, for each dimension *j*, how many different walks there are in just that dimension which take $t$ steps. Let us call that number $W(j,t)$. From your question, you already know how to compute these numbers with dynamic programming.
Now, it's e... |
If the graph happens to be a DAG, then you can found the number of paths from any vertex to any other vertex using linear algebra. Let $A$ be the adjacency matrix of the graph. Compute
$$ B = \sum_{k=0}^{n-1} A^k. $$
Then $B_{ij}$ is the number of paths (of length at most $n-1$) between vertex $i$ and vertex $j$. Thi... |
As Tsuyoshi Ito notes, the first problem can be solved using network flow. This was described in detail in [cstheory][1].
[1]: http://cstheory.stackexchange.com/questions/9626/viapath-as-a-maximum-flow-problem |
null |
*What follows is Tsuyoshi Ito's answer.* In the case of DAG, all paths can be enumerated in polynomial space and therefore the problem cannot be EXPTIME-complete unless PSPACE=EXPTIME. The natural decision version (given a DAG G, its vertices s and t, and numbers x and y, decide whether there is a path from s to t whos... |
null |
*What follows is Tsuyoshi Ito's answer.* If you know Kruskal’s algorithm for the minimum spanning tree, it is an easy exercise to show that the output of Kruskal’s algorithm is a minimum bottleneck spanning tree. (I think that it is easier than showing that the output of Kruskal’s algorithm is a minimum spanning tree.) |
null |
*What follows is Tsuyoshi Ito's answer.* As rizwanhudda said, this problem is a special case of the graph isomorphism problem and therefore it is not known to be NP-complete. We cannot say “this problem can’t be NP-complete” because of that, because the graph isomorphism problem might be NP-complete. However, many comp... |
null |
**breadth-first search (BFS):** is a strategy for searching in a graph when search is limited to essentially two operations: (a) visit and inspect a node of a graph; (b) gain access to visit the nodes that neighbor the currently visited node. The BFS begins at a root node and inspects all the neighboring nodes. Then fo... |
null |
**Random graphs with small world topology**
In graphs with *small world topology*, nodes are highly clustered yet the path length between them is small. A topology like this can make search problems very difficult, since local decisions quickly propagate globally. In other words, shortcuts can mislead heuristics. Fu... |
*What follows is taken from [Tsuyoshi Ito](http://cs.stackexchange.com/users/568/tsuyoshi-ito)'s comment.*
In the case of DAG, all paths can be enumerated in polynomial space and therefore the problem cannot be EXPTIME-complete unless PSPACE=EXPTIME. The natural decision version (given a DAG G, its vertices s and t... |
*What follows is taken from [Tsuyoshi Ito](http://cs.stackexchange.com/users/568/tsuyoshi-ito)'s comment.*
If you know Kruskal’s algorithm for the minimum spanning tree, it is an easy exercise to show that the output of Kruskal’s algorithm is a minimum bottleneck spanning tree. (I think that it is easier than showi... |
*What follows is taken from [Tsuyoshi Ito](http://cs.stackexchange.com/users/568/tsuyoshi-ito)'s comment.*
As [rizwanhudda said](http://cs.stackexchange.com/questions/2383/has-anyone-found-polynomial-algorithm-on-hamiltonian-cycle-isomorphism/4954#comment6444_2383), this problem is a special case of the graph isomo... |
**Can I always increase the complexity of a problem via polynomial reduction?** (in which case '*reduction*' is really a misnomer) For example, if I have a classic P problem (say, finding the smallest element in an array, by iterating through and making comparisons with the smallest value found thus far), what would be... |
Clarifications on polynomial reducibility for problems in P and NP-complete |
|complexity-theory|time-complexity| |
**Can I always increase the complexity of a problem via polynomial reduction?** (in which case '*reduction*' is really a misnomer) For example, if I have a classic P problem (say, finding the smallest element in an array, by iterating through and making comparisons with the smallest value found thus far), what would be... |
As pointed out by @Vor the point of polynomial-time reductions is to show that if have a reduction from A to B and an algorithm to solve a problem B then you can use it to efficiently (i.e. in polynomial time) solve the problem A. Note that efficiently does not mean optimally, when you reductions, your solutions will n... |
Im trying to figure out how to describe fifty-six strings to test if a three state FA over the alphabet {a b} has a finite language.
The number fifty-six comes from a theorem that states if a machine has N states and an alphabet has m letters, then in total there are m^N + m^(N + 1) + m^(N + 2) +...+ m^(2N-1) differ... |
Describing Strings |
|automata|finite-automata| |
*Breadth*-first-search is the algorithm that will find shortest paths in an unweighted graph.
There is a simple tweak to get from DFS to an algorithm that will find the shortest paths on an unweighted graph. Essentially, you replace the stack used by DFS with a queue. However, the resulting algorithm is no longer ca... |
The strings are just all strings of lengths $N$ to $2N-1$. In your case:
> 000 001 010 011 100 101 110 111
> 0000 0001 0010 0011 0100 0101 0110 0111
> 1000 1001 1010 1011 1100 1101 1110 1111
> 00000 00001 00010 00011 00100 00101 00110 00111
> 01000 01001 01010 01011 01100 01101 01110 01111
> 10000 100... |
Im trying to figure out how to describe fifty-six strings to test if a three state FA over the alphabet $\{a,b\}$ has a finite language.
The number fifty-six comes from a theorem that states if a machine has $N$ states and an alphabet has $m$ letters, then in total there are $m^N + m^{N + 1} + m^{N + 2} +\ldots+ m^{... |
As suggested by Kaveh, perhaps this is a reduction that can prove that the class of graphs with an Hamiltonian cycle is GI-complete.
Given two graphs $G_1 = (V_1,E_1)$ and $G_2 = (V_2,E_2)$, $|V_1| = |V_2|=n$, expand $G_1$ with a complete graph $K_{2n}$ labeling its nodes in pairs $(a_i, b_i)$; then for each vertex ... |
We know that $st\text{-}non\text{-}connectivity$ is in [$\mathsf{NL}$][1] by [Immerman–Szelepcsényi theorem][2] theorem and since $st\text{-}connectivity$ is $\mathsf{NL\text{-}hard}$ therefore $st\text{-}non\text{-}connectivity$ is many-one log-space reducible to $st\text{-}connectivity$. But is there a direct/combina... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.