instruction
stringlengths
0
29.8k
⌀
Here are some example automata: ![example dfas][1] [1]: https://i.stack.imgur.com/zvnrW.png
we are given two strings x=x1,x2,x3,....,xm and y=y1,y2,y3,....,yn over some finite alphabet. we consider the problem of converting x to y .using the following operations: 1.substitution:replace one symbol by another one. 2.insertion:insert one symbol 3.deletion:delete one symbol. for example,if x="logarithm" and...
similarity problem
|algorithms|reference-request|programming-languages|dynamic-programming|strings|
null
A language is recursive if a Turing Machine decides it: On input *w*, the TM always halts, and accepts if *w* is in the language, and rejects if *w* is not in the language. So to show that the language is recursive, you just need to show that your Turing Machine gives the correct answer on every input string (accept...
A solution must look like this: we have list of intervals and we must tell for a new interval which of the intervals contain it and which of the list are contained in the new interval. A logical start will be that the list of intervals are sorted in some data structure and we need to add the new interval in its prop...
A language is recursive if a Turing Machine decides it: On input *w*, the TM always halts, and accepts if *w* is in the language, and rejects if *w* is not in the language. So to show that the language is recursive, you just need to show that your Turing Machine gives the correct answer on every input string (accept...
>We are given two strings $x=x_1,x_2,x_3,\ldots,x_m$ and $y=y_1,y_2,y_3,\ldots,y_n$ over some finite alphabet. We consider the problem of converting $x$ to $y$. Using the following operations: >1.Substitution: replace one symbol by another one. >2.Insertion: inserts one symbol >3.Deletion: delete one symbol. ...
String similarity problem
|algorithms|reference-request|dynamic-programming|strings|
null
null
What is the complexity approximation for The clique problem? Is it accurate to consider it 2^n? Thanks in advance!
NP complexity - clique problem
|algorithm-analysis|
Wikipedia is usually a good starting reference to well-known problems as the clique. Check this website: http://en.wikipedia.org/wiki/Clique_problem#Finding_maximum_cliques_in_arbitrary_graphs Some interesting references are included in that link
> $3^n$ grows faster than any exponential function with a base of $2$. True. This implies that $3^n = O(2^n)$ cannot be true. But what you have here is $2^{O(n)}$. Recall that $O(f(n))$ is really a set of functions, and strictly speaking we should be writing $3^n \in 2^{O(n)}$ (or even $(n \mapsto 3^n) \in 2^{O(n...
Suppose $A = \{\langle G, d, s, t\rangle : G \text{ undirected}, s, t \text{ nodes in } G, \text{there is a path of length }d \text{ from } s \text{ to } t \text{ and no path of shorter length}\}$. I can easily see that this language is in NL, but I am having trouble proving that this is NL-complete.
Prove the following problem is NL-complete
|complexity-theory|space-complexity|
null
Just like @Hendrik mention all you need to do is calculate Levenshtein distance which does exactly what you need. Levenshtein distance can be expressed in following formulae $$ \mbox{lev}_{a,b}(i, j) = \begin{cases} \max(i,j) &, \mbox{if } \min(i,j) = 0 \\ \min \begin{cases} \mbox{lev}_{a,b}(...
null
What is the best known approximation for the computational complexity of the clique problem? Is it accurate to consider it $O(2^n)$?
Computational complexity of the clique problem
|complexity-theory|time-complexity|algorithm-analysis|
Wikipedia is usually a good starting reference to well-known problems as the clique. There is [a list of the fastest known algorithms](http://en.wikipedia.org/wiki/Clique_problem#Finding_maximum_cliques_in_arbitrary_graphs) for CLIQUE including references. Apparently, the fastest algorithm we know runs in time $O(1....
Wikipedia is usually a good starting reference to well-known problems as the clique. There is [a list of the fastest known algorithms](http://en.wikipedia.org/wiki/Clique_problem#Finding_maximum_cliques_in_arbitrary_graphs) for CLIQUE including references. Apparently, the fastest algorithm we know runs in time $O(1....
|asymptotics|landau-notation|
Let $G'$ be the graph with self-loops added to every vertex. Take $n$ copies $G'_1,G'_2,\ldots,G'_n$ (without the edges) and connect $x \in G'_i$ to $y \in G'_{i+1}$ if $(x,y) \in G'$. The shortest path between $s \in G'_1$ and $t \in G'_n$, if any exists, is now of length exactly $n-1$.
$3^n \in 2^{O(n)}$ is apparently true. I thought that it was false though because $3^n$ grows faster than any exponential function with a base of 2. How is $3^n \in 2^{O(n)}$ true?
$3^n = 2^{O(n)}$ is apparently true. I thought that it was false though because $3^n$ grows faster than any exponential function with a base of 2. How is $3^n = 2^{O(n)}$ true?
> 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$...
Closure properties of languages
|formal-languages|regular-languages|context-free|closure-properties|
I got it on further thought. It is trivial. $\Sigma^* - P$ is $P'$, the complement of P and this is regular. I was unnecessarily concentrating on how $Q \subseteq P$ would play a role. It doesn't actually.
Just like @Hendrik mention all you need to do is calculate Levenshtein distance which does exactly what you need. Levenshtein distance can be expressed in following formulae $$ \mbox{lev}_{a,b}(i, j) = \begin{cases} \max(i,j) &, \mbox{if } \min(i,j) = 0 \\ \min \begin{cases} \mbox{lev}_{a,b}(...
The Clique problem takes a graph G = (V,E) and an integer k and asks if G contains a clique of size k. (A clique is a set of vertices such that every pair of vertices in the set is adjacent.) The Independent-Set problem takes a graph G’ = (V’,E’) and an integer k’ and asks if G’ contains an independent set of size k’. ...
NP complete problem
|algorithms|formal-languages|programming-languages|np-complete|computer-architecture|
This problem is as hard as comparison sorting, given `n` input number sort them. You can make interval set from input number set $S$ as follow: $ \Gamma =$$ \{(a,b) | a\in S \wedge b=\max_{t\in S} \{2\times|t|- |a| + 1 \} \} \cup \{(\max_{t\in S} \{2\times|t|+1\},\max_{t\in S} \{2\times|t|+1\})\}$ Above transf...
|algorithms|complexity-theory|graphs|np-complete|
The Clique problem takes a graph G = (V,E) and an integer k and asks if G contains a clique of size k. (A clique is a set of vertices such that every pair of vertices in the set is adjacent.) The Independent-Set problem takes a graph G’ = (V’,E’) and an integer k’ and asks if G’ contains an independent set of size k’. ...
I was practicing the following problem : There are total N operations . At each operation , you can either add element to the top or removes few elements as described below. The input (integer) other than -1 indicates that we have to add the elements in last in first out fashion(LIFO). If the input is -1 at a ti...
Efficient /Fast Algorithm for the Modified Stack Implementation
|algorithms|
The Clique problem takes a graph $G = (V,E)$ and an integer $k$ and asks if $G$ contains a clique of size $k$. (A clique is a set of vertices such that every pair of vertices in the set is adjacent.) The Independent-Set problem takes a graph $G’ = (V’,E’)$ and an integer $k’$ and asks if $G’$ contains an independent se...
You can simply push elements to the stack only if they are smaller than the element on the top of the stack.If they are bigger you will count them in different counter in order to know how much elements were pushed. When you have to pop you will pop only the top element: input: element // stack.peak...
null
You can simply push elements to the stack only if they are smaller than the element on the top of the stack.If they are bigger you will count them in different counter in order to know how much elements were pushed and keep those counters in another stack. When you have to pop you will pop only the top element: ...
This problem is as hard as comparison sorting, given `n` input number sort them. You can make interval set from input number set $S$ (w.l.o.g suppose input numbers are in $Z^+$) as follow: $ \Gamma = \{(a,b) | a\in S \wedge b=\max_{t\in S} \{2\cdot t - a + 1 \} \}$ Above transformation can be done in $O(n)$. ...
You can simply push elements to the stack only if they are smaller than the element on the top of the stack.If they are bigger you will count them in different counter in order to know how much elements were pushed and keep those counters in another stack. When you have to pop you will pop only the top element. Here...
You can simply push elements to the stack only if they are smaller than the element on the top of the stack.If they are bigger you will count them in different counter in order to know how much elements were pushed and keep those counters in another stack. When you have to pop you will pop only the top element. Here...
For the "-facing" rule to hold, you must make sure that all faces are properly oriented. Use the right-hand rule for instance, that means that the vertices of a face should be numbered in such a way that a positive rotation in the plane of the face corresponds to a normal pointing outside of the polyhedron. (Got it ?) ...
null
first your integer numbers are converted into binary numbers.<br/> ex- in CPU integer 2 is converted to 0010 > `digital comparator` or magnitude comparator is a hardware electronic > device that takes two numbers as input in binary form and determines > whether one number is greater than or less than or equal to th...
The trick is to realize that if a graph has a clique of size $k$, the inverse graph has an independent set of size $k$. A clique of size $k$ means that k nodes in the graph are all connected. In the inverse graph these $k$ nodes are not (directly) connected and can be used to create an independent set of size $k$ He...
The trick is to realize that if a graph has a clique of size $k$, the inverse graph has an independent set of size $k$. A clique of size $k$ means that k nodes in the graph are all connected. In the inverse graph these $k$ nodes are not (directly) connected and can be used to create an independent set of size $k$ He...
Reducing Clique to Independent Set
null
The trick is to realize that if a graph has a clique of size $k$, the inverse graph has an independent set of size $k$. A clique of size $k$ means that $k$ nodes all have edges in between them. In the inverse graph these $k$ nodes are not (directly) connected and can be used to create an independent set of size $k$ ...
Yes, this is called the *Product Constuction* - given DFAs $M_1$ and $M_2$, we can construct $M=M_1\times M_2$: - $M$ consists of pairs of states from its constituent DFAs, so if the original DFAs have states $A,B,C$ and $x,y,z$, the product would be $\{Ax,Ay,Az,Bx,By,Bz,Cx,Cy,Cz\}$. - The transition functio...
The trick is to realize that if a graph has a clique of size $k$, the inverse graph has an independent set of size $k$. A clique of size $k$ means that $k$ nodes all have edges in between them. In the inverse graph these $k$ nodes are not (directly) connected and can be used to create an independent set of size $k$ ...
The trick is to realize that if a graph has a clique of size $k$, the inverse graph has an independent set of size $k$. A clique of size $k$ means that $k$ nodes all have edges in between them. In the inverse graph these $k$ nodes are not (directly) connected and can be used to create an independent set of size $k$ ...
null
If you are not asked, you don't have to construct the LL(1) table to prove that it is an LL(1) grammar. You just compute the FIRST/FOLLOW sets as Alex did: FIRST(S)={a,b} FIRST(A)={ε} FIRST(B)={ε} FOLLOW(A)={a,b} FOLLOW(B)={a,b} And then, by definition an LL(1) grammar has to: 1) If **A => a** and **A => b**...
I was practicing the following problem : > There are a total of $N$ operations. At each operation, you can either add an element to the top or remove several elements as described below. > Inputs are integers. An input other than $-1$ indicates that we have to add the elements in last in first out fashion (LIFO...
Efficient algorithm for a modified stack to pop the smallest element
|algorithms|arrays|stacks|
Sounds like you are reading The Art of Multiprocessor Programming. > "All function calls have a linearization point at some instant between their invocation and their response" >> Okay that's fine, they occur somewhere within a function call, but what are they? Side effects of the functions. http://en.wikipedi...
With respect concurrent programming, What is a linearization point? They seem to occur at a CAS instruction apparently. The best definition I could find is [here][1]. "All function calls have a linearization point at some instant between their invocation and their response" Okay that's fine, they occur somew...
What is a linearization point?
|concurrency|
With respect concurrent programming, what is a linearization point? They seem to occur at a compare-and-swap instruction apparently. The best definition I could find is [here][1]. > All function calls have a linearization point at some instant between their invocation and their response. Okay that's fine, th...
|semantics|concurrency|synchronization|
How can I prove that I can verify whether a boolean assignment of variables $a$ satisfies some boolean formmula $\phi$ in polynomial time? I know that we can just plug the boolean assignment into the formula, but this seems to be a very high-level description, and I am not sure that it is a reliable one since we mus...
How is verifying whether an assignment satisfies a boolean formula $\in P$?
|complexity-theory|
Suppose $$A = \left\{\langle G, d, s, t\rangle \;\Bigg|\; \begin{array}{l} \text{\(G\) undirected}, \\ \text{\(s\) and \(t\) are nodes in \(G\)}, \\ \text{there is a path of length \(d\) from \(s\) to \(t\) and no path of shorter length} \end{array}\right\}$$ I can easily see that this language is in NL, b...
|complexity-theory|graphs|space-complexity|
If you are not asked, you don't have to construct the LL(1) table to prove that it is an LL(1) grammar. You just compute the FIRST/FOLLOW sets as Alex did: $\qquad \begin{align} \operatorname{FIRST}(S)&={a,b} \\ \operatorname{FIRST}(A)&={ε} \\ \operatorname{FIRST}(B)&={ε} \\ \operatorname{FOLLOW}(A)&={a,b} \\ \...
How is verifying whether an assignment satisfies a boolean formula possible in polynomial time?
|complexity-theory|satisfiability|
There is no need to simplify the formula, you just evaluate it recursively according to the definition of the boolean operators in use. Let $\varphi$ a boolean formula and $a$ an assignment of all variables. Then, denote with $\varphi(a)$ the result of replacing all variables in $\varphi$ with the corresponding valu...
|complexity-theory|logic|satisfiability|
There is no need to simplify the formula, you just evaluate it recursively according to the definition of the boolean operators in use. Let $\varphi$ a boolean formula and $a : X_\varphi \to \{0,1\}$ an assignment of all variables that occur in $\varphi$. Now we define the evaluation function $\operatorname{eval}_a$...
Coming from the POV of someone who has just started his MS in CS program, but is seriously considering eventually going into for his PhD. I am having trouble deciding what I will focus my research on when I go for my PhD (though I definitely know I want to go for my PhD). See http://academia.stackexchange.com/quest...
Where to find published research papers
|reference-request|
If you are not asked, you don't have to construct the LL(1) table to prove that it is an LL(1) grammar. You just compute the FIRST/FOLLOW sets as Alex did: $\qquad \begin{align} \operatorname{FIRST}(S)&={a,b} \\ \operatorname{FIRST}(A)&={ε} \\ \operatorname{FIRST}(B)&={ε} \\ \operatorname{FOLLOW}(A)&={a,b} \\ \...
See the ACM digital library, IEEE xplorer. These are the top in my opinion. Look as well in ScienceDirect (Elsevier) and Springer (for theoretical computer science, I believe these two libraries are better). Usually, googling your research problem would lead you to papers. The journals in which these papers are ...
If you are not asked, you don't have to construct the LL(1) table to prove that it is an LL(1) grammar. You just compute the FIRST/FOLLOW sets as Alex did: $\qquad \begin{align} \operatorname{FIRST}(S)&={a,b} \\ \operatorname{FIRST}(A)&={ε} \\ \operatorname{FIRST}(B)&={ε} \\ \operatorname{FOLLOW}(A)&={a,b} \\ \...
null
I'm reading the MIT Press, Introduction to Algorithms textbook 3rd edition, and I am a bit confused by an exercise. 2.1-3 Consider the searching problem: Input: A sequence of n numbers A = <a1, a1,...., an> and a value v. Output: An index i such that v = A[i] or the special value NIL if v does not appear in A. ...
loop invariant proof
|untagged|