instruction
stringlengths
0
29.8k
⌀
If we accept some restrictions regarding the size of the inputs, I think so. There is a mapping betweeen types of grammar and the type of automaton that can recognise them: Type Grammar Accepted Automaton Type 0 Unrestricted grammar Turing Machine Type 1 Context-sensitive grammar Linear-bou...
If we accept some restrictions regarding the limmited size of the input, and we accept that the input and output symbol sets are equal (which is usually the case for digital circuits), and we consider the outputs to be part of the domain of discours, then... I think yes. There is a mapping betweeen types of grammar...
If we accept some restrictions regarding the limmited size of the input, and we consider the outputs to be part of the domain of discours appended at the end of the input (or for single-bit outputs, use it as an indicator of valid inputs), then yes. There is a mapping betweeen types of grammar and the type of autom...
Yes IF we accept some restrictions regarding the limmited size of the input, and we consider the outputs to be part of the domain of discourse appended at the end of the input (or, for single-bit outputs, use it as an indicator of valid inputs). There is a mapping betweeen types of grammar and the type of automaton...
I don't really need hands on coding help, I need to clear my concepts of some of the more complex topics of DS and Algo like NP-Completeness, Computational Geometry, String Matching, Multithreaded Algorithms and Backtracking Algorithms. I have so far read CLRF(Cormen) as my go to book. But sometimes I just can't wrap m...
Suggest good books for Advanced Data Structure and Algorithms
|algorithms|np-complete|computational-geometry|books|backtracking|
I have a bag of sets which overlap, and I am looking for an efficient (if possible, optimal) way to leverage that overlap to store those sets with minimal space requirements. For example, consider these two sets: ``` S = {1,2,3,4} T = {2,3,4,5} ``` An efficient storage solution would somehow make use of the ov...
Efficient storage of overlapping sets
|database-theory|
Let $N$ be a number and consider the sequence of $a[i]$, $b[i]$ with $i=1,n$ where $a[i]$ are positive integers and $b[i]$ is the sign '$<$' or '$>$'. Find the maximum length of the subsequence(which is not necessarily contiguous) (a[i],b[i]) such that if $$b[i]='<'$$ then $$a[i+1]<a[i]$$ and if $$b[i]='>'$$ then $$a[i...
So I'm writing a software that generates random MIDI tracks based on a given mode, tonal etc. As for now the randomisation works on tones building sequences of equal duration. What I'd like to do is also randomise the duration of each note in a sequence, but at the same time I'd like it to fit with the time signatu...
Randomly Split a Bar Into Beats
|randomized-algorithms|sets|greedy-algorithms|
There are N islands and there is one pirate. The pirate can start out from any one of the n islands and has the option of either staying on the same island for the next or moving to a different island. All the islands are connected to each other by routes. Each day the pirate steals some gold on the island he is in. Th...
how to find the most optimal path for this problem?
|algorithms|dynamic-programming|
There are N islands and there is one pirate. The pirate can start out from any one of the n islands and has the option of either staying on the same island for the next day or moving to a different island. All the islands are connected to each other by routes. Each evening of the day the pirate steals some gold on ...
There are N islands and there is one pirate. The pirate can start out from any one of the n islands and has the option of either staying on the same island for the next day or moving to a different island. All the islands are connected to each other by routes. Each evening of the day the pirate steals some gold on ...
Yes IF we accept some restrictions regarding the fixed size of the input, and we consider the outputs to be part of the domain of discourse appended at the end of the input (or, for single-bit outputs, use it as an indicator of valid inputs). There is a mapping betweeen types of grammar and the type of automaton th...
|algorithms|optimization|dynamic-programming|
If $L$ is a DCFL and $d$ a symbol, then $\{d\}^*{\cdot} L$ is not necessarily a DCFL. Thus DCFL is not closed under pre-concatenation with regular languages. An example of that is given in a related answer [Why DCFL is not closed under kleene star?][1] (see the comment by Raphael below that answer!) > The languag...
null
There are N islands and there is one pirate. The pirate can start out from any one of the n islands and has the option of either staying on the same island for the next day or moving to a different island. All the islands are connected to each other by routes. Each evening of the day the pirate steals some gold on ...
If $L ⊆ \{0, 1\}^*$ is a language, then we denote by $ \overline{L}$ the complement of $L$ For example, the definition of $coNP$ is $coNP =\{L | L \in NP\}$ The complement of $SAT$ language is $\overline{SAT} = \{\phi | \phi$ is not satisfiable$\}$ Of course, there are other $P$ languages What I want to as...
Does a language have the same time complexity as its complement language?
|complexity-theory|time-complexity|np|co-np|
The first thing I notice is the required bound: $O(N^2\cdot m)$ This is a nice cushy bound, which is good news for us. The $N^2$ bit tells me that we can visit all pairs of islands (leaving one of $N$ islands and arriving at one of the $N-1$ other islands). And the $M$ bit tells me that that process of visiting all ...
If $L ⊆ \{0, 1\}^*$ is a language, then we denote by $ \overline{L}$ the complement of $L$ For example, the definition of $coNP$ is $coNP =\{L | \overline{L} \in NP\}$ The complement of $SAT$ language is $\overline{SAT} = \{\phi | \phi$ is not satisfiable$\}$ Of course, there are other $P$ languages What I...
null
I'm looking for a context-free grammar that recognizes precisely the numbers `1` - `N` in order: `1,10,11,100` valid (numbers `1` - `4` in base-2) `1,1,10,11,100` invalid (duplicate `1`) `1,10,100` invalid (missing `3`) `10,1,11,100` invalid (has all numbers but `1` and `2` are not in the correct position) ...
What context-free grammar recognizes a list of numbers 1 - N in order?
|context-free|formal-grammars|
This language $L$ is not context-free, so there is no CFG generating it. Indeed, suppose it is context-free, and let $n$ be the pumping length. Let $u \in L$ be a word of length $\geqslant n$ (for example $u = 1, 2, …, n$ in binary). The [pumping lemma](https://en.wikipedia.org/wiki/Pumping_lemma_for_context-free_la...
This language $L$ is not context-free, so there is no CFG generating it. Indeed, suppose it is context-free, and let $n$ be the pumping length. Let $u \in L$ be a word of length $\geqslant n$ (for example $u = 1, 2, …, n$ in binary). The [pumping lemma](https://en.wikipedia.org/wiki/Pumping_lemma_for_context-free_la...
Take $s = a^{10}$ for our example string. Compute the set of all potential grammar reducing variable-rules: $$ A \to aa \\ B \to aaa \\ C \to aaaa \\ D \to aaaaa $$ There is always exactly $\left\lfloor \dfrac{|s|}{2}\right\rfloor - 1$ of these over a singleton alphabet, or in other words $O(|s|)$. Now...
An ingenious exact smallest grammar algorithm for strings over a single letter, $s \in \{a\}^*$. First enumerate the start rules up to commutation
|algorithms|formal-languages|optimization|formal-grammars|combinatorics|
null
I find Algorithm Design by Kleinberg and Tardos an excellent resource. It will cover some of the topics you mentioned.
{"Voters":[{"Id":145802,"DisplayName":"Michel"}]}
{"Voters":[{"Id":145802,"DisplayName":"Michel"}]}
Let's call two vertices $x,y\in V$ _equivalent_, if they aren't discerned by any hyperedge: For all $e\in E$ we have $x,y\in e$ or $x,y\not\in e$. It does not make sense to discern equivalent vertices by basis sets. Thus, when searching for candidate bases, one can constrain oneself to unions of equivalent classes. ...
null
I don't think there is any one-size-fits-all answer to this problem. In the worst case, no compression is possible. Which compression algorithm is best is going to depend on the distribution of problem instances that you see in real life. That information is not provided, so the question is not answerable.
null
**Setup** I have a non-empty set of elements $U$ that are arranged spatially. I would like to partition $U$ into $N$ non-empty, disjoint subsets, $A_i$, having up to $M$ elements each. Each subset is only allowed to contain neighboring elements. I would like to also partition $U$ into $N$ non-empty, disjoint s...
Modified set cover to identify "orthogonal" partitions
|integer-programming|set-cover|
**Setup** I have a non-empty set of elements $U$ that are arranged spatially. I would like to partition $U$ into $N$ non-empty, disjoint subsets, $A_i$, having up to $M$ elements each. Each subset is only allowed to contain neighboring elements. I would like to also partition $U$ into $N$ non-empty, disjoint s...
I feel like I am understanding P ≠ NP fairly well, but there is one issue I feel like I am missing. It seems like a search for an answer generates information that a check does not. Is this a correct way of looking at it, and if so, how does that not already imply that P ≠ NP? **Example for Clarification** Let's...
P = NP: Doesn't a search generate more information than a check?
|p-vs-np|
What you describe is one of the reason some people tend to think that $\mathsf{P}$ indeed is different than $\mathsf{NP}$. However, you suppose here that checking all possibilities is the only way to solve a problem, which it is not necessarily. As an example, consider primality testing. One of the naive way to find...
**Setup** I have a non-empty set of elements $U$ that are arranged spatially. I would like to partition $U$ into $N$ non-empty, disjoint subsets, $A_i$, having up to $M$ elements each. Each subset is only allowed to contain neighboring elements. I would like to also partition $U$ into $N$ non-empty, disjoint s...
**Setup** I have a non-empty set of elements $U$ that are arranged spatially. I would like to partition $U$ into $N$ non-empty, disjoint subsets, $A_i$, having up to $M$ elements each. Each subset is only allowed to contain neighboring elements. I would like to also partition $U$ into $N$ non-empty, disjoint s...
Take $s = a^{10}$ for our example string. Compute the set of all potential grammar reducing variable-rules: $$ A \to aa \\ B \to aaa \\ C \to aaaa \\ D \to aaaaa $$ There is always exactly $\left\lfloor \dfrac{|s|}{2}\right\rfloor - 1$ of these over a singleton alphabet, or in other words $O(|s|)$. Now...
**Setup** I have a non-empty set of elements $U$ that are arranged spatially. I would like to partition $U$ into $N$ non-empty, disjoint subsets, $A_i$, having up to $M$ elements each. Each subset is only allowed to contain neighboring elements. I would like to also partition $U$ into $N$ non-empty, disjoint s...
For part 1, another approach is to use a SAT solver. This might be slightly faster than an ILP solver. Let the boolean variable $a_{v,i}$ be true if $v \in A_i$, and $a_{v,i}$ be true if $v \in B_i$. Then you obtain some constraints (CNF clauses) as follows: - The $A_i$'s form a partition: $\neg a_{v,i} \lor \n...
I don't know whether there is a polynomial-time algorithm for this problem that always gives the optimal solution. Below I show a candidate heuristic that might be useful in some settings. For notation, let $L[i,j]$ be the location of the $j$th source in the $i$th list. - Initialize a queue $Q$ with all of the $L[...
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...
Checking if Schedule is recoverable
|database-theory|database-concurrency|
Yes. Consider decidable language $L$ and its complement $\bar L$. Note that the decidability of $L$ implies the decidability of $\bar L$. Thus, there exists a TM $D$ that can decide $L$ in $\text{TIME}(f(n))$. Similarly, there exists a TM $D'$ that can decide $\bar L$ in $\text{TIME}(g(n))$. We now consider three cases...
Let $P$ be a symmetric (positive definite, if that helps...) matrix of size $n$. Let $F$ be a matrix of size $n$. * Is there an existing efficient algorithm implementation to calculate $FPF^T$ ? * Is there an even more efficient existing implementation for the special case where $F$ is upper triangular ? To g...
Fast compute of F*P*FT matrix product
|matrices|matrix-multiplication|
null
I'm currently enrolled to a CS course about programming languages and we learned about structural induction. In a question from our home assignments we need to proof that the following CFG has balanced parentheses: [![][1]][1] [1]: https://i.stack.imgur.com/PbyhW.png My initial solution used simple inducti...
Proof: CFG has balanced parentheses
|formal-languages|context-free|induction|
null
null
Let $P$ be a symmetric (positive definite, if that helps...) matrix of size $n$. Let $F$ be a matrix of size $n$. * Is there an existing efficient algorithm implementation to calculate $FPF^T$ ? * Is there an even more efficient existing implementation for the special case where $F$ is upper triangular ? To g...
Let $P$ be a symmetric (positive definite, if that helps...) matrix of size $n$. Let $F$ be a matrix of size $n$. * Is there an existing efficient algorithm implementation to calculate $FPF^T$ ? * Is there an even more efficient existing implementation for the special case where $F$ is upper triangular ? To g...
Let $P$ be a symmetric (positive definite, if that helps...) matrix of size $n$. Let $F$ be a matrix of size $n$. * Is there an existing efficient algorithm implementation to calculate $FPF^T$ ? * Is there an even more efficient existing implementation for the special case where $F$ is upper triangular ? To g...
Let $P$ be a symmetric (positive definite, if that helps...) matrix of size $n$. Let $F$ be a matrix of size $n$. * Is there an existing efficient algorithm implementation to calculate $FPF^T$ ? * Is there an even more efficient existing implementation for the special case where $F$ is upper triangular ? To g...
null
I'm assuming that the axiom is $E2$. By substituting $R$ in $E2$ you get the equivalent grammar: $$ E2 \to \varepsilon \mid \text{id} \mid () \mid (E2) $$ You can show by induction on the number $i$ of productions used that every sentimental form of the above grammar has balanced parenthesis. The base case is...
I'm assuming that the axiom is $E2$. By substituting $R$ in $E2$ you get the equivalent grammar: $$ E2 \to \varepsilon \mid \text{id} \mid () \mid (E2) $$ You can show by induction on the number $i$ of productions used that every sentential form of the above grammar has balanced parentheses. The base case is ...
In Tomasulo's algorithm, is there only one reservation station per functional unit? Can there be more?
Tomasulo's Algorithm: Is there one reservation station per functional unit?
|computer-architecture|
In Tomasulo's algorithm, is there only one reservation station per functional unit (even with multiple same-function FUs like, say, 3 adders)? Can there be more?
I'm facing this problem for some time now, I've tried a greedy approach yet I result to trying a DP-ish approach, only to get stuck at a standstill. Given a board of length $n$, and an increasing monotonic "price" function $p:\mathbb{N}\rightarrow\mathbb{R}^+ $, an acceptable partition (Notated by $X=\{x_1,x_2,\ldot...
Maximal Profit of 'legal' cutting of a board
|dynamic-programming|greedy-algorithms|partitions|maximum-subarray|
Consider the set of all linear programs of the form: maximize $c x$ subject to $A x \leq b$ $x \geq 0$ where there are $m$ variables, $n$ constraints, and all coefficients in $A, b, c$ are integers from a given finite set $K$. Since the number of such programs is finite, the number of possible optimal va...
The set of possible values of linear programs
|linear-programming|
Let $OPT[i]$ denote the maximum profit that can be attained by partitioning a board of length $i$ (according to $p$). Then $OPT[0] = 0$ since the only acceptable partition has $m=0$. For $i = 1, \dots, n$: $$ OPT[i] = \max_{j=1, \dots, i} \left( p(j) + OPT[i-j] \right). $$ The optimal profit is then in $OPT[n...
This problem is known as the "rod cutting problem". See, e.g., [here](https://web.stanford.edu/class/archive/cs/cs161/cs161.1168/lecture12.pdf). Let $OPT[i]$ denote the maximum profit that can be attained by partitioning a board of length $i$ (according to $p$). Then $OPT[0] = 0$ since the only acceptable partiti...
null
null
I'm looking for an algorithm that is closely related to [2-dimensional nesting][1]. The main differences between this and normal nesting are: * A fixed number of elements to be placed * The elements cannot rotate * The elements must be placed in as _small_ an area as possible, as opposed to placing as _many_ piec...
Nesting algorithm for rectangular-based, fixed-orientation polygons
|packing|
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......