instruction stringlengths 0 29.8k ⌀ |
|---|
I've come across many definitions of recursive and recursively enumerable languages. But I couldn't quite understand what they are .
Can some one please tell me what they are in simple words?
Thanks in advance. |
Recursive and recursively enumerable language definition for a layman |
|formal-languages|turing-machines| |
null |
I have read a few algorithms for $LR(k)$ parser, in which there is a frequent mention of selecting a handle from the grammar given.
For example, one document said - *"the essence of LR parsing is identifying the handle on top of stack"*
Please help me understand, what are handles in parsing? |
What are handles in parsing? |
|parsers| |
null |
|compilers|parsers| |
Let's consider the following grammar:
> 1: $S \to A b$
> 2: $S \to B b$
> 3: $A \to a a$
> 4: $B \to a a a$
Obviously, this language is totally uninteresting: the only words in it are $aab$ and $aaab$. However, the grammar is not $LL(1)$ or $LL(2)$ (not sure if you know what that is, if you don't, then... |
null |
A problem is recursive or *decidable* if a machine can compute the answer.
A problem is recursively enumerable or *semidecidable* if a machine can be convinced that the answer is positive. |
null |
null |
**Yes**, your algorithm is correct. The maximum number of edges that a graph can have without forming a cycle is when it is a tree. Lesser number of edges is only when the graph is disconnected. We will assume that the graph is connected, without loss of generality. In such a case, there would be $|V| - 1$ edges in the... |
The problem is
$$\max f(\mathbf{x}) \text{ subject to } \mathbf{Ax} = \mathbf{b}$$
where $f(\mathbf{x}) = \sum_{i=1}^N\sqrt{1+\frac{x_i^4}{(\sum_{i=1}^{N}x_i^2)^2}}$, <br/>
$\mathbf{x} = [x_1,x_2,...,x_N]^T \in \mathbb{R}^{N\times 1}$, and <br/>
$\mathbf{A} \in \mathbb{R}^{M\times N} $ <br/>
We can see that ... |
Maximizing a convex function with a linear constraint |
|linear-programming| |
null |
null |
I recieved the following assignemnt:
EXACT-TRIPLE(<%> | % is a Boolean formula that has exactly 3 satisfying assignments)
I need to decide an whether this problem belongs in NP or not.
I assume it's not. How do I prove that ?
|
Prove that a problem is not in NP |
|complexity-theory|np-complete|satisfiability|np| |
The problem is coNP-hard, and so not likely to be in NP. Indeed, given a formula $\phi$, you can construct a formula $\phi'$ such that if $\phi$ has $x$ satisfying assignments then $\phi'$ has $x+3$. This gives a reduction from the coNP-complete problem UN-SAT to EXACT-TRIPLE. |
|optimization|linear-programming| |
null |
For each vertex $i$, note its $(x_i,y_i)$ location and the distance $d_i$ from the source.
Building the [Voronoi diagram][1] or the [Delaunay triangulation][2] of the pointset can be useful (this would not use $d_i$ data).
If you want something simpler and self-contained, then for each point find its closest neighb... |
I have a question about the stable marriage algorithm, for what I know it can only be used when I have arrays with the same number of elements for building the preference and the ranking matrices.
For example if we have 10 students that should be assigned to 10 dorms, then I can build the preference and ranking matr... |
The stable marriage algorithm with asymmetric arrays |
Trivially decidable problem is one in which the problem is a known property of the language/grammar. So **intersection of two regular languages is regular should be trivially decidable**? But it is given as not trivially decidable.
|
Is the intersection of two regular languages regular? |
I try to provide a strict and mathematical rigorous proof to the following problem in Distributed Algorithms.
Prove or make a contradiction: if to vertices $a$ and $b$ on the network $G$ are located on the distance $k$ from each other, and there are $k^2$ different paths on different edges, so it is possible to tra... |
Proof of message complexity on the network |
|proof-techniques|distributed-systems| |
I received the following assignment:
$\text{EXACT-TRIPLE} = \{ \phi \mid \phi \text{ is a boolean formula that has exactly 3 satisfying assignments} \}$.
I need to decide whether this problem belongs to NP or not. I assume it does not. How do I prove that?
|
Prove that $\text{EXACT-TRIPLE}$ is not in NP |
null |
The best algorithm depends on whether $d[v]$ is reliable or not. If it is reliable then you can find the shortest paths graph like this:
For each vertex v in G:
for each edge e leading to v:
if weight[e] + d[origin of e] == d[v]:
include e in the output graph
If $d[v]$ i... |
As has been pointed out, there are well known shortest path algorithms. But your problem already has most of the information. Specifically, you already know the shortest path distances $d[v]$ from $s$ for each node $v$. In such a case, you can use a much better algorithm.
By a "shortest paths graph", I think you mea... |
null |
The best algorithm depends on whether $d[v]$ is reliable or not. If it is reliable then you can find the shortest paths graph like this:
for each edge e in G:
if weight[e] + d[origin of e] == d[end of e]:
include e in the output graph
If $d[v]$ is not reliable then [Dijkstra's algorithm]... |
The best algorithm depends on whether $d[v]$ is reliable or not. If it is reliable then you can find the shortest paths graph like this:
for each edge e in G:
if weight[e] + d[origin of e] == d[end of e]:
include e in the output graph
If $d[v]$ is not reliable then [Dijkstra's algorithm]... |
The best algorithm depends on whether $d[v]$ is reliable or not. If it is reliable then you can find the shortest paths graph like this:
for each edge e in G:
if weight[e] + d[origin of e] == d[end of e]:
include e in the output graph
If $d[v]$ is not reliable then [Dijkstra's algorithm]... |
Consider a sequence of $n$ flips of an unbiased coin. Let $H_i$ denote the absolute value of the excess of the number of heads over tails seen in the first $i$ flips. Define $H=$max$_i H_i$. Show that $E[H_i]=\theta ( \sqrt{i} )$ and $E[H]=\theta( \sqrt{n} )$.
This problem appears in the first chapter of `Randomize... |
Discrepancy between heads and tails |
|randomized-algorithms| |
|probability-theory|randomized-algorithms| |
null |
Your coin flips form a one-dimensional random walk $X_0,X_1,\ldots$ starting at $X_0 = 0$, with $X_{i+1} = X_i \pm 1$, each of the options with probability $1/2$. Now $H_i = |X_i|$ and so $H_i^2 = X_i^2$. It is easy to calculate $E[X_i^2] = i$ (this is just the variance), and so $E[H_i] \leq \sqrt{E[H_i^2]} = \sqrt{i}$... |
I am interested in the stateless k-armed bandit problem, where an agent repeatedly chooses one of k independent arms, each with a different distribution of rewards, and tries to maximize its total reward.
I read many papers about this subject, but I am still confused, as there are two types of solutions:
A. It ha... |
k-armed bandit - index policies vs. Q-learning |
|machine-learning| |
I try to solve an exercise in **Distributed Algorithm** described as follow.
Let's define a *label assignment problem* as follow. There is a anonymous network (vertices don't have unique ID's , nodes don't have any clue about $n$ - number of vertices nor about network topology ). The labels assigned to vertices must... |
Label Assignment Problem |
|algorithms|time-complexity|distributed-systems| |
null |
If We have an algorithm that it's complexity is theta(m + n^2) and we know that 0 < m < n^2. it's complexity become theta(n^2). but if We had an algorithm that it's complexity was theta(mlogn) and 0 < m < n^2 could we conclude that it's complexity is theta((n^2)logn)? |
Computing time complexity |
|time-complexity| |
null |
Consider a sequence of $n$ flips of an unbiased coin. Let $H_i$ denote the absolute value of the excess of the number of heads over tails seen in the first $i$ flips. Define $H=\text{max}_i H_i$. Show that $E[H_i]=\Theta ( \sqrt{i} )$ and $E[H]=\Theta( \sqrt{n} )$.
This problem appears in the first chapter of `Rand... |
null |
If we have an algorithm such that its complexity is $\Theta(m + n^2)$ and we know that $0 < m < n^2$, then its complexity becomes $\Theta(n^2)$. But if we had an algorithm such that its complexity was $\Theta(m\log n)$ and $0 < m < n^2$, could we conclude that its complexity is $\Theta(n^2\log n)$? |
|time-complexity|landau-notation| |
null |
The problem is interesting: especially as we dont have a limit on the ID's. I will only answer your following question:
Does the usage of randomized leader election is eligible in the case of graph as described above?
I dont suggest using leader election. Its lower bound does not meet your requirement (it is stil... |
I dont know the solution of your problem: especially as we dont have a limit on the ID's. My "guessing" is that you cannot solve this problem with complexities you listed.
I will only answer your following question:
Does the usage of randomized leader election is eligible in the case of graph as described above?... |
null |
First, consider this simple problem --- design a data structure of *comparable* elements that behaves just like a stack (in particular, push(), pop() and top() take constant time), but can also return its min value in $O(1)$ time, without removing it from the stack. This is easy by maintaining a second stack of min val... |
If $m=\Theta(n^2)$, then indeed $\Theta(m\log n)=\Theta(n^2\log n)$.
However, you are only given that $0<m<n^2$, that is, $m=O(n^2)$ and you can only infer that the algorithm has complexity $O(n^2 \log n)$, but not $\Theta$ of the same quantity. For instance, assume $m$ is a constant, or assume $m=\sqrt{n}$, and you... |
First of all sorry, if this question already exists, in that case, pointing to the right direction will be appreciated.
Secondly, sorry, if the question is below the expected level of Niveau, but all help appreciated.
In the textbook by J. Hromkovic, named "Theoretical Computer Science, Introduction to Automata, ... |
alphabet of a single tape turing machine that simulates a multitape TM |
|turing-machines| |
t(n)=t(n-1)+t(0)+o(n)= o(n^2) as one subarray will have 0 or 1 element the other will have
(n-1) element hence makes it O(n^2). |
null |
(I successfully downloaded the image).
It is not clear in the picture what is the difference between $\Sigma$ and $\Sigma_A$, however looking at the definition of Exercise 4.12 I think that the author simply distinguishes the input alphabet $\Sigma_A$ from the working alphabet $\Gamma_A$; so in order to simulate:
... |
(I successfully downloaded the image).
It is not clear in the picture what is the difference between $\Sigma$ and $\Sigma_A$, however looking at the definition of Exercise 4.12 I think that the author simply distinguishes the input alphabet $\Sigma_A$ from the working alphabet $\Gamma_A$ (*tape alphabet*); so in ord... |
*XOR is not the correct name, but I am looking for some kind of exclusive behavior.*
I am currently solving a set of different (assignment) problems by modeling flow networks and running a min-cost-flow algorithm. Flow networks are quite handy because a lot of problems can be reduced to them in an easy and understan... |
XOR-like behavior in flow networks |
|algorithms|graphs|network-flow|assignment-problem| |
null |
*XOR is not the correct name, but I am looking for some kind of exclusive behavior.*
I am currently solving a set of different (assignment) problems by modeling flow networks and running a min-cost-max-flow algorithm. Flow networks are quite handy because a lot of problems can be reduced to them in an easy and under... |
For your first question, I do not know any general techniques or rules of thumb that you can use to model arbitrary restrictions in flow networks. Most examples I have seen are generally based on some intuition about the nature of restrictions, and often at first seem arbitrary.
For your particular case, I have yet... |
G=({S,A,B},{0,1},P,S)
Where P:
- S→A1B
- A→0A|ε
- B→0B|1B|ε
I have to list the first 25 strings from L(G) using the left side derivation. So far I've made the tree, but I'm not sure that it's correct.
![enter image description here][1]
[1]: https://i.stack.imgur.com/yZlK7.jpg |
Derive some strings |
|context-free| |
"the first 25 strings" in what order?
Let's assume lexicographic order. Then, go by length of the produced strings.
Length 0: only $\varepsilon$ is of length $0$. Can $\varepsilon$ be generated by the grammar? (No).
Length 1: what strings of length 1 can be generated by $G$? only the string "1" (why?)
now, pr... |
"the first 25 strings" in what order?
Let's assume lexicographic order. Then, go by length of the produced strings.
Length 0: only $\varepsilon$ is of length $0$. Can $\varepsilon$ be generated by the grammar? (No).
Length 1: what strings of length 1 can be generated by $G$? only the string "1" (why?)
now, pr... |
null |
The difference between your formula and the index methods is that your formula gives more weight to recent data. If there's a lever that has large but infrequent rewards then your formula won't converge.
On the other hand, your formula will perform better than index methods if the reward distribution for some of the... |
null |
> Let $P$ be a regular language and $Q$ be a context-free language such
> that $Q \subseteq P$(For example, let $P = \{ a^*b^* \}$ and $Q = \{ a^nb^n\}$). Then which of the following is always regular?
>
> 1. $P \cap Q$
> 2. $P - Q$
> 3. $\Sigma^* - Q$
> 4. $\Sigma^* - P$
**Option 1** <br>
$P \cap Q = Q$... |
Yes, Convex Optimization with equality constraint is NP-Hard in general. However, there exist mature techniques that find very nice approximate solutions to convex optimization problems, like Coordinate Descent.
Suppose you use coordinate descent and the matrix A has rank $k$. You can fix n-k-1 coordinates of your ... |
> Let $P$ be a regular language and $Q$ be a context-free language such
> that $Q \subseteq P$(For example, let $P = a^*b^*$ and $Q = \{ a^nb^n | n \ge 0\}$). Then which of the following is always regular?
>
> 1. $P \cap Q$
> 2. $P - Q$
> 3. $\Sigma^* - Q$
> 4. $\Sigma^* - P$
**Option 1** <br>
$P \cap Q... |
I try to solve an exercise in **Distributed Algorithm** described as follow.
Let's define a *label assignment problem* as follow. There is a anonymous network (vertices don't have unique ID's , nodes don't have any clue about $n$ - number of vertices nor about network topology ). The labels assigned to vertices must... |
null |
I have to solve system of linear algebraic equations AX=B, where A is two-dimensional matrix and all elements of main diagonal are equal to zero.
How to solve this problem? Iterational methods are not applied in this case.
One way is LU Decomposition method with reordering rows of A to get entries in main diagona... |
LU decomposition with pivoting |
|matrices|linear-algebra| |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.