instruction stringlengths 0 29.8k ⌀ |
|---|
null |
I am trying to solve one of the sample test problems in which I have to write an expression/pattern for the following language:
{w ∈ {0, 1, 2}*: #0(w) ∗ #1(w) is even}
I was thinking about the approach of getting all strings with even number of 0s and 1s first and then make a complement of that expression, but no... |
expression/pattern for language where product of number of 0s and 1s is even |
|formal-grammars| |
I am trying to solve one of the sample test problems in which I have to write an expression/pattern for the following language:
$\{w ∈ \{0, 1, 2\}^*: \#0(w) ∗ \#1(w) \text{ is even}\}$
I was thinking about the approach of getting all strings with even number of 0s and 1s first and then make a complement of that e... |
{"Voters":[{"Id":112114,"DisplayName":"Fred Jefferson"}]} |
I am trying to solve one of the sample test problems in which I have to write an expression/pattern for the following language:
$\{w ∈ \{0, 1, 2\}^*: \#0(w) ∗ \#1(w) \text{ is even}\}$
I was thinking about the approach of getting all strings with even number of 0s and 1s first and then make a complement of that e... |
{"Voters":[{"Id":112114,"DisplayName":"Fred Jefferson"}]} |
I am trying to solve one of the sample test problems in which I have to write an expression/pattern for the following language:
$\{w \in \{0, 1, 2\}^*: {\#}_{0}(w) ∗ {\#}_{1}(w) \text{ is even}\}$
I was thinking about the approach of getting all strings with even number of 0s and 1s first and then make a complem... |
null |
You should be able to achieve it with a finite state machine, hand rolled lexer or even a regular expression (rather long regular expression). But I will throw in a quick and easy overkill solution. There is a project called "jison" which is like Bison, but for JavaScript (https://github.com/zaach/jison). It is a parse... |
null |
You should be able to achieve it with a finite state machine, hand rolled lexer or even a regular expression (rather long regular expression). But I will throw in a quick and easy overkill solution. There is a project called "jison" which is like Bison, but for JavaScript (https://github.com/zaach/jison). It is a parse... |
I don't know whether writing the complement of a regular expression will satisfy the requirements of your test, but anyway it's not correct. $2^∗(002^∗|112^∗)^∗012^∗$ must start with $0$, $11$, or $2$, so neither $100$ nor $101$ are included, and so both of them will show up in the complement. But they both satisfy the... |
You should be able to achieve it with a finite state machine, hand rolled lexer or even a regular expression (rather long regular expression). But I will throw in a quick and easy overkill solution. There is a project called "jison" which is like Bison, but for JavaScript (https://github.com/zaach/jison). It is a parse... |
I don't know whether writing the complement of a regular expression will satisfy the requirements of your test, but anyway it's not correct. $2^∗(002^∗|112^∗)^∗012^∗$ must start with $0$, $11$, or $2$, so neither $100$ nor $101$ are included, and so both of them will show up in the complement. But they both satisfy the... |
So, I have been looking into the famous back tracking problem called N Queens. The problem is essentially finding the number of possible ways you can place a n number of queens on a n x n chess board such that all of the queens are not in any other attack positions from other queens on the board.
I came across the ... |
N Queens Problem - Number of Possible Placements |
|combinatorics| |
I think there are two important advantages of the original counting sort implementation. First, the original version can easily be modified in case the items (keys) being sorted includes additional data. Say you are sorting objects that contains an ID and name, and these objects must be sorted by their ID. The original... |
I think there are two important advantages of the original counting sort implementation. First, the original version can easily be modified in case the items (keys) being sorted includes additional data. Say you are sorting objects that contains an ID and name, and these objects must be sorted by their ID. The original... |
Is there any cellular automaton on the Eisenstein integers? By this I mean that the triangles formed by the Eisenstein integers are considered as cells and each triangle has three neighbours plus itself. I programmed in python such a cellular automaton and am curious what properties it has.
git: https://gist.github.... |
4,426,165,368 is the number of ways to place 8 *identical* queens into 64 places, i.e the number of [combinations](https://en.wikipedia.org/wiki/Combination). "Identical" means positions are considered equivalent if one queen is swapped to another queen.
Each combination corresponds to $8!$ positions if the queens a... |
You should be able to achieve it with a finite state machine, hand rolled lexer or even a regular expression (rather long regular expression). But I will throw in a quick and easy overkill solution. There is a project called "jison" which is like Bison, but for JavaScript (https://github.com/zaach/jison). It is a parse... |
You should be able to achieve it with a finite state machine, hand rolled lexer or even a regular expression (rather long regular expression). But I will throw in a quick and easy overkill solution. There is a project called "jison" which is like Bison, but for JavaScript (https://github.com/zaach/jison). It is a parse... |
Dijkstra's runtime analysis in terms of $|V|$ and $|E|$ |
|runtime-analysis|dijkstras-algorithm| |
I proposed a better approximation algorithm for vertex cover problem (a [1.999999-approximation][1] algorithm by solving a well-known SDP model and a randomized procedure). It is not published, yet. But, I am sure that it is true (I am grateful if anyone identify any potential issues).
[1]: https://vixra.org/abs... |
null |
If I have a CFL, can I define a regular substitution to make it a RL?
For example, if I have the language $\{a^nb^n | n>=0\}:$
Define $h(a)=a$ , $h(b)=b$, then $h(L)={a*}$ , am I right?
Thanks! |
CFL with regular substitution to make a regular language |
|regular-languages|automata|finite-automata|context-free| |
If I have a CFL, can I define a regular substitution to make it a RL?
For example, if I have the language $\{a^nb^n | n>=0\}:$
Define $h(a)=a$ , $h(b)=b$, then $h(L)={a^*}$ , am I right?
Thanks! |
No,by the substitution CFLs remains CFLs.
For example, $L= \{a^nb^n|n>=0\} = \{\epsilon,ab, aabb, aaabbb,.......\}.$
After substitution by $h(a) = a$ and $h(b) =b$,$h(\epsilon) = \epsilon$ then the language L becomes remains same, which is CFL. |
No,by the substitution CFLs remains CFLs.
For example, $L= \{a^nb^n|n>=0\} = \{\epsilon,ab, aabb, aaabbb,.......\}.$
After substitution by $h(a) = a$ and $h(b) =b$,$h(\epsilon) = \epsilon$ then the language L becomes remains same, which is CFL.
N. B.- One thing remember substitution for DCFLs are not closed i... |
Recently, I had to implement the following algorithm (similarly). Code in Kotlin:
fun solution(keyword: String, lyric: String): Boolean {
val lyricWords = music.split(" ")
var index = 0
for (word in lyricWords) {
for (c in word) {
if (c == k... |
Time Complexity for the given algorithm |
|algorithms|algorithm-analysis|runtime-analysis|strings| |
No,by the substitution CFLs remains CFLs by your substitution.
For example, $L= \{a^nb^n|n>=0\} = \{\epsilon,ab, aabb, aaabbb,.......\}.$
After substitution by $h(a) = a$ and $h(b) =b$,$h(\epsilon) = \epsilon$ then the language L becomes remains same, which is CFL.
N. B.- One thing remember substitution for D... |
No,by your defined substitution CFLs remains CFLs.
For example, $L= \{a^nb^n|n>=0\} = \{\epsilon,ab, aabb, aaabbb,.......\}.$
After substitution by $h(a) = a$ and $h(b) =b$,$h(\epsilon) = \epsilon$ then the language L becomes remains same, which is CFL.
N. B.- One thing remember substitution for DCFLs are not... |
How can i derivate this Hoare Tripel?
(Q; P; R) {false} x := x + 1; {x = 0}
I do not know which rule should i use on this.
I am confused on this wrong precondition. |
Hoare Triple Derivation Example (Precondition False) |
|software-verification|hoare-logic| |
I'm trying to solve the following exercise:
Given this is true:
\begin{align} \neg \forall x \space \ \exists y \ ( x\neq y \rightarrow LeftOf(x,y) )\end{align}
Demonstrate :
\begin{align} \exists y \ \forall x (x = y \ \ \lor \ \ RightOf(y,x) ) \end{align}
With LeftOf and RightOf defined as: \begin{a... |
First-Order logic exercise |
|logic|first-order-logic| |
I work in the Computer Graphics field, and I have a problem where I need to find the optimal solution for, but I'm not sure how to best formulate the problem mathematically, how to define the objective function, and finally - how best to find that optimal solution.
My problem is as follows:
I have a 3D scene, and... |
Identifying the parameters and finding an optimal solution to a problem |
|optimization|linear-programming| |
Let me cross post my question from math.stackexchange, since I feel this community is more related to the field.
Title is self explanatory. I want to know is the language $L = \{xcy \,| \,x,y\in \{a,b,c\}^\star, |x|_a = |y|_b \}$ is context-free.
I tried to prove that is not context-free using a proof by contra... |
Prove or disprove that the language $L = \{xcy\, | \, x,y\in \{a,b,c\}^\star, |x|_a = |y|_b \}$ is context free |
|context-free| |
Well this is a basic context-free language and you should easily realize it's context-free, I guess what confused you is that $x,y\in\{a,b,c\}^*$ and the word is $xcy$ so you didn't know how to deal with the $c$, I recommend for questions like this you try to solve it in the form $x\#y$ where $\#\notin\Sigma^*$ and the... |
Say I want to solve a set of problems. I know that I can map my problem as a problem that is known to be hard in the general case (say, inference in Bayesian networks). But my set only contains instances which will map to easy instances - (say, having a tree-structure when cast to a BN inference problem)
I know BNs ... |
Identifying easy subsets/instances of NP-hard problems? |
|np-complete| |
I don't think that it is possible to push an element to a **full** array-based stack in worst case $\mathcal{O}(1)$ time. However, you can rest assured that each push runs in constant **amortized** time whenever you multiply the length of the full array by a factor of $q > 1$ (like you do; $q = 2$ in your case). This i... |
No,by your defined substitution CFLs remains CFLs.
For example, $L= \{a^nb^n|n>=0\} = \{\epsilon,ab, aabb, aaabbb,.......\}.$
After substitution by $h(a) = a$ and $h(b) =b$,$h(\epsilon) = \epsilon$ then the language L becomes remains same, which is CFL. But when every symbol converges to single image then your la... |
This is a very broad topic. Every problem is a special case of some hard problem. For instance, most problems (both hard and easy ones) can be viewed as a special case of the halting problem, but that doesn't really help us distinguish hard from easy problems. It all depends on the details. I don't think there's an... |
#### Proof Idea for the usual pumping lemma
Let $s$ be a very long string in $L$. A parse tree for $s$ is so tall that it must contain some long path from the start symbol at the root of the tree to
one of the terminals at a leaf. On this long path, some nonterminal $R$ must repeat because of the pigeonhole princip... |
Let $L$ be a context-free language. Prove that there exists integer $p>0$ such that
$ \forall z\in L $ such that $ |z|\ge p $, there exists a partition $ z=uvwxy $ such that
1. $|vwx|\le p$
2. $|vx|\geq2$
3. $\forall i\geq 0 : uv^iwx^iy\in L$
HINT: $p$ needs to be bounded $ p\leq 2^{2k}$ which gives ... |
Prove a stronger version of the pumping lemma for context-free languages |
|formal-languages|context-free|formal-grammars|pumping-lemma| |
#### Proof Idea for the usual pumping lemma
Let $s$ be a very long string in $L$. A parse tree for $s$ is so tall that it must contain some long path from the start symbol at the root of the tree to
one of the terminals at a leaf. On this long path, some nonterminal $R$ must repeat because of the pigeonhole princip... |
Recently, I had to implement the following algorithm (similarly). Code in Kotlin:
fun solution(keyword: String, lyric: String): Boolean {
val lyricWords = music.split(" ")
var index = 0
for (word in lyricWords) {
for (c in word) {
if (c == k... |
No,by your defined substitution CFLs remains CFLs.
For example, $L= \{a^nb^n|n>=0\} = \{\epsilon,ab, aabb, aaabbb,.......\}.$
After substitution by $h(a) = a$ and $h(b) =b$,$h(\epsilon) = \epsilon$ then the language L becomes remains same, which is CFL. But when every symbol converges to single image then your la... |
If I have a CFL, can I define a regular substitution to make it a RL?
For example, if I have the language $\{a^nb^n \mid n\ge0\}:$
Define $h(a)=a$ , $h(b)=b$, then $h(L)={a^*}$ , am I right?
Thanks! |
No,by your defined substitution CFLs remains CFLs.
For example, $\{a^nb^n \mid n\ge0\} = \{\epsilon,ab, aabb, aaabbb,.......\}.$
After substitution by $h(a) = a$ and $h(b) =b$,$h(\epsilon) = \epsilon$ then the language L becomes remains same, which is CFL. But when every symbol converges to single image then your... |
null |
#### Proof Idea for the usual pumping lemma
Let $z$ be a very long string in $L$. A parse tree for $z$ is so tall that it must contain some long path from the start symbol at the root of the tree to
one of the terminals at a leaf. On this long path, some nonterminal $R$ must repeat because of the pigeonhole princip... |
**It's roughly any pre-training choices you encode into your model**
In machine learning a prior is, according to the book "Deep Learning" by Goodfellow, Bengio, and Courville, a probability distribution over the parameters of your machine learning model. So as I understand it according to this definition your prior... |
In Bayesian statistics, a "prior" represents the beliefs we have before observing some data. Then, after we observe some data, we update our beliefs; those updated beliefs are called the "posterior".
Statistical machine learning can be viewed through this lens. The "priors" are the beliefs we hold or we try to enf... |
I'm not sure if this is still open because the existing answer is still unacceptable. I'll try answering a bit more thoroughly in case that's still desired.
A rhetorical question to keep in mind: would anyone take you seriously if you said ZFC is "not Turing complete" and therefore insufficient to express the algori... |
I saw this image only, and it got me thinking: is this the maximum area difference between a contiguous region and Los Angeles County, such that the population of that region is smaller?
Formally, given a graph with nodes $i$ from $0$ to $n$, where $i = (p_i, a_i)$, with $p_i$ represent its population and $a_i$ its... |
Algorithm to determine maximum difference between different sets of a graph |
|graphs|dynamic-programming| |
For loop inside For loop indicates multiplication of time complexity parts.
For loop following for loop indicates addition of time complexity part.
So I'd expect: $O(mn)$
That is to say. You doing $O(m)$, $n$ number of times. Thus $O(mn)$. |
For loop inside For loop indicates multiplication of time complexity parts.
For loop following for loop indicates addition of time complexity parts.
So I'd expect: $O(mn)$
That is to say. You doing $O(m)$, $n$ number of times. Thus $O(mn)$. |
Yes. DSATUR produces an optimal coloring for interval graphs. My idea is as follows:
We know that
1. In DSATUR, once a new vertex has been colored then we should determine which of the remaining uncolored vertices has the highest number of colors in its neighborhood to color this vertex next.
2. For interval gra... |
Does there exist a general approach in mainstream academia for representing a deterministic infinite automata? Unlike the finite kind, this one with infinite number of states.
Although there is infinite state. There is a finite number of types of states. E.g. state $enterBrackets_k$ goes to state has an edge leading... |
Representing Determinstic Infinite Automata |
|finite-automata| |
I saw this image only, and it got me thinking: is this the maximum area difference between a contiguous region and Los Angeles County, such that the population of that region is smaller?
Formally, given a graph with nodes $i$ from $0$ to $n$, where $i = (p_i, a_i)$, with $p_i$ represent its population and $a_i$ its... |
Does there exist a general approach in mainstream academia for representing a deterministic infinite automata? Unlike the finite kind, this one with infinite number of states.
Although there is infinite state. There is a finite number of types of states. E.g. state $inBrackets_k$ goes to state has an edge leading to... |
Yes. DSATUR produces an optimal coloring for interval graphs. My idea is as follows:
We know that
1. In DSATUR, once a new vertex has been colored then we should determine which of the remaining uncolored vertices has the highest number of colors in its neighborhood to color this vertex next.
2. For interval gra... |
null |
As [Yuval Filmus explains](https://cs.stackexchange.com/questions/152355/representing-determinstic-infinite-automata#comment320484_152355), every language can be recognized by an infinite-state DFA. So, it is not a concept that is of much interest in computability and automata theory.
Of course you can represent an... |
As [Yuval Filmus explains](https://cs.stackexchange.com/questions/152355/representing-determinstic-infinite-automata#comment320484_152355), every language can be recognized by an infinite-state DFA. So, it is not a concept that is of much interest in computability and automata theory.
Of course you can represent an... |
This started with me trying to make a regex to accept Bitcoin addresses. However, I couldn't do it. That led me to think: "is the set of all possible Bitcoin addresses even a regular language"?
For simplicity, consider only "legacy" P2SH Bitcoin addresses: a valid address consist of the character "1" followed by 25 ... |
Are the set of all Bitcoin addresses a context-sensitive language? |
|formal-languages|context-free|regular-expressions|context-sensitive| |
This started with me trying to make a regex to accept Bitcoin addresses. However, I couldn't do it. That led me to think: "is the set of all possible Bitcoin addresses even a regular language"?
For simplicity, consider only "legacy" P2SH Bitcoin addresses: a valid address consist of the character "1" followed by 25 ... |
null |
Yes. DSATUR produces an optimal coloring for interval graphs.
My (incomplete) idea is as follows (I can't write it in a comment):
We know that
1. In DSATUR, once a new vertex has been colored then we should determine which of the remaining uncolored vertices has the highest number of colors in its neighborhoo... |
No,by your defined substitution CFLs remains CFLs.
For example, $\{a^nb^n \mid n\ge0\} = \{\epsilon,ab, aabb, aaabbb,.......\}.$
After substitution by $h(a) = a$ and $h(b) =b$,$h(\epsilon) = \epsilon$ then the language L becomes remains same, which is CFL. But when every symbol converges to single image then your... |
Any answer I give you is likely to be unsatisfying and a little silly, both because we're squarely in theory-land here (and not the useful kind of theory, but theory that is irrelevant in practice), but also because of an oddity of the SHA256 hash: the SHA256 hash was not designed to hash messages that are longer than ... |
null |
There are several non-probabilisitc proofs :
1/ using greedy algorithm deleting minimum degree :
See : https://www.sciencedirect.com/science/article/pii/S0166218X13001339
https://onlinelibrary.wiley.com/doi/10.1002/jgt.3190150110
2/ deleting vertices of maximum degree :
see :https://www.combinatorics.org/ojs/i... |
Induction on the order of G . True for |G| = 1. Assume for |G| = n let prove it for |G| = n +1. Choose a vertex v of minimum degree . Consider H = G - N[v]. Clearly a(G)> = 1 + a(H) > = 1 + sum { 1/( deg_H(u) +1) :u in V(H)} > = ** sum { 1/(deg_G(w)) +1 ) :w in N[{v] } + sum { 1/( deg_H(u) +1) : u in V(H)} = sum { 1/(d... |
Suppose we are appending elements to the tail of the list. Suppose also that the rightmost finger has index $f$. Now, the distance between $f$ and the second rightmost finger $f - 1$ (which should be the largest since we are comparing two rightmost fingers (the distance between adjacent fingers grows as we scan the fin... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.