instruction
stringlengths
0
29.8k
⌀
in his original paper "on computable numbers with an application to the entscheidungsproblem"[[1]](https://www.cs.virginia.edu/~robins/Turing_Paper_1936.pdf) Turing didn't have halting problem (see [[2]](https://www.researchgate.net/profile/Salvador-Lucas/publication/352559794_Did_Turing_Care_of_the_Halting_Problem/lin...
null
Recently, my girlfriend and I were trying to get out of the house, when I encountered a phenomenon which I thought might be analogous to a tradeoff in concurrent systems. Here's the real world setup. ### Processes - `Process A`: Girlfriend orders coffee on phone. - `Process B`: Girlfriend gets ready at apartme...
Is there an algorithm for enumerating a sequence of minimal-length substrings composed of terminal symbols within some CFG which are not substrings of any string in the language defined by that CFG? In other words, given a CFG, $G=(V,\Sigma ,R,S)$, find a sequence of increasing-length substrings $E = \{e \in \Sigma^+ \...
Minimal-length strings which are not substrings of any string in a given context free language
|formal-languages|context-free|formal-grammars|
Minimal-length strings that are not substrings of any string in a given CFL
Is there an algorithm for enumerating a sequence of minimal-length substrings composed of terminal symbols within some CFG which are not substrings of any string in the language defined by that CFG? In other words, given a CFG, $G=(V,\Sigma ,R,S)$, find a sequence of increasing-length strings $E = \{e \in \Sigma^+ \mid...
Minimal-length strings which are substrings of no string in a given CFL
If I reverse a single edge in a DAG, how can I efficiently propagate the effects of that (e.g. change other edges) such that I don't introduce any cycles by said reversal? Is there a named algorithm for this that I should look up? I see some other questions about reversing an entire DAG; I'm only concerned with a singl...
reverse single edge in DAG and keep it a DAG
|graphs|dag|
Non-regular language whose prefix language is not the whole set of words
I would suggest the following: If you know a [topological sorting](https://en.wikipedia.org/wiki/Topological_sorting) $(s_0, …, s_{n-1})$ of your DAG and you want to reverse the edge $(s_i, s_j)$, $i < j$: ``` Input: DAG G = (S, A), topological sorting (s0, s1, …, s{n-1}), indices i < j for each k from i to j...
null
If I reverse a single edge in a DAG, how can I efficiently propagate the effects of that (e.g. change other edges) such that I don't introduce any cycles by said reversal? Is there a named algorithm for this that I should look up? I see some other questions about reversing an entire DAG; I'm only concerned with a singl...
null
Consider the stable marriage problem with $n$ men and $n$ women. Let $A$ and $B$ be two stable matchings, and suppose that we form a new matching $C$ by assigning to each men his favorite partner between the ones he gets in $A$ and $B$. Prove that $C$ is also a stable matching. This is my attempt. I'm stuck at provi...
Proving that this matching is stable
|graphs|matching|bipartite-matching|
I believe this can be formulated as a min-cut problem, and thus solved with an algorithm for max-flow. Suppose you want to reverse the edge $s \to t$, and turn it into the edge $t \to s$. That will pose a problem for every other path $s \leadsto t$, because each such path will create a cycle in the graph. So, we c...
First, you need to prove that $C$ is a matching: suppose it is not a matching. That means that there exists two men $m_1$, $m_2$ matched with the same woman $w$. It follows that, without loss of generality, $m_1$ is matched with $w$ in $A$ and $m_2$ is matched with $w$ in $B$. Without loss of generality again, supp...
Assume $\Sigma$ contains two symbols such as $\{0,1\}$ or more. Otherwise, $\Sigma$ contains only one symbols, which means, as stated in the queustion, $pref(L)=\Sigma^*$ for any non-regular language $L$. Here is the simplest way to find such examples. Let $L$ be a non-regular language such that $pref(L)$ is r...
Assume $\Sigma$ contains at least two symbols such as $\{0,1\}$ or more. <!-- Otherwise, $\Sigma$ contains only one symbol, which means, as stated in the question, $pref(L)=\Sigma^*$ for any non-regular language $L$. --> Here is the simplest way to find such examples. Let $L$ be a non-regular language such that...
null
Assume $\Sigma$ contains at least two symbols such as $\{0,1\}$. <!-- Otherwise, $\Sigma$ contains only one symbol, which means, as stated in the question, $pref(L)=\Sigma^*$ for any non-regular language $L$. --> Here is the simplest way to find such examples. Let $L$ be a non-regular language such that $pref(L...
Here's a quite simple example: the language $\{a^m b^{mn} : m, n \in \mathbb{N}\}$ is not regular, but its prefix language $\{a^m b^n : m, n \in \mathbb{N}\}$ is regular.
null
In other words, if I have 10 arrays each with 10 of the same values but scrambled their order and heapified them all, is it possible to have different results?
If you took the permutations of an array and heapified it, will you always get the same heap?
|algorithms|data-structures|heaps|
Assume $\Sigma$ contains at least two symbols such as $\{0,1\}$. <!-- Otherwise, $\Sigma$ contains only one symbol, which means, as stated in the question, $\mathit{pref}(L)=\Sigma^*$ for any non-regular language $L$. --> Here is the simplest way to find such examples. Let $L$ be a non-regular language such tha...
The [wikipedia for even-odd rule][1] says > On a simple curve, the even–odd rule reduces to a decision algorithm for the point in polygon problem. On a complex polygon, there are clearly false negatives in the holes. For example, the hole in the middle of a pentagram is within the boundary of the polygon, but any...
Does the even-odd rule ever have false positives for deciding a point in a complex polygon?
|computational-geometry|
Assume $\Sigma$ contains at least two symbols. <!-- Otherwise, $\Sigma$ contains only one symbol, which means, as stated in the question, $\mathit{pref}(L)=\Sigma^*$ for any non-regular language $L$. --> ------ Here are three simple examples. - Words that are $0$ followed by a palindrome. - Palindromes that...
Non-regular language whose prefix language is regular but not the whole set of words
Assume $\Sigma$ contains at least two symbols. <!-- Otherwise, $\Sigma$ contains only one symbol, which means, as stated in the question, $\mathit{pref}(L)=\Sigma^*$ for any non-regular language $L$. --> ------ Here are three simple examples. - Words that are $0$ followed by a palindrome. - Palindromes that...
Here's a quite simple example: the language $\{a^m b^{mn} : m, n \in \mathbb{N}^{+}\}$ is not regular, but its prefix language $\{a^m b^n : m, n \in \mathbb{N}^{+}\}$ is regular.
A straightforward reduction follows from Fowler, Paterson, and Tanimoto "[Optimal packing and covering in the plane are np-complete][1]" 1981. The details are in the paper. Summarized: To transform 3-SAT into this problem fill a large grid with negative values, then place large positive valued cells in specific loca...
Here's a quite simple example: the language $\{a^m b^{mn} : m, n \in \mathbb{N}\}$ is not regular, but its prefix language is recognised by the regular expression $a^* \,|\, aa^*b^*$.
null
Here's a quite simple example: the language $\{a^m b^{mn} : m, n \in \mathbb{N}\}$ is not regular, but its prefix language is recognised by the regular expression $\epsilon \,|\, aa^*b^*$.
The language $\{0^n1^m: 0\le n\le m\}$ is not regular, but its prefix language is $0^*1^*$. ------ Here are more examples. Assume $\Sigma$ contains $0$ and $1$ . <!-- Otherwise, $\Sigma$ contains only one symbol, which means, as stated in the question, $\mathit{pref}(L)=\Sigma^*$ for any non-regular language $...
I've seen some questions regarding the regularity of prefix language of non-regular languages (for examples, [here](https://cs.stackexchange.com/questions/98112/non-regular-language-whose-prefix-language-is-regular) and [here](https://cs.stackexchange.com/questions/117078/example-of-non-regular-context-free-language-l-...
null
null
In [1], Corollary 2.3, after proving that HC-k-(n-even) for a fixed k >= 3, the paper says that HC-k-regular being NP Complete is _an inmediate consequence of the former_. Where: HC-k-regular-(n-even) means if the graph has a hamiltonian cycle in a k-regular graph with an even number of nodes. And HC-k-regular m...
Why HC-k-regular-(n-even) being NP-Complete implies HC-k-regular is NP complete?
|graphs|np-complete|hamiltonian-circuit|
null
Hmmm, I think by definition "HC-k-regular-(n-even) is NP-Complete" implies "HC-k-regular is NP-hard", since every NP problem can be reduce to an instance of HC-k-regular-(n-even) problem, which is also an HC-k-regular problem. Together with the obvious result that "HC-k-regular is NP", we can get the conclusion "HC-k-r...
Let $M$ be a collection of elements given in the form of the array such that membership of any element can be done in $O(1)$ time. The goal is to sample an element from the array $M$. Note that we will run the sampling algorithm multiple times (say $k$ times) in such a way that in each repetition we get different eleme...
Faster Algorithm for sampling a point from the array
|algorithms|sampling|
Let $M$ be a collection of elements given in the form of the array such that membership of any element can be done in $O(1)$ time. The goal is to sample an element from the array $M$. Note that we will run the sampling algorithm multiple times (say $k$ times) in such a way that in each repetition we get different eleme...
Hmmm, I think by definition "HC-k-regular-(n-even) is NP-Complete" implies "HC-k-regular is NP-hard", since every NP problem can be reduce to an instance of HC-k-regular-(n-even) problem, which is also a HC-k-regular instance. Together with the obvious result that "HC-k-regular is NP", we can get the conclusion "HC-k-r...
Let $M$ be a collection of elements given in the form of the array such that membership of any element can be done in $O(1)$ time. The goal is to sample an element from the array $M$. Note that we will run the sampling algorithm multiple times (say $k$ times) in such a way that in each repetition we get a different ele...
I've learned that finite automata doesn't have memory and hence languages, where there are comparison within the string, can't be considered regular. In our university there was a question where the following term was considered as *regular* in the solutions: $\{WXW^R | W,X ∈ \{0,1\}^*\}$ here, $W^R$ is the reve...
does finite automate have memory?
|finite-automata|
null
I've learned that finite automata doesn't have memory and hence languages, where there are comparison within the string, can't be considered regular. In our university there was a question where the following language was considered as *regular* in the solutions: $\{WXW^R | W,X ∈ \{0,1\}^*\}$ here, $W^R$ is the ...
The "and hence..." is incorrect. There might be other ways to determine whether a string is in the language, that doesn't require comparison. For the particular language you cite, try to come up with an example of a string that is *not* in that language. That might make it clearer why it is regular, and why the "a...
Let $M$ be a collection of elements given in the form of the array such that membership of any element can be done in $O(1)$ time. Which means elements of array $M$ are $\{1,2,\cdots,n\}$ such that $1$ is stored at $M[1]$ and $2$ at $M[2]$ and so on. The goal is to sample an element from the array $M$. Note that we...
Let $M$ be a collection of elements given in the form of the array such that membership of any element can be done in $O(1)$ time. Which means elements of array $M$ are $\{1,2,\cdots,n\}$ such that $1$ is stored at $M[1]$ and $2$ at $M[2]$ and so on. The goal is to sample an element from the array $M$. Note that we...
Let $M$ be a collection of elements given in the form of the array such that membership of any element can be done in $O(1)$ time. Which means elements of array $M$ are $\{1,2,\cdots,n\}$ such that $1$ is stored at $M[1]$ and $2$ at $M[2]$ and so on. The goal is to sample an element from the array $M$. Note that we...
I have a question for my thesis research, but I am not able to find proof of this. Does anyone have any idea on what should be approach be in order to prove this? Question -> Prove that L1 ∪ L2 ⊆ L1L2, if λ ∈ L1 ∩ L2
Proof for Language: L1 ∪ L2 ⊆ L1L2
|formal-languages|automata|
I'm just a beginner, I've started learning programming, CS, math, and Unix. I know how to code in Pascal and also study C. In the university a professional programmer, who teaches coding, said that literally everything in C is a side effect. >Accessing a volatile object, modifying an object, modifying a file, or ca...
Is it true that everything is a side effect in C?
|programming-languages|c|
I have a question for my thesis research, but I am not able to find proof of this. Does anyone have any idea on what should be approach be in order to prove this? Question: ```Prove that L1 ∪ L2 ⊆ L1L2, if λ ∈ L1 ∩ L2```
No, there is no "false positive". ------ Before I start explaining why there is no "false positive", please allow me to lecture a bit on the meaning of "the even-odd rule". > The SVG defines the even–odd rule by saying: > > This rule determines the "insideness" of a point on the canvas by drawing a ray from ...
|terminology|computational-geometry|polygons|
No, there is no "false positive". ------ Before I start explaining why there is no "false positive", please allow me to lecture a bit on the meaning of "the even-odd rule". > The SVG defines the even–odd rule by saying: > > This rule determines the "insideness" of a point on the canvas by drawing a ray from ...
So your situation in computing terms: You have two task A and B that could be calculated in parallel. A produces a result X at no cost at the end of A. B requires X at the first step. B has the choice of waiting for A to finish, or calculating X itself. It is not uncommon that trying to parallelise tasks involves d...
I'm just a beginner, I've started learning programming, CS, math, and Unix. I know how to code in Pascal and also study C. In the university a professional programmer, who teaches coding, said that literally everything in C is a side effect. >Accessing a volatile object, modifying an object, modifying a file, or ca...
Such considerations are known as Critical Path analysis. They allow to describe the temporal dependencies and find the fastest solution, as well as detect bottlenecks or near-bottlenecks. https://en.wikipedia.org/wiki/Critical_path_method
null
I found the following definition, which IMO is relevant: "A side effect is when a function relies on, or modifies, something outside its parameters to do something. For example, a function which reads or writes from a variable outside its own arguments, a database, a file, or the console can be described as having s...
Let $M$ be a collection of elements given in the form of the array such that membership of any element can be done in $O(1)$ time. Which means elements of array $M$ are $\{1,2,\cdots,n\}$ such that $1$ is stored at $M[1]$ and $2$ at $M[2]$ and so on. The goal is to sample an element from the array $M$. Note that we...
return M[(i - 1) % n + 1] for $i=1,2, \cdots k$ does the trick.
Here's a quite simple example: the language $\{a^m b^{mn} : m, n \in \mathbb{N}\}$ is not regular, but its prefix language is recognised by the regular expression $\epsilon \mathop{|} a a^{*} b^{*}$.
Question I was asked: Does it make a difference if I say "The worst case run time is $O(n^2)$ vs the worst case run time is $\Theta(n^2)$?" To me, the only difference is that when we say $O(n^2)$, the function may also be $O(n)$, we do not know. But when we say $\Theta(n^2)$, we know for a fact the function is $O(n^...
null
Question I was asked: Does it make a difference if I say "The worst case run time is $O(n^2)$ vs the worst case run time is $\Theta(n^2)$?" To me, the only difference is that when we say $O(n^2)$, the function may also be $O(n)$, we do not know. But when we say $\Theta(n^2)$, we know for a fact the function is $O(n^...
I'd take the language $(01)^n 0^m$ where m = 0 or 1, and 2n + m is a prime number. That is a string alternating between 0 and 1, and the length is a prime number. The prefix language is the regular language of alternating 0's and 1's. You can take any regular language L and then create a language L' consisting of s...
You answer yourself by saying that $\Theta$ is the conjunction of $O$ and $\Omega$. So yes of course, $\Theta$ is more informative than $O$ alone. Make sure anyway that you don't confuse the asymptotic behavior of the algorithm complexity, and that of its worst-case complexity. E.g. the running-time of QuickSort ...
The odd-even rule does not require a half-line from the test point, any continuous curve can do. If there is a curve from the point that goes to infinity without meeting the polygon boundary, then the point is outside in the ordinary sense. In that case, the number of intersections is zero, an even number, so the od...
The odd-even rule does not require a half-line from the test point, any continuous curve can do (you can deform any area of the plane). If there is a curve from the point that goes to infinity without meeting the polygon boundary, then the point is outside *in the ordinary sense*. In that case, the number of interse...
O(f(n)) is also used when there is no simple function that your runtime is close to. For example: Find the smallest prime factor of n by trial division, finishing when a factor is found: There are O(n^1/2) tests if you divide by all integers up to the square root of n. But for even n there is only one test, and similar...
public static void main(String args[]) { int[][] metrix = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}; /* index pattern Top-Right: 0,2 0,1 1,2 0,0 1,1 2,2 1,0 2,1 2,0 Bottom-Left 2,0 1,0 2,1 0,0 1,1 2,2 ...
{"Voters":[{"Id":153572,"DisplayName":"Jugal Panchal"}]}
Here is a possible approach. Enumerate lengths in increasing order (length 0, length 1, length). For each length, enumerate all strings in lexicographic order, as follows. Let's take length 4 as illustration. First, check whether any member of $L$ has any substring of the form `a???` (where `?` is a wildcard that ...
{"Voters":[{"Id":153572,"DisplayName":"Jugal Panchal"}]}
Suppose we want to prove by induction that $f(n) \in \Theta(g(n))$. How should the induction proof be set up? I'm tempted to say that the base case should prove that $f(1) \in \Theta(g(1))$ and the inductive step should be to prove that if $f(k) \in \Theta(g(k))$ for some $k\in\mathbb N$, then $f(k+1) \in \Theta(g(k+1)...
Proving an asymptotic bound with induction
|asymptotics|landau-notation|mathematical-analysis|