instruction stringlengths 0 29.8k ⌀ |
|---|
The maximal choice smallest grammar algorithm. Is this an exact algorithm or an approximation? |
|algorithms|formal-languages|optimization|formal-grammars|combinatorics| |
My solution is `1*(01+){2,}0?`
1. `(01+){2,}` means there are at least two (01+), e.g. 0101, 01101, 011010111
2. Then we should allow any number of 1 at the begining so add `1*` at the begining.
3. We should allow 0 at the send, exactly one 0 or no 0. So add `0?`
Combine step 1, 2, 3, get the solution `1*(01+... |
When we speak of a variable, sometimes we will mean the string it expands to, and other times, the variable itself. Let $t \leqslant s$ mean substring.
Take the string $s = a^6$. Then its compressible substrings are $aa, aaa$. Now assign _positioned variables_ $A_i \to aa$, $B_j \to aaa$, for $i = 1...5, j = 1...... |
null |
I will describe how you can solve this with an ILP (integer linear programming) solver. For the size of problem you have, I expect it will work acceptably well.
Let's focus on just two of your shapes, say shape $S_i$ and $S_j$. Let $(x_i,y_i)$ denote the position of some fixed point of $S_i$ (say, the lower-left ... |
I'm stuck here, how can i prove this:
L1 ∪ L2 ⊆ L1*L2*
x∈ L1 ∪ L2
x∈ L1* ∨ x ∈L2*
x ∈(L1)* ∨ x∈(L2)*
x ∈L1* ∪ L2*
What's next? |
Proving L1 ∪ L2 ⊆ L1*L2* |
|formal-languages|automata|discrete-mathematics|software-engineering| |
Proving L1 ∪ L2 ⊆ L1* L2* |
I'm stuck here, how can i prove this:
```
L1 ∪ L2 ⊆ L1*L2*
```
x∈ L1 ∪ L2
x∈ L1* ∨ x ∈L2*
x ∈(L1)* ∨ x∈(L2)*
x ∈L1* ∪ L2*
What's next? |
I'm stuck here, how can i prove this:
```
L1 ∪ L2 ⊆ L1*L2*
```
x∈ L1 ∪ L2 ---->
x∈ L1* ∨ x ∈L2* ---->
x ∈(L1)* ∨ x∈(L2)* ---->
x ∈L1* ∪ L2* ---->
What's next? |
Note that for any $L$, $L\subset L^*$ since $L =L^1$ and $L^* = L^0 \cup L^1 \cup L^2 \cup... $.
Now $L_1^*L_2^* = L_1^0L_2^* \cup L_1^1L_2^* \cup L_1^2L_2^* \cup ... $. Since $\varepsilon \in L^*$, $L_1 \subset L_1^1L_2^*$ which implies that $L_1 \subset L_1^*L_2^*$.
To show that $L_2 \subset L_1^*L_2^*$ use the... |
null |
You can show first that $L_1 \cup L_2 \subset L_1^*L_2^*$.
Note that $L_1^*L_2^* = L_1^0L_2^* \cup L_1^1L_2^* \cup L_1^2L_2^* \cup ... $. Since $\varepsilon \in L^*$ and $L=L^1$, it follows that $L_1 \subset L_1^1L_2^*$ which then implies that $L_1 \subset L_1^*L_2^*$.
To show that $L_2 \subset L_1^*L_2^*$ use t... |
You can show first that $L_1 \cup L_2 \subset L_1^*L_2^*$:
* Note that $L_1^*L_2^* = L_1^0L_2^* \cup L_1^1L_2^* \cup L_1^2L_2^* \cup ... $. Since $\varepsilon \in L^*$ and $L=L^1$, it follows that $L_1 \subset L_1^1L_2^*$ which then implies that $L_1 \subset L_1^*L_2^*$.
* To show that $L_2 \subset L_1^*L_2^*$ us... |
null |
null |
Consider the following schedule S.Is S conflict–serializable? Append the commit operations of these transactions at the end of the
schedule in an appropriate order such that S is recoverable. How many such orders are there?
$$S: r1(X); r2(Z); r1(Z); r3(X); r3(Y); w1(X); w3(y); r2(Y); w2(Z); w2(Y);$$
I have alrea... |
null |
A schedule is said to be irrecoverable if it has a [Dirty read][1], and the commits are not in order of the dirty reads. There is one dirty read $w3(Y); r2(Y)$. So the order of commits should be where $T(3)$ commits before $T(2)$, giving 3 commit orders
$$T(1);T(3);T(2);$$
$$T(3);T(1);T(2);$$
$$T(3);T(2);T(1);$$
... |
null |
How can I calculate the complexity of:
$MD(bi) = \min \{ (\max b_i -\min b_i + MD(b_i-\max(b_i)), (\max b_i -\min b_i + MD(b_i-\min(b_i)))\} $
Where is a sequence $b= (b_1, b_2, \dots, b_n)$ and $b_i= (b_1, b_2, \dots, b_i)$ for $i= 1,\dots, n$
Thoughts: I think the time complexity is $O(n^2) $ because we ne... |
Complexity of finding the maximum |
|time-complexity|optimization|dynamic-programming|polynomial-time| |
We perform the induction on derivation steps. Let's say that our derivation of $\alpha$ $\in$ $L(E2)$ is composed of $k$ steps, the first step is denoted as $V \xrightarrow{k} \alpha$, the second step will be $ \alpha \xrightarrow{2} \beta$, and so on. I'll be assuming that the starting symbol is $E2$
It's trivial t... |
I think the precise definition of a final coalgebra might help.
Fix a set of symbols $\Sigma$. For any set $X$ define $F(X) = \Sigma \times X$, and for any $f : X \to Y$ let $F(f) : F(X) \to F(Y)$ be the map $(s, x) \mapsto (s, f(x))$. Then $F : \mathsf{Set} \to \mathsf{Set}$ is a functor.
An **$F$-coaglebra** is... |
null |
*Given a graph G = (V, E) with edge lengths c : E → R, and a number d ∈ R, is there a Hamilton cycle of length l ≤ d in G?
Show that the Travelling-Salesman problem is contained in the complexity class NP.*
I am somewhat struggling with this exercise because I have little problem understanding the formality. I know... |
Show that the decision version of the Traveling Salesman problem is in NP |
|traveling-salesman| |
*Given a graph G = (V, E) with edge lengths c : E → R, and a number d ∈ R, is there a Hamilton cycle of length l ≤ d in G?
Show that the Travelling-Salesman problem is contained in the complexity class NP.*
I am somewhat struggling with this exercise because I have little problem understanding the formality. I know... |
TSP can be expressed as a decision problem and an optimisation problem.
Here, as you said, a solution to the optimisation problem can be seen as a certificate to the decision problem: if you are given a certain path in $G$, you can verify in polynomial time that:
1. it is a Hamiltonian cycle;
2. its weight is ... |
We perform the induction on derivation steps. Let's say that our derivation of $\alpha$ $\in$ $L(E2)$ is composed of $k$ steps, the first step is denoted as $V \xrightarrow{k} \alpha$, the second step (if $k >= 2$) will be $ \alpha \xrightarrow{k-1} \beta$, and so on. I'll be assuming that the starting symbol is $E2$
... |
We perform the induction on derivation steps. Let's say that our derivation of some sentence in $L(E2)$ is composed of $k$ steps, the first step is denoted as $V \xrightarrow{k} \alpha$, the second step (if $k >= 2$) will be $ \alpha \xrightarrow{k-1} \beta$, and so on. I'll be assuming that the starting symbol is $E2$... |
Definition of an NP problem: An NP problem is a decision problem, which means for every instance there is an answer, either “Yes” or No”. For each yes-instance there is a polynomial size correct certificate. And there is a program which given an instance and a certificate will tell you in polynomial time “Yes” if given... |
Definition of an NP problem: An NP problem is a decision problem, which means for every instance there is an answer, either “Yes” or No”. For each yes-instance there is a polynomial size correct certificate. And there is a program which given an instance and a certificate will tell you in polynomial time “Yes” if given... |
No, the time complexity is not $O(n^2)$.
Assume all elements in the given $b$ are different. Then the number of different sequences that appear on the left-hand side of the recurrence relation you will compute is $\Omega(n^2)$. The average time to find the minimum or the maximum is $\Omega(n)$. Hence the time-comple... |
null |
How can I calculate the complexity of:
$$MD(bi) = \max(b_i)-\min(b_i) + \min\{MD(b_i-\max(b_i)), MD(b_i-\min(b_i))\}$$
Where is a sequence $b= (b_1, b_2, \dots, b_n)$ and $b_i= (b_1, b_2, \dots, b_i)$ for $i= 1,\dots, n$. I want to know $MD(b)$.
Thoughts: I think the time complexity is $O(n^2) $ because we n... |
Time complexity of finding the minimum by dynamic programing |
No, the time complexity is not $O(n^2)$.
Assume all elements in the given $b$ are different. Then the number of different sequences that appear on the left-hand side of the recurrence relation you will compute is $\Omega(n^2)$. The average time to find the minimum or the maximum is $\Omega(n)$. Hence the time-comple... |
No, the time complexity is not $O(n^2)$.
Assume all elements in the given $b$ are different. Then the number of different sequences that appear on the left-hand side of the recurrence relation you will compute is $\Omega(n^2)$. The average time to find the minimum or the maximum is $\Omega(n)$. Hence the time-comple... |
How can I calculate the complexity of:
$$MD(s) = \max(s)-\min(s) + \min\{MD(s-\max(s)), MD(s-\min(s))\}$$
Where $s$ is a finite set of numbers. I want to compute $MD(b)$, where $b=(b_1,b_2,\dots,b_n)$.
Thoughts: I think the time complexity is $O(n^2) $ because we need linear time to calculate the maximum and... |
How can I calculate the complexity of:
$$MD(s) = \max(s)-\min(s) + \min\{MD(s-\max(s)), MD(s-\min(s))\}$$
Where $s$ is a finite multi-set of numbers. I want to compute $MD(b)$, where $b=(b_1,b_2,\dots,b_n)$.
Thoughts: I think the time complexity is $O(n^2) $ because we need linear time to calculate the maxim... |
How can I calculate the complexity of:
$$MD(s) = \max(s)-\min(s) + \min\{MD(s\setminus\{\max(s)\}), MD(s\setminus\{\min(s)\})\}$$
Where $s$ is a finite multi-set of numbers. I want to compute $MD(b)$, where $b=(b_1,b_2,\dots,b_n)$.
Thoughts: I think the time complexity is $O(n^2) $ because we need linear tim... |
Let's say that I have a Las Vegas algorithm for a given problem (whose answer is `true`/`false` for simplicity) with a chance of answering `p`, and a Montecarlo algorithm for the same problem which is `q`-correct (it gives the correct answer with a probability of at least `q`)
Could there be any way to combine them ... |
Combine Las Vegas and Montecarlo probabilistic algorithms to improve chance of finding correct answer |
|algorithms|randomized-algorithms|probabilistic-algorithms|monte-carlo| |
How can I calculate the complexity of:
$$MD(s) = \max(s)-\min(s) + \min(MD(s\setminus\{\max(s)\}), MD(s\setminus\{\min(s)\}))$$
where $s$ is a finite multi-set of numbers. I want to compute $MD(b)$, where $b=(b_1,b_2,\dots,b_n)$.
Thoughts: I think the time complexity is $O(n^2) $ because we need linear time ... |
If done recursively by brute force, the computation follows the recurrence
$$T(n)=2n+2T(n-1),$$ assuming that the cost of a $\min$ or $\max$ is $n$.
The solution of this recurrence is exponential $O(2^n)$.
But if you look closer, you only apply the function $MD$ to $\dfrac{n(n+1)}2$ different subsets, namely th... |
How can I calculate the complexity of computing $MD(b)$, where $b=(b_1,b_2,\dots,b_n)$?
$$MD(s) = \max(s)-\min(s) + \min(MD(s\setminus\{\max(s)\}), MD(s\setminus\{\min(s)\}))$$
where $s$ is a finite multi-set of numbers with base case
$$MD(\text{two elements})=\text{the bigger element}-\text{the smaller element}.$... |
No, the time complexity is not $O(n^2)$.
Assume all elements in the given $b$ are different. Then the number of different sequences that appear on the left-hand side of the recurrence relation you will compute is $\Omega(n^2)$. The average time to find the minimum or the maximum is $\Omega(n)$. Hence the time-comple... |
No, the time complexity is not $O(n^2)$.
Assume all elements in the given $b$ are different. Then the number of different multi-sets that appear on the left-hand side of the recurrence relation you will compute is $\Omega(n^2)$. The average time to find the minimum or the maximum is $\Omega(n)$. Hence the time-compl... |
If we have this language $ L = \{a^mb^nc^n:m,n \in N\}$, would its complement be $\{a,b,c\}^* \setminus L = L^\complement = \{c^nb^na^m:m,n \in N\}$? This was the professor's answer, which I find incorrect, because it doesn't include $aba$, which should be in the complement as well. Since the given language is not regu... |
complement of {a^lb^mc^n:n>l+m} |
|formal-languages|automata|finite-automata| |
If we have this language $ L = \{a^mb^nc^n:m,n \in N\}$, would its complement be $\{a,b,c\}^* \setminus L = L^\complement = \{c^nb^na^m:m,n \in N\}$? This was the professor's answer, which I find incorrect, because it doesn't include for example $aba$, which should be in the complement as well. Since the given language... |
How can I calculate the complexity of computing $MD(b)$, where $b=(b_1,b_2,\dots,b_n)$?
$$MD(s) = \max(s)-\min(s) + \min(MD(s\setminus\{\max(s)\}), MD(s\setminus\{\min(s)\}))$$
where $s$ is a finite multi-set of numbers with base case
$$MD(\text{one element})=0.$$
Thoughts: I think the time complexity is $O(n^2... |
No, the time complexity is not $O(n^2)$.
Assume all elements in the given $b$ are different. Then the number of different multi-sets that appear on the left-hand side of the recurrence relation you will compute is $\Omega(n^2)$. The average time to find the minimum or the maximum is $\Omega(n)$. Hence the time-compl... |
I'm working on some exercises regarding graph theory and complexity.
Now I'm asked to give an algorithm that computes a transposed graph of $G$, $G^T$ given the adjacency matrix of $G$. So basically I just have to give an algorithm to transpose an $N \times N$ matrix.
My first thought was to loop through all rows ... |
null |
That's a good question!
All of this will depend in your application and camera setup. Usually, it works like this: if you have a say 128x128 detector template you will be able to detect the object at this size and greater dimensions. When you go up at the pyramid the image size is smaller, but the detected object (w... |
null |
I have 4 questions regarding relation between starvation and bounded waiting.
1.Does starvation-freedom imply deadlock-freedom?
My Answer:
From [here][1],
definition of starvation free is
> **Freedom from Starvation** -:Every thread that attempts to acquire the lock eventually succeeds
> **Free... |
null |
I have 4 questions regarding relation between starvation and bounded waiting.
1.Does starvation-freedom imply deadlock-freedom?
My Answer:
From [here][1],
definition of starvation free is
> **Freedom from Starvation** -:Every thread that attempts to acquire the lock eventually succeeds
> **Free... |
Despite what badly written pop-science explanations of quantum computation may tell you, a qubit is _not_ two classical bits and $N$ qubits is _not_ $2^N$ bits. Qubits are fundamentally different from bits, pairs of bits or anything else (except for a representation of $\alpha$ and $\beta$ in binary to p... |
null |
|dynamic-programming|numerical-algorithms| |
null |
null |
You can think of $ \lvert 0 \rangle $ or $ \lvert 1 \rangle $ as the standard basis of $ \mathbb{C}^2 $. In this sense, a single qubit $ \lvert \psi \rangle $ is nothing more than a unit vector in $ \mathbb{C}^2 $, that is, a linear combination of $ \lvert 0 \rangle $ and $ \lvert 1 \rangle $ with length $1$. Now, a $N... |
## Description
Similar to the encoding of a Turing Machine, we can encode a Push-Down Automata. Denote $\langle M \rangle$ as the encoding of PDA M, and a natural number n, is language $L = \{ \langle M \rangle | \text{ M is a PDA, L(M) contains at least 1 string w that } |w| \leq n \}$ a recursive language?
## Q... |
Prove that $L = \{ \langle M \rangle | \text{ M is a PDA, L(M) contains at least 1 string w that } |w| \leq n \}$ is recursive? |
|turing-machines|computability|automata|decidability| |
null |
null |
You should think in algorithms instead of thinking in Turing Machine. Turing Machines are just a very formal way to express algorithms but writing a Turing Machine even for simple algorithms is a chore.
It suffices to know that if one really wanted to, they could construct a very complicated Turing Machine to encode... |
I will describe how you can solve this with an ILP (integer linear programming) solver. For the size of problem you have, I expect it will work acceptably well.
Let's focus on just two of your shapes, say shape $S_i$ and $S_j$. Let $(x_i,y_i)$ denote the position of some fixed point of $S_i$ (say, the lower-left ... |
null |
For simplicity, assume $0 \in K$. It allows us to treat $x \geq 0$ constraints in the same way as other constraints.
For an LP that has an optimal solution, there is an optimal solution in the basis. Therefore, it is sufficient to consider the set of possible solutions for systems of $m$ non-singular linear equations ... |
Let $A \subseteq Z$, where $Z=\{1,2,3,\cdots,n\}$. Now given any $B \subseteq Z$, we need to check whether $A \cap B =\varphi$ or not. I am looking for a randomized algorithm.
I am trying to implement it using a bloom filter.
Create a bloom filter of size max (|A|,|B|). Iterate over both sets $A$ and $B$ and check ... |
Set intersection using bloom intersection |
|bloom-filters| |
I guess the question does not apply just to CS as I'm trying to understand how it applies to RAIDs, but I guess it's maybe the most suitable place to ask anyway.
There's a lot of info that RS codes are often used to implement second parity for RAID-6. There are some systems that implement triple-parity.
Am I righ... |
Am I right that Reed-Solomon codes can be used to implement arbitrary-parity RAID schemes? |
|coding-theory|error-correcting-codes| |
null |
I guess the question does not apply just to CS as I'm trying to understand how it applies to RAIDs, but I guess it's maybe the most suitable place to ask anyway.
There's a lot of info that RS codes are often used to implement second parity for RAID-6. There are some systems that implement triple-parity.
Am I righ... |
Let $A \subseteq Z$, where $Z=\{1,2,3,\cdots,n\}$. Now given any $B \subseteq Z$, we need to check whether $A \cap B =\varphi$ or not. I am looking for a randomized algorithm.
I am trying to implement it using a bloom filter.
Create a bloom filter for $A$ and $B$ respectively. Now consider the intersection of $A$ a... |
null |
For your $f_1$, you need to solve the recurrence
$$T(n)=\begin{cases}n<k\to c\\n\ge k\to T(f_1(\frac n2) + f_1(\frac n3) - f_1(\frac n5))+T(\frac n2)+T(\frac n3)+T(\frac n5).\end{cases}$$
This mandates the resolution of the recurrence on $f_1$ itself, probably not the easiest thing. |
For your $f_1$, you need to solve the recurrence
$$T(n)=\begin{cases}n<k\to c\\n\ge k\to T(f_1(\frac n2) + f_1(\frac n3) - f_1(\frac n5))+T(\frac n2)+T(\frac n3)+T(\frac n5).\end{cases}$$
This mandates the resolution of the recurrence on $f_1$ itself, probably not the easiest thing.
----------
Your second... |
If k ≤ 1 then we are stuck; there will be infinite recursion unless the input is n = 0 for k = 0.
Otherwise: The result is 1 if $n < k \cdot 2^m$, for every m ≥ 0. Proof by induction: It is obviously true if m = 0. Assume it is true for all m' ≤ m: Let $n < k \cdot 2^{m+1}$. If $n < k \cdot 2^m$ then the result is ... |
I work with elements that have a representation in two different vector spaces and I would like to compute an indicator of how similar the neighbors of the elements are in these two spaces.
To do so, I start by computing the list of the $n$-nearest neighbors of all elements, then I use a sequence similarity measure... |
Is there an existing similarity measure for comparing sequences similar to this one? |
|algorithms| |
I am creating a database on students' interests using the Entity-Relationship Model for a University assignment.
Should I implement the circled stuff as attribute, or an entity set?
[![ER Diagram for Student Interest Database][1]][1]
[1]: https://i.stack.imgur.com/s8yPX.png |
Implement this as Attribute or Entity Set? |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.