id
int64
1
141k
title
stringlengths
15
150
body
stringlengths
45
28.5k
tags
stringlengths
1
102
label
int64
1
1
text
stringlengths
128
28.6k
source
stringclasses
1 value
1,692
Prove fingerprinting
<p>Let $a \neq b$ be two integers from the interval $[1, 2^n].$ Let $p$ be a random prime with $ 1 \le p \le n^c.$ Prove that&#xA;$$\text{Pr}_{p \in \mathsf{Primes}}\{a \equiv b \pmod{p}\} \le c \ln(n)/(n^{c-1}).$$</p>&#xA;&#xA;<p>Hint: As a consequence of the prime number theorem, exactly $n/ \ln(n) \pm o(n/\ln(n))$ many numbers from $\{ 1, \ldots, n \}$ are prime.</p>&#xA;&#xA;<p>Conclusion: we can compress $n$ bits to $O(\log(n))$ bits and get a quite small false-positive rate.</p>&#xA;&#xA;<p>My question is how can i proove that $$\text{Pr}_{p \in \mathsf{Primes}}\{a \equiv b \pmod{p}\} \le c \ln(n)/(n^{c-1})$$?</p>&#xA;
probability theory information theory coding theory number theory
1
Prove fingerprinting -- (probability theory information theory coding theory number theory) <p>Let $a \neq b$ be two integers from the interval $[1, 2^n].$ Let $p$ be a random prime with $ 1 \le p \le n^c.$ Prove that&#xA;$$\text{Pr}_{p \in \mathsf{Primes}}\{a \equiv b \pmod{p}\} \le c \ln(n)/(n^{c-1}).$$</p>&#xA;&#xA;<p>Hint: As a consequence of the prime number theorem, exactly $n/ \ln(n) \pm o(n/\ln(n))$ many numbers from $\{ 1, \ldots, n \}$ are prime.</p>&#xA;&#xA;<p>Conclusion: we can compress $n$ bits to $O(\log(n))$ bits and get a quite small false-positive rate.</p>&#xA;&#xA;<p>My question is how can i proove that $$\text{Pr}_{p \in \mathsf{Primes}}\{a \equiv b \pmod{p}\} \le c \ln(n)/(n^{c-1})$$?</p>&#xA;
habedi/stack-exchange-dataset
1,697
Are there undecidable properties of non-turing-complete automata?
<p>Are there undecidable properties of linear bounded automata (avoiding the empty set language trick)? What about for a deterministic finite automaton? (put aside intractability). </p>&#xA;&#xA;<p>I would like to get an example (if possible) of an undecidable problem that is defined <em>without using Turing machines</em> explicitly.</p>&#xA;&#xA;<p>Is Turing completeness of a model necessary to support uncomputable problems?</p>&#xA;
computability automata undecidability
1
Are there undecidable properties of non-turing-complete automata? -- (computability automata undecidability) <p>Are there undecidable properties of linear bounded automata (avoiding the empty set language trick)? What about for a deterministic finite automaton? (put aside intractability). </p>&#xA;&#xA;<p>I would like to get an example (if possible) of an undecidable problem that is defined <em>without using Turing machines</em> explicitly.</p>&#xA;&#xA;<p>Is Turing completeness of a model necessary to support uncomputable problems?</p>&#xA;
habedi/stack-exchange-dataset
1,700
What is meant by interrupts in the context of operating systems?
<p>I've decided to read <a href="http://rads.stackoverflow.com/amzn/click/0470128720" rel="noreferrer">Operating Systems Concepts</a> by Silberschatz, Galvin Gagne (8th edition) over the summer. I've gotten to a topic that's confusing me - interrupts and their role as it relates to operating systems. </p>&#xA;&#xA;<p>The text says that an operating system will begin a first process such as "init" and then wait for an "event" to occur and this event is usually signaled by an interrupt. The text also says that the interrupt can come from either the hardware or the software. How does this work, in a little more detail? Is the operating system driven by interrupts? </p>&#xA;&#xA;<p>I am just looking for some big picture understanding. </p>&#xA;
operating systems computer architecture process scheduling
1
What is meant by interrupts in the context of operating systems? -- (operating systems computer architecture process scheduling) <p>I've decided to read <a href="http://rads.stackoverflow.com/amzn/click/0470128720" rel="noreferrer">Operating Systems Concepts</a> by Silberschatz, Galvin Gagne (8th edition) over the summer. I've gotten to a topic that's confusing me - interrupts and their role as it relates to operating systems. </p>&#xA;&#xA;<p>The text says that an operating system will begin a first process such as "init" and then wait for an "event" to occur and this event is usually signaled by an interrupt. The text also says that the interrupt can come from either the hardware or the software. How does this work, in a little more detail? Is the operating system driven by interrupts? </p>&#xA;&#xA;<p>I am just looking for some big picture understanding. </p>&#xA;
habedi/stack-exchange-dataset
1,706
Why is this example a regular language?
<p>Consider this example (taken from this document: <a href="http://www.cs.nott.ac.uk/~txa/g51mal/notes-3x.pdf" rel="nofollow">Showing that language is not regular</a>):</p>&#xA;&#xA;<p>$$L = \{1^n \mid n\text{ is even}\} $$</p>&#xA;&#xA;<p>According to the Pumping Lemma, a language $L$ is regular if :</p>&#xA;&#xA;<ul>&#xA;<li>$y \ne ε$</li>&#xA;<li>$|xy| \lt n$</li>&#xA;<li>$\forall k \in N, xy^kz \in L$</li>&#xA;</ul>&#xA;&#xA;<p>In the above example, $n$ must be even. Suppose we have $n = 4$, we can express: $$xy^kz$$ such that: $x = 1$, $z = 1$, and with $k = 2$, we have $y^k = y^2 = 11$, so we get the string $1111$. However, since all $k$ must be satisfied, if $k = 1$, the string is $111$, it does not belong to $L$. Yet, I was told that the above example is a regular language. How can it be?</p>&#xA;
formal languages regular languages proof techniques
1
Why is this example a regular language? -- (formal languages regular languages proof techniques) <p>Consider this example (taken from this document: <a href="http://www.cs.nott.ac.uk/~txa/g51mal/notes-3x.pdf" rel="nofollow">Showing that language is not regular</a>):</p>&#xA;&#xA;<p>$$L = \{1^n \mid n\text{ is even}\} $$</p>&#xA;&#xA;<p>According to the Pumping Lemma, a language $L$ is regular if :</p>&#xA;&#xA;<ul>&#xA;<li>$y \ne ε$</li>&#xA;<li>$|xy| \lt n$</li>&#xA;<li>$\forall k \in N, xy^kz \in L$</li>&#xA;</ul>&#xA;&#xA;<p>In the above example, $n$ must be even. Suppose we have $n = 4$, we can express: $$xy^kz$$ such that: $x = 1$, $z = 1$, and with $k = 2$, we have $y^k = y^2 = 11$, so we get the string $1111$. However, since all $k$ must be satisfied, if $k = 1$, the string is $111$, it does not belong to $L$. Yet, I was told that the above example is a regular language. How can it be?</p>&#xA;
habedi/stack-exchange-dataset
1,710
Organisation and Architecture of Quantum Computers
<p>What are devices and their interconnections used alongwith Quantum Processors? Are they compatible with hardware devices like Cache, RAM, Disks of current computers?</p>&#xA;
computer architecture quantum computing
1
Organisation and Architecture of Quantum Computers -- (computer architecture quantum computing) <p>What are devices and their interconnections used alongwith Quantum Processors? Are they compatible with hardware devices like Cache, RAM, Disks of current computers?</p>&#xA;
habedi/stack-exchange-dataset
1,712
Randomized String Searching
<p>I need to detect whether a binary pattern $P$ of length $m$ occurs in a binary text $T$ of length $n$ where $m &lt; n$.</p>&#xA;&#xA;<p>I want to state an algorithm that runs in time $O(n)$ where we assume that arithmetic operations on $O(\log_2 n)$ bit numbers can be executed in constant time. The algorithm should accept with probability $1$ whenever $P$ is a substring of $T$ and reject with probability of at least $1 - \frac{1}{n}$ otherwise.</p>&#xA;&#xA;<p>I think fingerprinting could help here. But I can't get it.</p>&#xA;
algorithms strings searching probabilistic algorithms
1
Randomized String Searching -- (algorithms strings searching probabilistic algorithms) <p>I need to detect whether a binary pattern $P$ of length $m$ occurs in a binary text $T$ of length $n$ where $m &lt; n$.</p>&#xA;&#xA;<p>I want to state an algorithm that runs in time $O(n)$ where we assume that arithmetic operations on $O(\log_2 n)$ bit numbers can be executed in constant time. The algorithm should accept with probability $1$ whenever $P$ is a substring of $T$ and reject with probability of at least $1 - \frac{1}{n}$ otherwise.</p>&#xA;&#xA;<p>I think fingerprinting could help here. But I can't get it.</p>&#xA;
habedi/stack-exchange-dataset
1,726
how do you prove that SAT is NP-complete?
<p>As it is, how do you prove that SAT is NP-complete?</p>&#xA;&#xA;<p>I know what it means by NP-complete, so I do not need an explanation on that.</p>&#xA;&#xA;<p>What I want to know is how do you know that one problem, such as SAT, is NP-complete without resorting to reduction to other problems such as hamiltonian problem or whatever.</p>&#xA;
complexity theory satisfiability
1
how do you prove that SAT is NP-complete? -- (complexity theory satisfiability) <p>As it is, how do you prove that SAT is NP-complete?</p>&#xA;&#xA;<p>I know what it means by NP-complete, so I do not need an explanation on that.</p>&#xA;&#xA;<p>What I want to know is how do you know that one problem, such as SAT, is NP-complete without resorting to reduction to other problems such as hamiltonian problem or whatever.</p>&#xA;
habedi/stack-exchange-dataset
1,731
Proving that recursively enumerable languages are closed against taking prefixes
<p>Define $\mathrm{Prefix} (L) = \{x\mid \exists y .xy \in L \}$. I'd love your help with proving that $\mathsf{RE}$ languages are closed under $\mathrm{Prefix}$.</p>&#xA;&#xA;<p>I know that recursively enumerable languages are formal languages for which there exists a Turing machine that will halt and accept when presented with any string in the language as input, but may either halt and reject or loop forever when presented with a string not in the language.</p>&#xA;&#xA;<p>Any help for how should I approach to this kind of a proof?</p>&#xA;
formal languages turing machines closure properties
1
Proving that recursively enumerable languages are closed against taking prefixes -- (formal languages turing machines closure properties) <p>Define $\mathrm{Prefix} (L) = \{x\mid \exists y .xy \in L \}$. I'd love your help with proving that $\mathsf{RE}$ languages are closed under $\mathrm{Prefix}$.</p>&#xA;&#xA;<p>I know that recursively enumerable languages are formal languages for which there exists a Turing machine that will halt and accept when presented with any string in the language as input, but may either halt and reject or loop forever when presented with a string not in the language.</p>&#xA;&#xA;<p>Any help for how should I approach to this kind of a proof?</p>&#xA;
habedi/stack-exchange-dataset
1,740
DFA with limited states
<p>Lets $L_z \ := \{ a^i b^i c^i : 0 \leq i &lt; z \}$</p>&#xA;&#xA;<p>$\{a,b,c\} \in \sum^*$</p>&#xA;&#xA;<p>there is a DFA with $\frac{z(z+1)}{2}+1$ states - How can I prove this?</p>&#xA;&#xA;<p>And I need largest possible number $n_z$, for which i can prove that every NFA, which accepts $L_z$, have $n_z$ states, at least!</p>&#xA;&#xA;<p>But first I need to show that $n_z = \frac{z(z+1)}{2}$&#xA; right?</p>&#xA;
formal languages regular languages automata finite automata
1
DFA with limited states -- (formal languages regular languages automata finite automata) <p>Lets $L_z \ := \{ a^i b^i c^i : 0 \leq i &lt; z \}$</p>&#xA;&#xA;<p>$\{a,b,c\} \in \sum^*$</p>&#xA;&#xA;<p>there is a DFA with $\frac{z(z+1)}{2}+1$ states - How can I prove this?</p>&#xA;&#xA;<p>And I need largest possible number $n_z$, for which i can prove that every NFA, which accepts $L_z$, have $n_z$ states, at least!</p>&#xA;&#xA;<p>But first I need to show that $n_z = \frac{z(z+1)}{2}$&#xA; right?</p>&#xA;
habedi/stack-exchange-dataset
1,745
Recursion for runtime of divide and conquer algorithms
<p>A divide and conquer algorithm's work at a specific level can be simplified into the equation:</p>&#xA;&#xA;<p>$\qquad \displaystyle O\left(n^d\right) \cdot \left(\frac{a}{b^d}\right)^k$</p>&#xA;&#xA;<p>where $n$ is the size of the problem, $a$ is the number of sub problems, $b$ is the factor the size of the problem is broken down by at each recursion, $k$ is the level, and $d$ is the exponent for Big O notation (linear, exponential etc.).</p>&#xA;&#xA;<p>The book claims if the ratio is greater than one the sum of work is given by the last term on the last level, but if it is less than one the sum of work is given by the first term of the first level. Could someone explain why this is true?</p>&#xA;
algorithm analysis asymptotics runtime analysis recursion mathematical analysis
1
Recursion for runtime of divide and conquer algorithms -- (algorithm analysis asymptotics runtime analysis recursion mathematical analysis) <p>A divide and conquer algorithm's work at a specific level can be simplified into the equation:</p>&#xA;&#xA;<p>$\qquad \displaystyle O\left(n^d\right) \cdot \left(\frac{a}{b^d}\right)^k$</p>&#xA;&#xA;<p>where $n$ is the size of the problem, $a$ is the number of sub problems, $b$ is the factor the size of the problem is broken down by at each recursion, $k$ is the level, and $d$ is the exponent for Big O notation (linear, exponential etc.).</p>&#xA;&#xA;<p>The book claims if the ratio is greater than one the sum of work is given by the last term on the last level, but if it is less than one the sum of work is given by the first term of the first level. Could someone explain why this is true?</p>&#xA;
habedi/stack-exchange-dataset
1,753
Non-regular Languages?
<blockquote>&#xA; <p><strong>Possible Duplicate:</strong><br>&#xA; <a href="https://cs.stackexchange.com/questions/1031/how-to-prove-that-a-language-is-not-regular">How to prove that a language is not regular?</a> </p>&#xA;</blockquote>&#xA;&#xA;&#xA;&#xA;<p>Why $L_a$ and $L_b$ are not reguluar?</p>&#xA;&#xA;<p>$L_a = \{ e^i f^{n-i} g^j h^{n-j} : n \in N, 1 \leq i, j \leq n \}$. </p>&#xA;&#xA;<p>$L_b= \{nm^{i_1} nm^{i_2}...bn^{i_z}: z \in N, (i_1,...,i_n) \in N^z, 1 \leq j \leq z, i_j ≠ j \}$.</p>&#xA;
formal languages regular languages finite automata
1
Non-regular Languages? -- (formal languages regular languages finite automata) <blockquote>&#xA; <p><strong>Possible Duplicate:</strong><br>&#xA; <a href="https://cs.stackexchange.com/questions/1031/how-to-prove-that-a-language-is-not-regular">How to prove that a language is not regular?</a> </p>&#xA;</blockquote>&#xA;&#xA;&#xA;&#xA;<p>Why $L_a$ and $L_b$ are not reguluar?</p>&#xA;&#xA;<p>$L_a = \{ e^i f^{n-i} g^j h^{n-j} : n \in N, 1 \leq i, j \leq n \}$. </p>&#xA;&#xA;<p>$L_b= \{nm^{i_1} nm^{i_2}...bn^{i_z}: z \in N, (i_1,...,i_n) \in N^z, 1 \leq j \leq z, i_j ≠ j \}$.</p>&#xA;
habedi/stack-exchange-dataset
1,754
Explain $\log_2(n)$ squared asymptotic run-time for naive nested parallel CREW PRAM mergesort
<p>On from Page 1 of <a href="http://www.inf.ed.ac.uk/teaching/courses/dapa/note3.pdf" rel="nofollow">these lecture notes</a> it is stated in the final paragraph of the section titled CREW Mergesort:</p>&#xA;&#xA;<blockquote>&#xA; <p>Each such step (in a sequence of $\Theta(\log_2\ n)$ steps) takes&#xA; time $\Theta(\log_2\ s)$ with a sequence length of $s$. Summing these, we&#xA; obtain an overall run time of $\Theta((\log_2\ n)^2)$ for $n$&#xA; processors, which is not quite (but almost!) cost-optimal.</p>&#xA;</blockquote>&#xA;&#xA;<p>Can anyone show explicitly how the sum mentioned is calculated and the squared log result arrived at?</p>&#xA;
algorithms complexity theory parallel computing
1
Explain $\log_2(n)$ squared asymptotic run-time for naive nested parallel CREW PRAM mergesort -- (algorithms complexity theory parallel computing) <p>On from Page 1 of <a href="http://www.inf.ed.ac.uk/teaching/courses/dapa/note3.pdf" rel="nofollow">these lecture notes</a> it is stated in the final paragraph of the section titled CREW Mergesort:</p>&#xA;&#xA;<blockquote>&#xA; <p>Each such step (in a sequence of $\Theta(\log_2\ n)$ steps) takes&#xA; time $\Theta(\log_2\ s)$ with a sequence length of $s$. Summing these, we&#xA; obtain an overall run time of $\Theta((\log_2\ n)^2)$ for $n$&#xA; processors, which is not quite (but almost!) cost-optimal.</p>&#xA;</blockquote>&#xA;&#xA;<p>Can anyone show explicitly how the sum mentioned is calculated and the squared log result arrived at?</p>&#xA;
habedi/stack-exchange-dataset
1,762
Counting trees (order matters)
<p>As a follow up to this <a href="https://cs.stackexchange.com/questions/368/counting-binary-trees">question</a> (the number of rooted binary trees of size n), how many possible binary trees can you have if the nodes are now labeled, so that abc is different than bac cab etc ? In other words, order matters. Certainly it will be much more than the Catalan number.</p>&#xA;&#xA;<p>What would the problem be if you have n-ary trees instead of binary ? </p>&#xA;&#xA;<p>Are these known problems? reference ? </p>&#xA;
binary trees combinatorics trees
1
Counting trees (order matters) -- (binary trees combinatorics trees) <p>As a follow up to this <a href="https://cs.stackexchange.com/questions/368/counting-binary-trees">question</a> (the number of rooted binary trees of size n), how many possible binary trees can you have if the nodes are now labeled, so that abc is different than bac cab etc ? In other words, order matters. Certainly it will be much more than the Catalan number.</p>&#xA;&#xA;<p>What would the problem be if you have n-ary trees instead of binary ? </p>&#xA;&#xA;<p>Are these known problems? reference ? </p>&#xA;
habedi/stack-exchange-dataset
1,771
Why is a regular language called 'regular'?
<p>I have just completed the first chapter of the <a href="http://www-math.mit.edu/~sipser/book.html"><em>Introduction to the Theory of Computation</em></a> by <em>Michael Sipser</em> which explains the basics of finite automata. </p>&#xA;&#xA;<p>He defines a regular language as anything that can be described by a finite automata. But I could not find where he explains why a regular language is called "regular?" What is the origin of the term "regular" in this context?</p>&#xA;&#xA;<p>NOTE: I am a novice so please try to explain in simple terms!</p>&#xA;
formal languages regular languages terminology finite automata history
1
Why is a regular language called 'regular'? -- (formal languages regular languages terminology finite automata history) <p>I have just completed the first chapter of the <a href="http://www-math.mit.edu/~sipser/book.html"><em>Introduction to the Theory of Computation</em></a> by <em>Michael Sipser</em> which explains the basics of finite automata. </p>&#xA;&#xA;<p>He defines a regular language as anything that can be described by a finite automata. But I could not find where he explains why a regular language is called "regular?" What is the origin of the term "regular" in this context?</p>&#xA;&#xA;<p>NOTE: I am a novice so please try to explain in simple terms!</p>&#xA;
habedi/stack-exchange-dataset
1,774
How do I classify my emulator input optimization problem, and with which algorithm should I approach it?
<p>Due to the nature of the question, I have to include lots of background information (because my question is: how do I narrow this down?) That said, it can be summarized (to the best of my knowledge) as:</p>&#xA;&#xA;<p><strong>What methods exist to find local optimums on extremely large combinatorial search spaces?</strong></p>&#xA;&#xA;<h2>Background</h2>&#xA;&#xA;<p>In the tool-assisted superplay community we look to provide specially-crafted (not generated in real-time) input to a video game console or emulator in order to minimize some cost (usually time-to-completion). The way this is currently done is by playing the game frame-by-frame and specifying the input for each frame, often redoing parts of the run many times (for example, the <a href="http://tasvideos.org/2020M.html">recently published</a> run for <em>The Legend of Zelda: Ocarina of Time</em> has a total of 198,590 retries).</p>&#xA;&#xA;<p><strong>Making these runs obtain their goal usually comes down to two main factors: route-planning and traversal.</strong> The former is much more "creative" than the latter.</p>&#xA;&#xA;<p>Route-planning is determining which way the player should navigate overall to complete the game, and is often the most important part of the run. This is analogous to choosing which sorting method to use, for example. The best bubble sort in the world simply isn't going to outperform a quick-sort on 1 million elements.</p>&#xA;&#xA;<p>In the desire for perfection, however, traversal (how the route is carried out) is also a huge factor. Continuing the analogy, this is how the sorting algorithm is implemented. Some routes can't even be performed without very specific frames of input. This is the most tedious process of tool-assisting and is what makes the production of a completed run takes months or even years. It's not a <em>difficult</em> process (to a human) because it comes down to trying different variations of the same idea until one is deemed best, but humans can only try so many variations in their attention-span. The application of machines to this task seems proper here.</p>&#xA;&#xA;<p><strong>My goal now is to try to automate the traversal process in general for the Nintendo 64 system</strong>. The search space for this problem is <em>far</em> too large to attack with a brute-force approach. An n-frame segment of an N64 run has 2<sup>30n</sup> possible inputs, meaning a mere 30 frames of input (a second at 30FPS) has 2<sup>900</sup> possible inputs; it would be impossible to test these potential solutions, let alone those for a full two-hour run.</p>&#xA;&#xA;<p>However, I'm not interested in attempting (or rather, am not going to even try to attempt) total global optimization of a full run. Rather, <strong>I would like to, given an initial input, approximate the <em>local</em> optimum for a particular <em>segment</em> of a run (or the nearest <em>n</em> local optimums, for a sort of semi-global optimization)</strong>. That is, given a route and an initial traversal of that route: search the neighbors of that traversal to minimize cost, but don't degenerate into trying all the cases that could solve the problem.</p>&#xA;&#xA;<p>My program should therefore take a starting state, an input stream, an evaluation function, and output the local optimum by minimizing the result of the evaluation.</p>&#xA;&#xA;<h2>Current State</h2>&#xA;&#xA;<p>Currently I have all the framework taken care of. This includes evaluating an input stream via manipulation of the emulator, setup and teardown, configuration, etc. And as a placeholder of sorts, the optimizer is a very basic genetic algorithm. It simply evaluates a population of input streams, stores/replaces the winner, and generates a new population by mutating the winner stream. This process continues until some arbitrary criteria is met, like time or generation number.</p>&#xA;&#xA;<p><strong>Note that the slowest part of this program will be, by far, the evaluation of an input stream</strong>. This is because this involves emulating the game for <em>n</em> frames. (If I had the time I'd write my own emulator that provided hooks into this kind of stuff, but for now I'm left with synthesizing messages and modifying memory for an existing emulator from another process.) On my main computer, which is fairly modern, evaluating 200 frames takes roughly 14 seconds. As such, I'd prefer an algorithm (given the choice) that minimizes the number of function evaluations.</p>&#xA;&#xA;<p>I've created a system in the framework that manages emulators concurrently. As such <strong>I can evaluate a number of streams at once</strong> with a linear performance scale, but practically speaking the number of running emulators can only be 8 to 32 (and 32 is really pushing it) before system performance deteriorates. This means (given the choice), an algorithm which can do processing while an evaluation is taking place would be highly beneficial, because the optimizer can do some heavy-lifting while it waits on an evaluation.</p>&#xA;&#xA;<p>As a test, my evaluation function (for the game <em>Banjo Kazooie</em>) was to sum, per frame, the distance from the player to a goal point. This meant the optimal solution was to get as close to that point as quickly as possible. Limiting mutation to the analog stick only, it took a day to get an <em>okay</em> solution. (This was before I implemented concurrency.)</p>&#xA;&#xA;<p>After adding concurrency, I enabled mutation of A button presses and did the same evaluation function at an area that required jumping. With 24 emulators running it took roughly 1 hour to reach the goal from an initially blank input stream, but would probably need to run for days to get to anything close to optimal.</p>&#xA;&#xA;<h2>Problem</h2>&#xA;&#xA;<p><strong>The issue I'm facing is that I don't know enough about the mathematical optimization field to know how to properly model my optimization problem</strong>! I can roughly follow the conceptual idea of many algorithms as described on Wikipedia, for example, but I don't know how to categorize my problem or select the state-of-the-art algorithm for that category.</p>&#xA;&#xA;<p><strong>From what I can tell, I have a combinatorial problem with an extremely large neighborhood</strong>. On top of that, <strong>the evaluation function is extremely discontinuous, has no gradient, and has many plateaus</strong>. Also, there aren't many constraints, though I'll gladly add the ability to express them if it helps solve the problem; I would like to allow specifying that the Start button should not be used, for example, but this is not the general case.</p>&#xA;&#xA;<h2>Question</h2>&#xA;&#xA;<p><strong>So my question is: how do I model this? What kind of optimization problem am I trying to solve? Which algorithm am I suppose to use?</strong> I'm not afraid of reading research papers so let me know what I should read!</p>&#xA;&#xA;<p>Intuitively, a genetic algorithm couldn't be the best, because it doesn't really seem to learn. For example, if pressing Start seems to <em>always</em> make the evaluation worse (because it pauses the game), there should be some sort of designer or brain that learns: "pressing Start at any point is useless." But even this goal isn't as trivial as it sounds, because sometimes pressing start <em>is</em> optimal, such as in so-called "pause backward-long-jumps" in <em>Super Mario 64</em>! Here the brain would have to learn a much more complex pattern: "pressing Start is useless except when the player is in this very specific state <em>and will continue with some combination of button presses</em>." </p>&#xA;&#xA;<p>It seems like I should (or the machine could learn to) represent input in some other fashion more suited to modification. Per-frame input seems too granular, because what's really needed are "actions", which may span several frames...yet many discoveries are made on a frame-by-frame basis, so I can't totally rule it out (the aforementioned pause backward-long-jump requires frame-level precision). It also seems like the fact that input is processed serially should be something that can be capitalized on, but I'm not sure how.</p>&#xA;&#xA;<p><strong>Currently I'm reading about (Reactive) Tabu Search, Very Large-scale Neighborhood Search, Teaching-learning-based Optimization, and Ant Colony Optimization.</strong></p>&#xA;&#xA;<p>Is this problem simply too hard to tackle with anything other than random genetic algorithms? Or is it actually a trivial problem that was solved long ago? Thanks for reading and thanks in advance for any responses.</p>&#xA;
reference request machine learning combinatorics optimization search problem
1
How do I classify my emulator input optimization problem, and with which algorithm should I approach it? -- (reference request machine learning combinatorics optimization search problem) <p>Due to the nature of the question, I have to include lots of background information (because my question is: how do I narrow this down?) That said, it can be summarized (to the best of my knowledge) as:</p>&#xA;&#xA;<p><strong>What methods exist to find local optimums on extremely large combinatorial search spaces?</strong></p>&#xA;&#xA;<h2>Background</h2>&#xA;&#xA;<p>In the tool-assisted superplay community we look to provide specially-crafted (not generated in real-time) input to a video game console or emulator in order to minimize some cost (usually time-to-completion). The way this is currently done is by playing the game frame-by-frame and specifying the input for each frame, often redoing parts of the run many times (for example, the <a href="http://tasvideos.org/2020M.html">recently published</a> run for <em>The Legend of Zelda: Ocarina of Time</em> has a total of 198,590 retries).</p>&#xA;&#xA;<p><strong>Making these runs obtain their goal usually comes down to two main factors: route-planning and traversal.</strong> The former is much more "creative" than the latter.</p>&#xA;&#xA;<p>Route-planning is determining which way the player should navigate overall to complete the game, and is often the most important part of the run. This is analogous to choosing which sorting method to use, for example. The best bubble sort in the world simply isn't going to outperform a quick-sort on 1 million elements.</p>&#xA;&#xA;<p>In the desire for perfection, however, traversal (how the route is carried out) is also a huge factor. Continuing the analogy, this is how the sorting algorithm is implemented. Some routes can't even be performed without very specific frames of input. This is the most tedious process of tool-assisting and is what makes the production of a completed run takes months or even years. It's not a <em>difficult</em> process (to a human) because it comes down to trying different variations of the same idea until one is deemed best, but humans can only try so many variations in their attention-span. The application of machines to this task seems proper here.</p>&#xA;&#xA;<p><strong>My goal now is to try to automate the traversal process in general for the Nintendo 64 system</strong>. The search space for this problem is <em>far</em> too large to attack with a brute-force approach. An n-frame segment of an N64 run has 2<sup>30n</sup> possible inputs, meaning a mere 30 frames of input (a second at 30FPS) has 2<sup>900</sup> possible inputs; it would be impossible to test these potential solutions, let alone those for a full two-hour run.</p>&#xA;&#xA;<p>However, I'm not interested in attempting (or rather, am not going to even try to attempt) total global optimization of a full run. Rather, <strong>I would like to, given an initial input, approximate the <em>local</em> optimum for a particular <em>segment</em> of a run (or the nearest <em>n</em> local optimums, for a sort of semi-global optimization)</strong>. That is, given a route and an initial traversal of that route: search the neighbors of that traversal to minimize cost, but don't degenerate into trying all the cases that could solve the problem.</p>&#xA;&#xA;<p>My program should therefore take a starting state, an input stream, an evaluation function, and output the local optimum by minimizing the result of the evaluation.</p>&#xA;&#xA;<h2>Current State</h2>&#xA;&#xA;<p>Currently I have all the framework taken care of. This includes evaluating an input stream via manipulation of the emulator, setup and teardown, configuration, etc. And as a placeholder of sorts, the optimizer is a very basic genetic algorithm. It simply evaluates a population of input streams, stores/replaces the winner, and generates a new population by mutating the winner stream. This process continues until some arbitrary criteria is met, like time or generation number.</p>&#xA;&#xA;<p><strong>Note that the slowest part of this program will be, by far, the evaluation of an input stream</strong>. This is because this involves emulating the game for <em>n</em> frames. (If I had the time I'd write my own emulator that provided hooks into this kind of stuff, but for now I'm left with synthesizing messages and modifying memory for an existing emulator from another process.) On my main computer, which is fairly modern, evaluating 200 frames takes roughly 14 seconds. As such, I'd prefer an algorithm (given the choice) that minimizes the number of function evaluations.</p>&#xA;&#xA;<p>I've created a system in the framework that manages emulators concurrently. As such <strong>I can evaluate a number of streams at once</strong> with a linear performance scale, but practically speaking the number of running emulators can only be 8 to 32 (and 32 is really pushing it) before system performance deteriorates. This means (given the choice), an algorithm which can do processing while an evaluation is taking place would be highly beneficial, because the optimizer can do some heavy-lifting while it waits on an evaluation.</p>&#xA;&#xA;<p>As a test, my evaluation function (for the game <em>Banjo Kazooie</em>) was to sum, per frame, the distance from the player to a goal point. This meant the optimal solution was to get as close to that point as quickly as possible. Limiting mutation to the analog stick only, it took a day to get an <em>okay</em> solution. (This was before I implemented concurrency.)</p>&#xA;&#xA;<p>After adding concurrency, I enabled mutation of A button presses and did the same evaluation function at an area that required jumping. With 24 emulators running it took roughly 1 hour to reach the goal from an initially blank input stream, but would probably need to run for days to get to anything close to optimal.</p>&#xA;&#xA;<h2>Problem</h2>&#xA;&#xA;<p><strong>The issue I'm facing is that I don't know enough about the mathematical optimization field to know how to properly model my optimization problem</strong>! I can roughly follow the conceptual idea of many algorithms as described on Wikipedia, for example, but I don't know how to categorize my problem or select the state-of-the-art algorithm for that category.</p>&#xA;&#xA;<p><strong>From what I can tell, I have a combinatorial problem with an extremely large neighborhood</strong>. On top of that, <strong>the evaluation function is extremely discontinuous, has no gradient, and has many plateaus</strong>. Also, there aren't many constraints, though I'll gladly add the ability to express them if it helps solve the problem; I would like to allow specifying that the Start button should not be used, for example, but this is not the general case.</p>&#xA;&#xA;<h2>Question</h2>&#xA;&#xA;<p><strong>So my question is: how do I model this? What kind of optimization problem am I trying to solve? Which algorithm am I suppose to use?</strong> I'm not afraid of reading research papers so let me know what I should read!</p>&#xA;&#xA;<p>Intuitively, a genetic algorithm couldn't be the best, because it doesn't really seem to learn. For example, if pressing Start seems to <em>always</em> make the evaluation worse (because it pauses the game), there should be some sort of designer or brain that learns: "pressing Start at any point is useless." But even this goal isn't as trivial as it sounds, because sometimes pressing start <em>is</em> optimal, such as in so-called "pause backward-long-jumps" in <em>Super Mario 64</em>! Here the brain would have to learn a much more complex pattern: "pressing Start is useless except when the player is in this very specific state <em>and will continue with some combination of button presses</em>." </p>&#xA;&#xA;<p>It seems like I should (or the machine could learn to) represent input in some other fashion more suited to modification. Per-frame input seems too granular, because what's really needed are "actions", which may span several frames...yet many discoveries are made on a frame-by-frame basis, so I can't totally rule it out (the aforementioned pause backward-long-jump requires frame-level precision). It also seems like the fact that input is processed serially should be something that can be capitalized on, but I'm not sure how.</p>&#xA;&#xA;<p><strong>Currently I'm reading about (Reactive) Tabu Search, Very Large-scale Neighborhood Search, Teaching-learning-based Optimization, and Ant Colony Optimization.</strong></p>&#xA;&#xA;<p>Is this problem simply too hard to tackle with anything other than random genetic algorithms? Or is it actually a trivial problem that was solved long ago? Thanks for reading and thanks in advance for any responses.</p>&#xA;
habedi/stack-exchange-dataset
1,779
$L(M) = L$ where $M$ is a $TM$ that moves only to the right side so $L$ is regular
<p>Suppose that $L(M) = L$ where $M$ is a $TM$ that moves only to the right side.</p>&#xA;&#xA;<p>I need to Show that $L$ is regular.</p>&#xA;&#xA;<p>I'd relly like some help, I tried to think of any way to prove it but I didn't reach to any smart conclusion. what is it about the only side right moves and the regularity? </p>&#xA;
formal languages computability turing machines regular languages computation models
1
$L(M) = L$ where $M$ is a $TM$ that moves only to the right side so $L$ is regular -- (formal languages computability turing machines regular languages computation models) <p>Suppose that $L(M) = L$ where $M$ is a $TM$ that moves only to the right side.</p>&#xA;&#xA;<p>I need to Show that $L$ is regular.</p>&#xA;&#xA;<p>I'd relly like some help, I tried to think of any way to prove it but I didn't reach to any smart conclusion. what is it about the only side right moves and the regularity? </p>&#xA;
habedi/stack-exchange-dataset
1,789
Quicksort to find median?
<p>Why is the worst scenario $\mathcal{O}\left(n^2\right)$ when using quicksort to find the median of a set of numbers?</p>&#xA;&#xA;<ul>&#xA;<li><p>If your algorithm continually picks a number larger than or smaller than <em>all</em> numbers in the list wouldn't your algorithm fail? For example if the list of numbers are:</p>&#xA;&#xA;<p>$S = (12,75,82,34,55,15,51)$</p>&#xA;&#xA;<p>and you keep picking numbers greater than $82$ or less than $12$ to create sublists with, wouldn't your set always remain the same size?</p></li>&#xA;<li><p>If your algorithm continually picks a number that creates sublists of $1$ why is the worst case scenario $\mathcal{O}\left(n^2\right)$? Wouldn't efficiency be linear considering that according to the <a href="http://en.wikipedia.org/wiki/Master_theorem" rel="nofollow">Master Theorem</a>, $d&gt;\log_b a$?* (and therefore be $\mathcal{O}\left(n^d\right)$ or specifically in this case $\mathcal{O}\left(n\right)$)</p></li>&#xA;</ul>&#xA;&#xA;<p>*Where $d$ is the efficiency exponent (i.e. linear, exponential etc.), $b$ is the factor the size of problem is reduced by at each iteration, $a$ is the number of subproblems and $k$ is the level. Full ratio: $T(n) = \mathcal{O}\left(n^d\right) * (\frac{a}{b^d})^k$</p>&#xA;
algorithms algorithm analysis search algorithms
1
Quicksort to find median? -- (algorithms algorithm analysis search algorithms) <p>Why is the worst scenario $\mathcal{O}\left(n^2\right)$ when using quicksort to find the median of a set of numbers?</p>&#xA;&#xA;<ul>&#xA;<li><p>If your algorithm continually picks a number larger than or smaller than <em>all</em> numbers in the list wouldn't your algorithm fail? For example if the list of numbers are:</p>&#xA;&#xA;<p>$S = (12,75,82,34,55,15,51)$</p>&#xA;&#xA;<p>and you keep picking numbers greater than $82$ or less than $12$ to create sublists with, wouldn't your set always remain the same size?</p></li>&#xA;<li><p>If your algorithm continually picks a number that creates sublists of $1$ why is the worst case scenario $\mathcal{O}\left(n^2\right)$? Wouldn't efficiency be linear considering that according to the <a href="http://en.wikipedia.org/wiki/Master_theorem" rel="nofollow">Master Theorem</a>, $d&gt;\log_b a$?* (and therefore be $\mathcal{O}\left(n^d\right)$ or specifically in this case $\mathcal{O}\left(n\right)$)</p></li>&#xA;</ul>&#xA;&#xA;<p>*Where $d$ is the efficiency exponent (i.e. linear, exponential etc.), $b$ is the factor the size of problem is reduced by at each iteration, $a$ is the number of subproblems and $k$ is the level. Full ratio: $T(n) = \mathcal{O}\left(n^d\right) * (\frac{a}{b^d})^k$</p>&#xA;
habedi/stack-exchange-dataset
1,796
Fast Poisson quantile computation
<p>I am seeking a fast algorithm to compute the following function, a quantile of the <a href="http://en.wikipedia.org/wiki/Poisson_distribution" rel="nofollow">Poisson distribution</a>:&#xA;$$f(n, \lambda) = e^{-\lambda} \sum_{k=0}^{n} \frac{\lambda^k}{k!} $$</p>&#xA;&#xA;<p>I can think of an algorithm in $O(n)$, but considering the structure of the series, there is probably a $O(1)$ solution (or at least a good $O(1)$ approximation). Any take?</p>&#xA;
algorithms numerical analysis
1
Fast Poisson quantile computation -- (algorithms numerical analysis) <p>I am seeking a fast algorithm to compute the following function, a quantile of the <a href="http://en.wikipedia.org/wiki/Poisson_distribution" rel="nofollow">Poisson distribution</a>:&#xA;$$f(n, \lambda) = e^{-\lambda} \sum_{k=0}^{n} \frac{\lambda^k}{k!} $$</p>&#xA;&#xA;<p>I can think of an algorithm in $O(n)$, but considering the structure of the series, there is probably a $O(1)$ solution (or at least a good $O(1)$ approximation). Any take?</p>&#xA;
habedi/stack-exchange-dataset
1,797
Key secrecy vs Algorithm secrecy
<p>it's a well known statement that </p>&#xA;&#xA;<p>"<em>Cryptographic security must rely on a secret key instead of a secret algorithm</em>."</p>&#xA;&#xA;<p>I would like to ask about some details about it. <em>And which are their differences?</em></p>&#xA;&#xA;<p>I see the obvious thing that for a multi user system, generating a key is overwhelmingly easier than generating a distinct alghorithm for every user pair, (and even for a single pair of users one could argue that updating the key is easier)</p>&#xA;&#xA;<p>But, Is it the only argument? </p>&#xA;&#xA;<p>I mean, if we define </p>&#xA;&#xA;<pre><code>AlgorithmA = AlgorithmX + key A&#xA;AlgorithmB = AlgorithmX + key B&#xA;</code></pre>&#xA;&#xA;<p>Then a change on the key is not different from a change in the algorithm.</p>&#xA;&#xA;<p>The only different I see is that for a new pair of users/keys</p>&#xA;&#xA;<ul>&#xA;<li><p><em>Most of</em> the Algorithm structure <strong>remains constant</strong> in the case of secret key,</p></li>&#xA;<li><p><em>Most of</em> Algorithm structure <strong>need to change</strong> in the case of secret Algorithm</p></li>&#xA;</ul>&#xA;&#xA;<p>But where is the limit? "most of" meaning?</p>&#xA;&#xA;<p>I would like to have more views and clues to understand why this distinction is usually mentioned.</p>&#xA;
cryptography security encryption
1
Key secrecy vs Algorithm secrecy -- (cryptography security encryption) <p>it's a well known statement that </p>&#xA;&#xA;<p>"<em>Cryptographic security must rely on a secret key instead of a secret algorithm</em>."</p>&#xA;&#xA;<p>I would like to ask about some details about it. <em>And which are their differences?</em></p>&#xA;&#xA;<p>I see the obvious thing that for a multi user system, generating a key is overwhelmingly easier than generating a distinct alghorithm for every user pair, (and even for a single pair of users one could argue that updating the key is easier)</p>&#xA;&#xA;<p>But, Is it the only argument? </p>&#xA;&#xA;<p>I mean, if we define </p>&#xA;&#xA;<pre><code>AlgorithmA = AlgorithmX + key A&#xA;AlgorithmB = AlgorithmX + key B&#xA;</code></pre>&#xA;&#xA;<p>Then a change on the key is not different from a change in the algorithm.</p>&#xA;&#xA;<p>The only different I see is that for a new pair of users/keys</p>&#xA;&#xA;<ul>&#xA;<li><p><em>Most of</em> the Algorithm structure <strong>remains constant</strong> in the case of secret key,</p></li>&#xA;<li><p><em>Most of</em> Algorithm structure <strong>need to change</strong> in the case of secret Algorithm</p></li>&#xA;</ul>&#xA;&#xA;<p>But where is the limit? "most of" meaning?</p>&#xA;&#xA;<p>I would like to have more views and clues to understand why this distinction is usually mentioned.</p>&#xA;
habedi/stack-exchange-dataset
1,801
From FACTOR To KNAPSACK
<ol>&#xA;<li><p>If there were an algorithm that factored in polynomial time by means of examining each possible factor of a complex number efficiently, could one not also use this algorithm to solve unbounded knapsack problems since two factors can be viewed as one value, say within the set for the knapsack problem, and the other being the number of copies of the first factor?</p>&#xA;&#xA;<p>FACTOR 15; 3, 5</p>&#xA;&#xA;<p>Unbounded KNAPSACK with value of 15 and the set of all integers; {5,5,5} andor {3,3,3,3,3}</p></li>&#xA;<li><p>Would this mean FACTOR was NP-Complete?</p></li>&#xA;<li><p>Would solving unbounded knapsack problems in polynomial time in this way prove P=NP?</p></li>&#xA;</ol>&#xA;
complexity theory np complete integers knapsack problems
1
From FACTOR To KNAPSACK -- (complexity theory np complete integers knapsack problems) <ol>&#xA;<li><p>If there were an algorithm that factored in polynomial time by means of examining each possible factor of a complex number efficiently, could one not also use this algorithm to solve unbounded knapsack problems since two factors can be viewed as one value, say within the set for the knapsack problem, and the other being the number of copies of the first factor?</p>&#xA;&#xA;<p>FACTOR 15; 3, 5</p>&#xA;&#xA;<p>Unbounded KNAPSACK with value of 15 and the set of all integers; {5,5,5} andor {3,3,3,3,3}</p></li>&#xA;<li><p>Would this mean FACTOR was NP-Complete?</p></li>&#xA;<li><p>Would solving unbounded knapsack problems in polynomial time in this way prove P=NP?</p></li>&#xA;</ol>&#xA;
habedi/stack-exchange-dataset
1,803
Extracting non-duplicate cells in a particular matrix with repeated entries
<p>Consider a board of $n$ x $n$ cells, where $n = 2k, k≥2$. Each of the numbers from $S = \left\{1,...,\frac{n^2}{2}\right\}$ is written to two cells so that each cell contains exactly one number.</p>&#xA;&#xA;<p>How can I show that $n$ cells $c_{i, j}$ can be chosen with one cell per row and one cell per column such that no pair of cells contains the same number.</p>&#xA;&#xA;<p>This was an example problem for an exam I'm studying for. I tried it now for several hours but I can't get it right. I think random permutations can help here but I am not sure.</p>&#xA;
combinatorics probability theory
1
Extracting non-duplicate cells in a particular matrix with repeated entries -- (combinatorics probability theory) <p>Consider a board of $n$ x $n$ cells, where $n = 2k, k≥2$. Each of the numbers from $S = \left\{1,...,\frac{n^2}{2}\right\}$ is written to two cells so that each cell contains exactly one number.</p>&#xA;&#xA;<p>How can I show that $n$ cells $c_{i, j}$ can be chosen with one cell per row and one cell per column such that no pair of cells contains the same number.</p>&#xA;&#xA;<p>This was an example problem for an exam I'm studying for. I tried it now for several hours but I can't get it right. I think random permutations can help here but I am not sure.</p>&#xA;
habedi/stack-exchange-dataset
1,809
Probabilistic test of matrix multiplication with one-sided error
<p>Given three matrices $A, B,C \in \mathbb{Z}^{n \times n}$ we want to test whether $AB \neq C$. Assume that the arithmetic operations $+$ and $-$ take constant time when applied to numbers from $\mathbb{Z}$.</p>&#xA;&#xA;<p>How can I state an algorithm with one-sided error that runs in $O(n^2)$ time and prove its correctness?</p>&#xA;&#xA;<p>I tried it now for several hours but I can't get it right. I think I have to use the fact that for any $x \in \mathbb{Z}^n$ at most half of the vectors $s \in S = \left\{1, 0\right\}^n$ satisfy $x \cdot s = 0$, where $x \cdot s$ denotes the scalar product$\sum_{i=1}^{n} x_is_i$.</p>&#xA;
algorithms probabilistic algorithms matrices linear algebra
1
Probabilistic test of matrix multiplication with one-sided error -- (algorithms probabilistic algorithms matrices linear algebra) <p>Given three matrices $A, B,C \in \mathbb{Z}^{n \times n}$ we want to test whether $AB \neq C$. Assume that the arithmetic operations $+$ and $-$ take constant time when applied to numbers from $\mathbb{Z}$.</p>&#xA;&#xA;<p>How can I state an algorithm with one-sided error that runs in $O(n^2)$ time and prove its correctness?</p>&#xA;&#xA;<p>I tried it now for several hours but I can't get it right. I think I have to use the fact that for any $x \in \mathbb{Z}^n$ at most half of the vectors $s \in S = \left\{1, 0\right\}^n$ satisfy $x \cdot s = 0$, where $x \cdot s$ denotes the scalar product$\sum_{i=1}^{n} x_is_i$.</p>&#xA;
habedi/stack-exchange-dataset
1,810
Are there NP problems, not in P and not NP Complete?
<p>Are there any known problems in $\mathsf{NP}$ (and not in $\mathsf{P}$) that aren't $\mathsf{NP}$ Complete? My understanding is that there are no currently known problems where this is the case, but it hasn't been ruled out as a possibility. </p>&#xA;&#xA;<p>If there is a problem that is $\mathsf{NP}$ (and not $\mathsf{P}$) but not $\mathsf{NP\text{-}complete}$, would this be a result of no existing isomorphism between instances of that problem and the $\mathsf{NP\text{-}complete}$ set? If this case, how would we know that the $\mathsf{NP}$ problem isn't 'harder' than what we currently identify as the $\mathsf{NP\text{-}complete}$ set?</p>&#xA;
complexity theory np complete p vs np
1
Are there NP problems, not in P and not NP Complete? -- (complexity theory np complete p vs np) <p>Are there any known problems in $\mathsf{NP}$ (and not in $\mathsf{P}$) that aren't $\mathsf{NP}$ Complete? My understanding is that there are no currently known problems where this is the case, but it hasn't been ruled out as a possibility. </p>&#xA;&#xA;<p>If there is a problem that is $\mathsf{NP}$ (and not $\mathsf{P}$) but not $\mathsf{NP\text{-}complete}$, would this be a result of no existing isomorphism between instances of that problem and the $\mathsf{NP\text{-}complete}$ set? If this case, how would we know that the $\mathsf{NP}$ problem isn't 'harder' than what we currently identify as the $\mathsf{NP\text{-}complete}$ set?</p>&#xA;
habedi/stack-exchange-dataset
1,816
Is there a typed SKI calculus?
<p>Most of us know the correspondence between <a href="http://en.wikipedia.org/wiki/Combinatory_logic">combinatory logic</a> and <a href="http://en.wikipedia.org/wiki/Lambda_calculus">lambda calculus</a>. But I've never seen (maybe I haven't looked deep enough) the equivalent of "typed combinators", corresponding to the simply typed lambda calculus. Does such thing exist? Where could one find information about it?</p>&#xA;
reference request logic lambda calculus type theory combinatory logic
1
Is there a typed SKI calculus? -- (reference request logic lambda calculus type theory combinatory logic) <p>Most of us know the correspondence between <a href="http://en.wikipedia.org/wiki/Combinatory_logic">combinatory logic</a> and <a href="http://en.wikipedia.org/wiki/Lambda_calculus">lambda calculus</a>. But I've never seen (maybe I haven't looked deep enough) the equivalent of "typed combinators", corresponding to the simply typed lambda calculus. Does such thing exist? Where could one find information about it?</p>&#xA;
habedi/stack-exchange-dataset
1,825
Maximum Enclosing Circle of a Given Radius
<p>I try to find an approach to the following problem:</p>&#xA;&#xA;<blockquote>&#xA; <p>Given the set of point $S$ and radius $r$, find the center point of circle, such that the circle contains the maximum number of points from the set. The running time should be $O(n^2)$.</p>&#xA;</blockquote>&#xA;&#xA;<p>At first it seemed to be something similar to smallest enclosing circle problem, that easily can be solved in $O(n^2)$. The idea was to set an arbitrary center and encircle all point of $S$. Next, step by step, replace the circle to touch the left/rightmost points and shrink the circle to the given radius, obviously, this is not going to work.</p>&#xA;
algorithms computational geometry
1
Maximum Enclosing Circle of a Given Radius -- (algorithms computational geometry) <p>I try to find an approach to the following problem:</p>&#xA;&#xA;<blockquote>&#xA; <p>Given the set of point $S$ and radius $r$, find the center point of circle, such that the circle contains the maximum number of points from the set. The running time should be $O(n^2)$.</p>&#xA;</blockquote>&#xA;&#xA;<p>At first it seemed to be something similar to smallest enclosing circle problem, that easily can be solved in $O(n^2)$. The idea was to set an arbitrary center and encircle all point of $S$. Next, step by step, replace the circle to touch the left/rightmost points and shrink the circle to the given radius, obviously, this is not going to work.</p>&#xA;
habedi/stack-exchange-dataset
1,828
Polytime and polyspace algorithm for determining the leading intersection of n discrete monotonic functions
<p>Some frontmatter: I'm a recreational computer scientist and employed software engineer. So, pardon if this prompt seems somewhat out of left field -- I routinely play with mathematical simulcra and open problems when I have nothing better to do. </p>&#xA;&#xA;<p>While playing with the <a href="http://en.wikipedia.org/wiki/Riemann_hypothesis">Riemann hypothesis</a>, I determined that the <a href="http://en.wikipedia.org/wiki/Prime_gap">prime gap</a> can be reduced to a recurrence relation based on the intersection of all $n-1$ complementary functions formed by the multiples of each previous prime number (keen observers will note this is a generalization of the <a href="http://en.wikipedia.org/wiki/Sieve_of_Eratosthenes">Sieve of Eratosthenes</a>). If this makes absolutely no sense to you, don't worry -- it's still frontmatter.</p>&#xA;&#xA;<p>Seeing how these functions related, I realized that the next instance of each prime can be reduced to the first intersection of these functions, recurring forward infinitely. However, I could not determine if this is tractable in polytime and polyspace. Thus: <strong>what I'm looking for is an algorithm that can determine the first intersection of $n$ discrete (and, if applicable, monotonic) functions in polynomial time and space. If no such algorithm currently exists or can exist, a terse proof or reference stating so is sufficient.</strong> </p>&#xA;&#xA;<p>The closest I can find so far is <a href="http://en.wikipedia.org/wiki/Dykstra%27s_projection_algorithm">Dykstra's projection algorithm</a> (yes, that's R. L. Dykstra, not <a href="http://en.wikipedia.org/wiki/Edsger_Dijkstra">Edsger Dijkstra</a>), which I believe reduces itself to a problem of <a href="http://en.wikipedia.org/wiki/Linear_programming#Integer_unknowns">integer programming</a> and is, therefore, NP-hard. Similarly, if one performs a transitive set intersection of all of the applicable points (as they're currently understood to be bounded), we must still constrain ourselves to exponential space for our recurrence due to the current weak bound of $\ln(m)$ primes for any real $m$ (and therefore, $e^n$ space for each prime $n$).</p>&#xA;&#xA;<p>Globally, I'm wondering if my understanding of the reduction of the problem is wrong. I don't expect to solve the Riemann hypothesis (or any deep, open problem in this space) any time soon. Rather, I'm seeking to learn more about it by playing with the problem, and I've hit a snag in my research.</p>&#xA;
algorithms reference request discrete mathematics
1
Polytime and polyspace algorithm for determining the leading intersection of n discrete monotonic functions -- (algorithms reference request discrete mathematics) <p>Some frontmatter: I'm a recreational computer scientist and employed software engineer. So, pardon if this prompt seems somewhat out of left field -- I routinely play with mathematical simulcra and open problems when I have nothing better to do. </p>&#xA;&#xA;<p>While playing with the <a href="http://en.wikipedia.org/wiki/Riemann_hypothesis">Riemann hypothesis</a>, I determined that the <a href="http://en.wikipedia.org/wiki/Prime_gap">prime gap</a> can be reduced to a recurrence relation based on the intersection of all $n-1$ complementary functions formed by the multiples of each previous prime number (keen observers will note this is a generalization of the <a href="http://en.wikipedia.org/wiki/Sieve_of_Eratosthenes">Sieve of Eratosthenes</a>). If this makes absolutely no sense to you, don't worry -- it's still frontmatter.</p>&#xA;&#xA;<p>Seeing how these functions related, I realized that the next instance of each prime can be reduced to the first intersection of these functions, recurring forward infinitely. However, I could not determine if this is tractable in polytime and polyspace. Thus: <strong>what I'm looking for is an algorithm that can determine the first intersection of $n$ discrete (and, if applicable, monotonic) functions in polynomial time and space. If no such algorithm currently exists or can exist, a terse proof or reference stating so is sufficient.</strong> </p>&#xA;&#xA;<p>The closest I can find so far is <a href="http://en.wikipedia.org/wiki/Dykstra%27s_projection_algorithm">Dykstra's projection algorithm</a> (yes, that's R. L. Dykstra, not <a href="http://en.wikipedia.org/wiki/Edsger_Dijkstra">Edsger Dijkstra</a>), which I believe reduces itself to a problem of <a href="http://en.wikipedia.org/wiki/Linear_programming#Integer_unknowns">integer programming</a> and is, therefore, NP-hard. Similarly, if one performs a transitive set intersection of all of the applicable points (as they're currently understood to be bounded), we must still constrain ourselves to exponential space for our recurrence due to the current weak bound of $\ln(m)$ primes for any real $m$ (and therefore, $e^n$ space for each prime $n$).</p>&#xA;&#xA;<p>Globally, I'm wondering if my understanding of the reduction of the problem is wrong. I don't expect to solve the Riemann hypothesis (or any deep, open problem in this space) any time soon. Rather, I'm seeking to learn more about it by playing with the problem, and I've hit a snag in my research.</p>&#xA;
habedi/stack-exchange-dataset
1,852
How to prove that a constrained version of 3SAT in which no literal can occur more than once, is solvable in polynomial time?
<p>I'm trying to work out an assignment (taken from the book <a href="http://www.cs.berkeley.edu/~vazirani/algorithms.html">Algorithms - by S. Dasgupta, C.H. Papadimitriou, and U.V. Vazirani</a>, Chap 8, problem 8.6a), and I'm paraphrasing what it states:</p>&#xA;&#xA;<blockquote>&#xA; <p>Given that 3SAT remains NP-complete even when restricted to formulas in which&#xA; each literal appears at most twice, show that if each literal appears at most once, then the problem is solvable in polynomial time.</p>&#xA;</blockquote>&#xA;&#xA;<p>I attempted to solve this by separating the clauses into multiple groups: </p>&#xA;&#xA;<ol>&#xA;<li>Clauses which did not have any variable in common with the rest of the clauses</li>&#xA;<li>Clauses which had only 1 variable in common</li>&#xA;<li>Clauses which had 2 variables in common</li>&#xA;<li>Clauses which had all 3 variables in common</li>&#xA;</ol>&#xA;&#xA;<p>My reasoning was attempted along the lines that the # of such groups is finite (due to the imposed restriction of no literal being present more than once), and we could try to satisfy the most restricted group first (group 4) and then substitute the result in the lesser restricted groups (3, 2 and then 1), but I realized that this wasn't quite getting me anywhere, as this doesn't differ much from the case for the constrained version of 3SAT in which each literal can appear at most twice, which has been proven to be NP-complete. </p>&#xA;&#xA;<p>I tried searching online for any hints/solutions, but all I could get was <a href="http://www.cs.rpi.edu/~moorthy/Courses/CSCI2300/lab2011-9.html">this link</a>, in which the stated hint didn't make sufficient sense to me, which I'm reproducing verbatim here:</p>&#xA;&#xA;<blockquote>&#xA; <p>Hint: Since each literal appears at most once, convert this problem to 2SAT problem - hence polynomial time, if a literal $x_i$ appears in clause $C_j$ and complement of $x_i$ (i.e., $\overline{x_i}$) in clause $C_k$, construct a new clause clause $C_j \lor \overline{C_k}$.</p>&#xA;</blockquote>&#xA;&#xA;<p>Both $C_j$ and $C_k$ have three literals each - I didn't get how I should go about converting it into 2SAT by doing $C_j \lor \overline{C_k}$ (or $\overline{C_j \lor C_k}$ if I read it incorrectly).</p>&#xA;&#xA;<p>Any help in either decrypting the hint, or providing a path I can explore would be really appreciated.</p>&#xA;
complexity theory satisfiability 3 sat
1
How to prove that a constrained version of 3SAT in which no literal can occur more than once, is solvable in polynomial time? -- (complexity theory satisfiability 3 sat) <p>I'm trying to work out an assignment (taken from the book <a href="http://www.cs.berkeley.edu/~vazirani/algorithms.html">Algorithms - by S. Dasgupta, C.H. Papadimitriou, and U.V. Vazirani</a>, Chap 8, problem 8.6a), and I'm paraphrasing what it states:</p>&#xA;&#xA;<blockquote>&#xA; <p>Given that 3SAT remains NP-complete even when restricted to formulas in which&#xA; each literal appears at most twice, show that if each literal appears at most once, then the problem is solvable in polynomial time.</p>&#xA;</blockquote>&#xA;&#xA;<p>I attempted to solve this by separating the clauses into multiple groups: </p>&#xA;&#xA;<ol>&#xA;<li>Clauses which did not have any variable in common with the rest of the clauses</li>&#xA;<li>Clauses which had only 1 variable in common</li>&#xA;<li>Clauses which had 2 variables in common</li>&#xA;<li>Clauses which had all 3 variables in common</li>&#xA;</ol>&#xA;&#xA;<p>My reasoning was attempted along the lines that the # of such groups is finite (due to the imposed restriction of no literal being present more than once), and we could try to satisfy the most restricted group first (group 4) and then substitute the result in the lesser restricted groups (3, 2 and then 1), but I realized that this wasn't quite getting me anywhere, as this doesn't differ much from the case for the constrained version of 3SAT in which each literal can appear at most twice, which has been proven to be NP-complete. </p>&#xA;&#xA;<p>I tried searching online for any hints/solutions, but all I could get was <a href="http://www.cs.rpi.edu/~moorthy/Courses/CSCI2300/lab2011-9.html">this link</a>, in which the stated hint didn't make sufficient sense to me, which I'm reproducing verbatim here:</p>&#xA;&#xA;<blockquote>&#xA; <p>Hint: Since each literal appears at most once, convert this problem to 2SAT problem - hence polynomial time, if a literal $x_i$ appears in clause $C_j$ and complement of $x_i$ (i.e., $\overline{x_i}$) in clause $C_k$, construct a new clause clause $C_j \lor \overline{C_k}$.</p>&#xA;</blockquote>&#xA;&#xA;<p>Both $C_j$ and $C_k$ have three literals each - I didn't get how I should go about converting it into 2SAT by doing $C_j \lor \overline{C_k}$ (or $\overline{C_j \lor C_k}$ if I read it incorrectly).</p>&#xA;&#xA;<p>Any help in either decrypting the hint, or providing a path I can explore would be really appreciated.</p>&#xA;
habedi/stack-exchange-dataset
1,859
Rule of thumb to know if a problem could be NP-complete
<p>This question was inspired by <a href="https://stackoverflow.com/questions/10589995/algorithm-have-a-set-of-points-g-that-can-see-other-points-c-need-an-al/10590173#comment13716914_10590173">a comment on StackOverflow</a>.</p>&#xA;&#xA;<p>Apart from knowing NP-complete problems of the Garey Johnson book, and many others; is there a rule of thumb to know if a problem looks like an NP-complete one?</p>&#xA;&#xA;<p>I am not looking for something rigorous, but to something that works in most cases.</p>&#xA;&#xA;<p>Of course, every time we have to prove that a problem is NP-complete, or a slight variant of an NP-complete one; but before rushing to the proof it would be great to have certain confidence in the positive result of the proof.</p>&#xA;
complexity theory np complete intuition
1
Rule of thumb to know if a problem could be NP-complete -- (complexity theory np complete intuition) <p>This question was inspired by <a href="https://stackoverflow.com/questions/10589995/algorithm-have-a-set-of-points-g-that-can-see-other-points-c-need-an-al/10590173#comment13716914_10590173">a comment on StackOverflow</a>.</p>&#xA;&#xA;<p>Apart from knowing NP-complete problems of the Garey Johnson book, and many others; is there a rule of thumb to know if a problem looks like an NP-complete one?</p>&#xA;&#xA;<p>I am not looking for something rigorous, but to something that works in most cases.</p>&#xA;&#xA;<p>Of course, every time we have to prove that a problem is NP-complete, or a slight variant of an NP-complete one; but before rushing to the proof it would be great to have certain confidence in the positive result of the proof.</p>&#xA;
habedi/stack-exchange-dataset
1,864
Hoare triple for assignment P{x/E} x:=E {P}
<p>I am trying to understand Hoare logic presented at Wikipedia,&#xA;<a href="http://en.wikipedia.org/wiki/Hoare_logic" rel="nofollow">Hoare logic at Wikipedia</a>&#xA;Apparently, if I understand correctly, a Hoare triple $$\{P\}~ C ~\{Q\}$$ means</p>&#xA;&#xA;<blockquote>&#xA; <p>if P just before C, then Q holds immediately after C, as long as C terminates. (A)</p>&#xA;</blockquote>&#xA;&#xA;<p>However, the assignment axiom schema seems to be interpreted in a different way:</p>&#xA;&#xA;<p>$$\frac{}{\{P[x/E]\} ~~x:=E~~ \{P\}}$$</p>&#xA;&#xA;<p>The wikipedia says:</p>&#xA;&#xA;<p>The assignment axiom means that the truth of $\{P[x/E]\}$ is equivalent to the after-assignment truth of $\{P\}$. Thus were $\{P[x/E]\}$ true prior to the assignment, by the assignment axiom, then $\{P\}$ would be true subsequent to which. Conversely, were $\{P[x/E]\}$ false prior to the assignment statement, $\{P\}$ must then be false consequently.</p>&#xA;&#xA;<p>I think the Hoare triple only affirms that if P[x/E] before x:=E, then P(x) holds after x:=E. It DOES NOT affirm, by its definition, that if P(x) holds after x:=E, then P[x/E] holds before x:=E. </p>&#xA;&#xA;<p>My naive question is, how can $\{P[x/E]\}$ before the assignment can be equivalent to $\{P\}$ after the assignment? Does this contradict with point (A) at the beginning of my post?</p>&#xA;
logic programming languages semantics hoare logic software verification
1
Hoare triple for assignment P{x/E} x:=E {P} -- (logic programming languages semantics hoare logic software verification) <p>I am trying to understand Hoare logic presented at Wikipedia,&#xA;<a href="http://en.wikipedia.org/wiki/Hoare_logic" rel="nofollow">Hoare logic at Wikipedia</a>&#xA;Apparently, if I understand correctly, a Hoare triple $$\{P\}~ C ~\{Q\}$$ means</p>&#xA;&#xA;<blockquote>&#xA; <p>if P just before C, then Q holds immediately after C, as long as C terminates. (A)</p>&#xA;</blockquote>&#xA;&#xA;<p>However, the assignment axiom schema seems to be interpreted in a different way:</p>&#xA;&#xA;<p>$$\frac{}{\{P[x/E]\} ~~x:=E~~ \{P\}}$$</p>&#xA;&#xA;<p>The wikipedia says:</p>&#xA;&#xA;<p>The assignment axiom means that the truth of $\{P[x/E]\}$ is equivalent to the after-assignment truth of $\{P\}$. Thus were $\{P[x/E]\}$ true prior to the assignment, by the assignment axiom, then $\{P\}$ would be true subsequent to which. Conversely, were $\{P[x/E]\}$ false prior to the assignment statement, $\{P\}$ must then be false consequently.</p>&#xA;&#xA;<p>I think the Hoare triple only affirms that if P[x/E] before x:=E, then P(x) holds after x:=E. It DOES NOT affirm, by its definition, that if P(x) holds after x:=E, then P[x/E] holds before x:=E. </p>&#xA;&#xA;<p>My naive question is, how can $\{P[x/E]\}$ before the assignment can be equivalent to $\{P\}$ after the assignment? Does this contradict with point (A) at the beginning of my post?</p>&#xA;
habedi/stack-exchange-dataset
1,883
Reconstructing Graphs from Degree Distribution
<p>Given a degree distribution, how fast can we construct a graph that follows the given degree distribution? A link or algorithm sketch would be good. The algorithm should report a "no" incase no graph can be constructed and any one example if multiple graphs can be constructed.</p>&#xA;
algorithms graphs
1
Reconstructing Graphs from Degree Distribution -- (algorithms graphs) <p>Given a degree distribution, how fast can we construct a graph that follows the given degree distribution? A link or algorithm sketch would be good. The algorithm should report a "no" incase no graph can be constructed and any one example if multiple graphs can be constructed.</p>&#xA;
habedi/stack-exchange-dataset
1,887
Why isn't this undecidable problem in NP?
<p>Clearly there aren't any undecidable problems in NP. However, according to <a href="http://en.wikipedia.org/wiki/NP_%28complexity%29">Wikipedia</a>:</p>&#xA;&#xA;<blockquote>&#xA; <p>NP is the set of all decision problems for which the instances where the answer is "yes" have [.. proofs that are] verifiable in polynomial time by a deterministic Turing machine.</p>&#xA; &#xA; <p>[...]</p>&#xA; &#xA; <p>A problem is said to be in NP if and only if there exists a verifier for the problem that executes in polynomial time.</p>&#xA;</blockquote>&#xA;&#xA;<p>Now consider the following problem:</p>&#xA;&#xA;<blockquote>&#xA; <p>Given a <a href="http://en.wikipedia.org/wiki/Diophantine_equation">Diophantine equation</a>, does it have any integer solutions?</p>&#xA;</blockquote>&#xA;&#xA;<p>Given a solution, it's easy to verify in polynomial time that it really <em>is</em> a solution: just plug the numbers into the equation. Thus, the problem is in NP. However, <em>solving</em> this problem is famously <a href="http://en.wikipedia.org/wiki/Hilbert%27s_tenth_problem">known to be undecidable</a>!</p>&#xA;&#xA;<p><em>(Similarly, it seems the halting problem should be in NP, since the "yes"-solution of "this program halts at the N-th step" can be verified in N steps.)</em></p>&#xA;&#xA;<p>Obviously there's something wrong with my understanding, but what is it?</p>&#xA;
complexity theory computability undecidability decision problem
1
Why isn't this undecidable problem in NP? -- (complexity theory computability undecidability decision problem) <p>Clearly there aren't any undecidable problems in NP. However, according to <a href="http://en.wikipedia.org/wiki/NP_%28complexity%29">Wikipedia</a>:</p>&#xA;&#xA;<blockquote>&#xA; <p>NP is the set of all decision problems for which the instances where the answer is "yes" have [.. proofs that are] verifiable in polynomial time by a deterministic Turing machine.</p>&#xA; &#xA; <p>[...]</p>&#xA; &#xA; <p>A problem is said to be in NP if and only if there exists a verifier for the problem that executes in polynomial time.</p>&#xA;</blockquote>&#xA;&#xA;<p>Now consider the following problem:</p>&#xA;&#xA;<blockquote>&#xA; <p>Given a <a href="http://en.wikipedia.org/wiki/Diophantine_equation">Diophantine equation</a>, does it have any integer solutions?</p>&#xA;</blockquote>&#xA;&#xA;<p>Given a solution, it's easy to verify in polynomial time that it really <em>is</em> a solution: just plug the numbers into the equation. Thus, the problem is in NP. However, <em>solving</em> this problem is famously <a href="http://en.wikipedia.org/wiki/Hilbert%27s_tenth_problem">known to be undecidable</a>!</p>&#xA;&#xA;<p><em>(Similarly, it seems the halting problem should be in NP, since the "yes"-solution of "this program halts at the N-th step" can be verified in N steps.)</em></p>&#xA;&#xA;<p>Obviously there's something wrong with my understanding, but what is it?</p>&#xA;
habedi/stack-exchange-dataset
1,901
Common idea in Karatsuba, Gauss and Strassen multiplication
<p>The identities used in multiplication algorithms by</p>&#xA;&#xA;<ul>&#xA;<li><p><a href="http://en.wikipedia.org/wiki/Karatsuba_algorithm#The_basic_step">Karatsuba</a> (integers)</p></li>&#xA;<li><p><a href="http://en.wikipedia.org/wiki/Multiplication_algorithm#Gauss.27s_complex_multiplication_algorithm">Gauss</a> (complex numbers)</p></li>&#xA;<li><p><a href="http://en.wikipedia.org/wiki/Strassen_algorithm">Strassen</a> (matrices)</p></li>&#xA;</ul>&#xA;&#xA;<p>seem very closely related. Is there a common abstract framework/generalization?</p>&#xA;
algorithms matrices
1
Common idea in Karatsuba, Gauss and Strassen multiplication -- (algorithms matrices) <p>The identities used in multiplication algorithms by</p>&#xA;&#xA;<ul>&#xA;<li><p><a href="http://en.wikipedia.org/wiki/Karatsuba_algorithm#The_basic_step">Karatsuba</a> (integers)</p></li>&#xA;<li><p><a href="http://en.wikipedia.org/wiki/Multiplication_algorithm#Gauss.27s_complex_multiplication_algorithm">Gauss</a> (complex numbers)</p></li>&#xA;<li><p><a href="http://en.wikipedia.org/wiki/Strassen_algorithm">Strassen</a> (matrices)</p></li>&#xA;</ul>&#xA;&#xA;<p>seem very closely related. Is there a common abstract framework/generalization?</p>&#xA;
habedi/stack-exchange-dataset
1,905
An oracle to separate NP from coNP
<p>How to prove that $\mathsf{NP}^A \neq \mathsf{coNP}^A$ ? I am just looking for a such oracle TM $M$ and a recursive language $L(M) = L$ for which this holds. </p>&#xA;&#xA;<p>I know the proof where you show that there is an oracle $A$ such that $\mathsf{P}^A \neq \mathsf{NP}^A$ and an oracle $A$ such that $\mathsf{P}^A = \mathsf{NP}^A$. I have a hint that I should find such oracle $A$ by extending the proof of $\mathsf{P}^A \neq \mathsf{NP}^A$ but wherever I search and read, it is "obvious" or "straightforward" everywhere but I just do not see how prove it at all.</p>&#xA;
complexity theory relativization
1
An oracle to separate NP from coNP -- (complexity theory relativization) <p>How to prove that $\mathsf{NP}^A \neq \mathsf{coNP}^A$ ? I am just looking for a such oracle TM $M$ and a recursive language $L(M) = L$ for which this holds. </p>&#xA;&#xA;<p>I know the proof where you show that there is an oracle $A$ such that $\mathsf{P}^A \neq \mathsf{NP}^A$ and an oracle $A$ such that $\mathsf{P}^A = \mathsf{NP}^A$. I have a hint that I should find such oracle $A$ by extending the proof of $\mathsf{P}^A \neq \mathsf{NP}^A$ but wherever I search and read, it is "obvious" or "straightforward" everywhere but I just do not see how prove it at all.</p>&#xA;
habedi/stack-exchange-dataset
1,913
Recurrences and Generating Functions in Algorithms
<p>Combinatorics plays an important role in computer science. We frequently utilize combinatorial methods in both analysis as well as design in algorithms. For example one method for finding a $k$-vertex cover set in a graph might just inspect all $\binom{n}{k}$ possible subsets. While the binomial functions grows exponentially, if $k$ is some fixed constant we end up with a polynomial time algorithm by asymptotic analysis.</p>&#xA;&#xA;<p>Often times real-life problems require more complex combinatorial mechanisms which we may define in terms of recurrences. One famous example is the <a href="http://en.wikipedia.org/wiki/Fibonacci_number">fibonacci sequence</a> (naively) defined as:</p>&#xA;&#xA;<p>$f(n) = \begin{cases}&#xA; 1 &amp; \text{if } n = 1 \\&#xA; 0 &amp; \text{if } n = 0 \\&#xA; f(n-1) + f(n-2) &amp; \text{otherwise}&#xA; \end{cases}&#xA;$</p>&#xA;&#xA;<p>Now computing the value of the $n$th term grows exponentially using this recurrence, but thanks to dynamic programming, we may compute it in linear time. Now, not all recurrences lend themselves to DP (off hand, the factorial function), but it is a potentially exploitable property when defining some count as a recurrence rather than a generating function.</p>&#xA;&#xA;<p>Generating functions are an elegant way to formalize some count for a given structure. Perhaps the most famous is the binomial generating function defined as:</p>&#xA;&#xA;<p>$(x + y)^\alpha = \sum_{k=0}^\infty \binom{\alpha}{k}x^{\alpha - k}y^k$</p>&#xA;&#xA;<p>Luckily this has a closed form solution. Not all generating functions permit such a compact description. </p>&#xA;&#xA;<blockquote>&#xA; <p>Now my question is this: how often are generating functions used in <em>design</em> of algorithms? It is easy to see how they may be exploited to understand the rate of growth required by an algorithm via analysis, but what can they tell us about a problem when creating a method to solve some problem?</p>&#xA;</blockquote>&#xA;&#xA;<p>If many times the same count may be reformulated as a recurrence it may lend itself to dynamic programming, but again perhaps the same generating function has a closed form. So it is not so evenly cut.</p>&#xA;
algorithms algorithm analysis combinatorics
1
Recurrences and Generating Functions in Algorithms -- (algorithms algorithm analysis combinatorics) <p>Combinatorics plays an important role in computer science. We frequently utilize combinatorial methods in both analysis as well as design in algorithms. For example one method for finding a $k$-vertex cover set in a graph might just inspect all $\binom{n}{k}$ possible subsets. While the binomial functions grows exponentially, if $k$ is some fixed constant we end up with a polynomial time algorithm by asymptotic analysis.</p>&#xA;&#xA;<p>Often times real-life problems require more complex combinatorial mechanisms which we may define in terms of recurrences. One famous example is the <a href="http://en.wikipedia.org/wiki/Fibonacci_number">fibonacci sequence</a> (naively) defined as:</p>&#xA;&#xA;<p>$f(n) = \begin{cases}&#xA; 1 &amp; \text{if } n = 1 \\&#xA; 0 &amp; \text{if } n = 0 \\&#xA; f(n-1) + f(n-2) &amp; \text{otherwise}&#xA; \end{cases}&#xA;$</p>&#xA;&#xA;<p>Now computing the value of the $n$th term grows exponentially using this recurrence, but thanks to dynamic programming, we may compute it in linear time. Now, not all recurrences lend themselves to DP (off hand, the factorial function), but it is a potentially exploitable property when defining some count as a recurrence rather than a generating function.</p>&#xA;&#xA;<p>Generating functions are an elegant way to formalize some count for a given structure. Perhaps the most famous is the binomial generating function defined as:</p>&#xA;&#xA;<p>$(x + y)^\alpha = \sum_{k=0}^\infty \binom{\alpha}{k}x^{\alpha - k}y^k$</p>&#xA;&#xA;<p>Luckily this has a closed form solution. Not all generating functions permit such a compact description. </p>&#xA;&#xA;<blockquote>&#xA; <p>Now my question is this: how often are generating functions used in <em>design</em> of algorithms? It is easy to see how they may be exploited to understand the rate of growth required by an algorithm via analysis, but what can they tell us about a problem when creating a method to solve some problem?</p>&#xA;</blockquote>&#xA;&#xA;<p>If many times the same count may be reformulated as a recurrence it may lend itself to dynamic programming, but again perhaps the same generating function has a closed form. So it is not so evenly cut.</p>&#xA;
habedi/stack-exchange-dataset
1,914
Find median of unsorted array in $O(n)$ time
<p>To find the median of an unsorted array, we can make a min-heap in $O(n\log n)$ time for $n$ elements, and then we can extract one by one $n/2$ elements to get the median. But this approach would take $O(n \log n)$ time.</p>&#xA;&#xA;<p>Can we do the same by some method in $O(n)$ time? If we can, then how?</p>&#xA;
algorithms time complexity
1
Find median of unsorted array in $O(n)$ time -- (algorithms time complexity) <p>To find the median of an unsorted array, we can make a min-heap in $O(n\log n)$ time for $n$ elements, and then we can extract one by one $n/2$ elements to get the median. But this approach would take $O(n \log n)$ time.</p>&#xA;&#xA;<p>Can we do the same by some method in $O(n)$ time? If we can, then how?</p>&#xA;
habedi/stack-exchange-dataset
1,915
What is postorder traversal on this simple tree?
<p>Given the following tree: </p>&#xA;&#xA;<p><img src="https://i.stack.imgur.com/GbJzO.png" alt="tree"></p>&#xA;&#xA;<p>Which traversal method would give as result the following output: CDBEA?</p>&#xA;&#xA;<p>The answer in my study guide is <em>Postorder</em>, but I think postorder would output: DEBCA. Am I wrong?</p>&#xA;
algorithms trees
1
What is postorder traversal on this simple tree? -- (algorithms trees) <p>Given the following tree: </p>&#xA;&#xA;<p><img src="https://i.stack.imgur.com/GbJzO.png" alt="tree"></p>&#xA;&#xA;<p>Which traversal method would give as result the following output: CDBEA?</p>&#xA;&#xA;<p>The answer in my study guide is <em>Postorder</em>, but I think postorder would output: DEBCA. Am I wrong?</p>&#xA;
habedi/stack-exchange-dataset
1,917
Vapnik-Chervonenkis Dimension: why cannot four points on a line be shattered by rectangles?
<p>So I'm reading <em>"Introduction to Machine Learning"</em> 2nd edition, by Bishop, et. all. On page 27 they discuss the Vapnik-Chervonenkis Dimension which is,</p>&#xA;&#xA;<blockquote>&#xA; <p><em>"The maximum number of points that can be shattered by H [the hypothesis class] is called the Vapnik-Chervonenkis (VC) Dimension of H, is denoted VC(H) and measures the capacity of H."</em></p>&#xA;</blockquote>&#xA;&#xA;<p>Whereas "shatters" indicates a hypothesis $h \in H$ for a set of N data points such that it separates the positive examples from the negative. In such an example it is said that "H shatters N points".</p>&#xA;&#xA;<p>So far I think I understand this. However, the authors lose me with the following:</p>&#xA;&#xA;<blockquote>&#xA; <p><em>"For example, four points on a line cannot be shattered by rectangles."</em></p>&#xA;</blockquote>&#xA;&#xA;<p>There must be some concept here I'm not fully understanding, because I cannot understand why this is the case. Can anyone explain this to me? </p>&#xA;
machine learning vc dimension
1
Vapnik-Chervonenkis Dimension: why cannot four points on a line be shattered by rectangles? -- (machine learning vc dimension) <p>So I'm reading <em>"Introduction to Machine Learning"</em> 2nd edition, by Bishop, et. all. On page 27 they discuss the Vapnik-Chervonenkis Dimension which is,</p>&#xA;&#xA;<blockquote>&#xA; <p><em>"The maximum number of points that can be shattered by H [the hypothesis class] is called the Vapnik-Chervonenkis (VC) Dimension of H, is denoted VC(H) and measures the capacity of H."</em></p>&#xA;</blockquote>&#xA;&#xA;<p>Whereas "shatters" indicates a hypothesis $h \in H$ for a set of N data points such that it separates the positive examples from the negative. In such an example it is said that "H shatters N points".</p>&#xA;&#xA;<p>So far I think I understand this. However, the authors lose me with the following:</p>&#xA;&#xA;<blockquote>&#xA; <p><em>"For example, four points on a line cannot be shattered by rectangles."</em></p>&#xA;</blockquote>&#xA;&#xA;<p>There must be some concept here I'm not fully understanding, because I cannot understand why this is the case. Can anyone explain this to me? </p>&#xA;
habedi/stack-exchange-dataset
1,918
Preprocess an array for counting an element in a slice (reduction to RMQ?)
<p>Given an array $a_1,\ldots,a_n$ of natural numbers $\leq k$, where $k$ is a constant, I want to answer in $O(1)$ queries of the form: "how many times does $m$ appear in the array between indices $i$ and $j$"?</p>&#xA;&#xA;<p>The array should be preprocessed in linear time. In particular I'd like to know if there's a reduction to Range Minimum Query.</p>&#xA;&#xA;<hr>&#xA;&#xA;<p>This is equivalent to RMQ in the case where $k=1$ and you want to query the number of ones within an interval. So we can use <a href="http://en.wikipedia.org/wiki/Range_Queries#Statement_Of_The_Problem">it</a>.<br>&#xA;<sup>I couldn't answer my own question because of limits of SE.</sup></p>&#xA;
algorithms arrays algorithm design
1
Preprocess an array for counting an element in a slice (reduction to RMQ?) -- (algorithms arrays algorithm design) <p>Given an array $a_1,\ldots,a_n$ of natural numbers $\leq k$, where $k$ is a constant, I want to answer in $O(1)$ queries of the form: "how many times does $m$ appear in the array between indices $i$ and $j$"?</p>&#xA;&#xA;<p>The array should be preprocessed in linear time. In particular I'd like to know if there's a reduction to Range Minimum Query.</p>&#xA;&#xA;<hr>&#xA;&#xA;<p>This is equivalent to RMQ in the case where $k=1$ and you want to query the number of ones within an interval. So we can use <a href="http://en.wikipedia.org/wiki/Range_Queries#Statement_Of_The_Problem">it</a>.<br>&#xA;<sup>I couldn't answer my own question because of limits of SE.</sup></p>&#xA;
habedi/stack-exchange-dataset
1,919
Equality testing of arrays and integers in a procedural language
<p>In terms of references and their implementation on the heap and the stack, how is&#xA;equality testing for arrays different from that for integers? </p>&#xA;&#xA;<p>This is to do with Java programming, if you have a stack and a heap, would equality testing for example <code>j == i</code> be the same for arrays and for integers? I understand that arrays, are stored in the heap and the stack, as it holds bulks of data, but integers are only stored in the stack and referenced in the heap.</p>&#xA;&#xA;<p><img src="https://i.stack.imgur.com/xtIHW.png" alt="this is a picture on how integer variables are stored on the heap and referenced on the heap"></p>&#xA;&#xA;<p>I understand for equality testing <code>j==i</code> (variables) the stack pointer will point to the same location.</p>&#xA;&#xA;<p>I'm confused on how <code>j==i</code> would be different for array and integers.</p>&#xA;&#xA;<p>Could someone explain? </p>&#xA;
programming languages arrays semantics equality memory management
1
Equality testing of arrays and integers in a procedural language -- (programming languages arrays semantics equality memory management) <p>In terms of references and their implementation on the heap and the stack, how is&#xA;equality testing for arrays different from that for integers? </p>&#xA;&#xA;<p>This is to do with Java programming, if you have a stack and a heap, would equality testing for example <code>j == i</code> be the same for arrays and for integers? I understand that arrays, are stored in the heap and the stack, as it holds bulks of data, but integers are only stored in the stack and referenced in the heap.</p>&#xA;&#xA;<p><img src="https://i.stack.imgur.com/xtIHW.png" alt="this is a picture on how integer variables are stored on the heap and referenced on the heap"></p>&#xA;&#xA;<p>I understand for equality testing <code>j==i</code> (variables) the stack pointer will point to the same location.</p>&#xA;&#xA;<p>I'm confused on how <code>j==i</code> would be different for array and integers.</p>&#xA;&#xA;<p>Could someone explain? </p>&#xA;
habedi/stack-exchange-dataset
1,921
Making random sources uniformly distributed
<p>How do I build a random source that outputs the bits 0 and 1 with $prob(0) = prob(1) = 0.5$. We have access to another random source $S$ that outputs $a$ or $b$ with independent probabilities $prob(a)$ and $prob(b) = 1 - prob(a)$ that are unknown to us.</p>&#xA;&#xA;<p>How do I state an algorithm that does the job and that does not consume more than an expected number of&#xA;$(prob(a) \cdot prob(b))^{-1}$ symbols of $S$ between two output bits and prove its correcteness?</p>&#xA;
algorithms probability theory randomized algorithms randomness
1
Making random sources uniformly distributed -- (algorithms probability theory randomized algorithms randomness) <p>How do I build a random source that outputs the bits 0 and 1 with $prob(0) = prob(1) = 0.5$. We have access to another random source $S$ that outputs $a$ or $b$ with independent probabilities $prob(a)$ and $prob(b) = 1 - prob(a)$ that are unknown to us.</p>&#xA;&#xA;<p>How do I state an algorithm that does the job and that does not consume more than an expected number of&#xA;$(prob(a) \cdot prob(b))^{-1}$ symbols of $S$ between two output bits and prove its correcteness?</p>&#xA;
habedi/stack-exchange-dataset
1,922
Deterministic and randomized communication complexity of set equality
<p>Two processors $A, B$ with inputs $a \in \{0, 1\}^n$ (for $A$) and $b \in \{0, 1\}^n$&#xA;(for $B$) want to decide whether $a = b$. $A$ does not know $B$’s input and vice versa.</p>&#xA;&#xA;<p>A can send a message $m(a) \in \{0, 1\}^n$ which $B$ can use to decide $a = b$. The communication and computation rules are called a <em>protocol</em>.</p>&#xA;&#xA;<ul>&#xA;<li>Show that every deterministic protocol must satisfy $|m(a)| \ge n$.</li>&#xA;<li>State a randomized protocol that uses only $O(\log_2n)$ Bits. The protocol should always accept if $a = b$ and accept with probability at most $1/n$ otherwise. Prove its correctness.</li>&#xA;</ul>&#xA;
algorithms probability theory randomized algorithms
1
Deterministic and randomized communication complexity of set equality -- (algorithms probability theory randomized algorithms) <p>Two processors $A, B$ with inputs $a \in \{0, 1\}^n$ (for $A$) and $b \in \{0, 1\}^n$&#xA;(for $B$) want to decide whether $a = b$. $A$ does not know $B$’s input and vice versa.</p>&#xA;&#xA;<p>A can send a message $m(a) \in \{0, 1\}^n$ which $B$ can use to decide $a = b$. The communication and computation rules are called a <em>protocol</em>.</p>&#xA;&#xA;<ul>&#xA;<li>Show that every deterministic protocol must satisfy $|m(a)| \ge n$.</li>&#xA;<li>State a randomized protocol that uses only $O(\log_2n)$ Bits. The protocol should always accept if $a = b$ and accept with probability at most $1/n$ otherwise. Prove its correctness.</li>&#xA;</ul>&#xA;
habedi/stack-exchange-dataset
1,923
Online generation of uniform samples
<p>A source provides a stream of items $x_1, x_2,\dots$ . At each step $n$ we want to save a random sample $S_n \subseteq \{ (x_i, i)|1 \le i \le n\}$ of size $k$, i.e. $S_n$ should be a uniformly chosen sample from all $\tbinom{n}{k}$ possible samples consisting of seen items. So at each step $n \ge k$ we must decide whether to add the next item to $S$ or not. If so we must also decide which of the current items to remove from $S$ .</p>&#xA;&#xA;<p>State an algorithm for the problem. Prove its correctness.</p>&#xA;
algorithms probability theory randomized algorithms randomness online algorithms
1
Online generation of uniform samples -- (algorithms probability theory randomized algorithms randomness online algorithms) <p>A source provides a stream of items $x_1, x_2,\dots$ . At each step $n$ we want to save a random sample $S_n \subseteq \{ (x_i, i)|1 \le i \le n\}$ of size $k$, i.e. $S_n$ should be a uniformly chosen sample from all $\tbinom{n}{k}$ possible samples consisting of seen items. So at each step $n \ge k$ we must decide whether to add the next item to $S$ or not. If so we must also decide which of the current items to remove from $S$ .</p>&#xA;&#xA;<p>State an algorithm for the problem. Prove its correctness.</p>&#xA;
habedi/stack-exchange-dataset
1,936
When do structural hazards occur in pipelined architectures?
<p>I'm looking for some relatively simple examples of when <a href="http://en.wikipedia.org/wiki/Hazard_%28computer_architecture%29#Structural_hazards">structural hazards</a> occur in a pipelined architecture.</p>&#xA;&#xA;<p>The only scenario I can think of is when memory needs to be accessed during different stages of the pipeline (ie, the initial instruction fetch stage and the later memory read/write stage).</p>&#xA;&#xA;<p>I'm thinking that there are many more structural hazards in more complex architectures, such as superscalar. Does it class as a structural hazard when an instruction is dispatched to an execution unit but is queued because the unit is in use?</p>&#xA;&#xA;<p>If this is highly architecture-specific, then just assume MIPS or something similar.</p>&#xA;
computer architecture cpu pipelines
1
When do structural hazards occur in pipelined architectures? -- (computer architecture cpu pipelines) <p>I'm looking for some relatively simple examples of when <a href="http://en.wikipedia.org/wiki/Hazard_%28computer_architecture%29#Structural_hazards">structural hazards</a> occur in a pipelined architecture.</p>&#xA;&#xA;<p>The only scenario I can think of is when memory needs to be accessed during different stages of the pipeline (ie, the initial instruction fetch stage and the later memory read/write stage).</p>&#xA;&#xA;<p>I'm thinking that there are many more structural hazards in more complex architectures, such as superscalar. Does it class as a structural hazard when an instruction is dispatched to an execution unit but is queued because the unit is in use?</p>&#xA;&#xA;<p>If this is highly architecture-specific, then just assume MIPS or something similar.</p>&#xA;
habedi/stack-exchange-dataset
1,940
If a point is a vertex of convex hull
<p>The exercise is </p>&#xA;&#xA;<blockquote>&#xA; <p>Given a set of point $S$ and a point $p$. Decide in $O(n)$ time if $p$ is a vertex of convex polygon formed from points of $S$.</p>&#xA;</blockquote>&#xA;&#xA;<p>The problem is I am a little bit confused with time complexity $O(n)$. The more naive solution would be to construct convex polygon in $O(n\log n)$ and test if $p$ is one of the vertices. </p>&#xA;
algorithms computational geometry
1
If a point is a vertex of convex hull -- (algorithms computational geometry) <p>The exercise is </p>&#xA;&#xA;<blockquote>&#xA; <p>Given a set of point $S$ and a point $p$. Decide in $O(n)$ time if $p$ is a vertex of convex polygon formed from points of $S$.</p>&#xA;</blockquote>&#xA;&#xA;<p>The problem is I am a little bit confused with time complexity $O(n)$. The more naive solution would be to construct convex polygon in $O(n\log n)$ and test if $p$ is one of the vertices. </p>&#xA;
habedi/stack-exchange-dataset
1,949
Use closure properties to transform languages to $L := \{ a^nb^n : n\in \mathbb N \}$
<p>For the purpose of proving that they are not regular, what closure properties can I use to transform the languages</p>&#xA;&#xA;<ol>&#xA;<li>$L_a = \{ a^*cw \mid w \in \{a,b \}^* \land |w|_a = |w|_b \}$ and</li>&#xA;<li>$L_b = \{ab^{i_1}ab^{i_2}\ldots ab^{i_n} \mid i_j∈\mathbb N \land \exists j∈[1,n] \ i_j \not= j \}$</li>&#xA;</ol>&#xA;&#xA;<p>to $L := \{ a^nb^n \mid n\in \mathbb N \}$, respectively?</p>&#xA;&#xA;<p>I tried: </p>&#xA;&#xA;<ol>&#xA;<li><p>$L_a = \{ a^*cw \mid w \in \{a,b \}^* \land |w|_a = |w|_b \}$ </p>&#xA;&#xA;<p>$L_a' = \{ \{a,d\}^*cw \mid w \in \{a,b,d \}^* \land |w|_a + |w|_d = |w|_b \}$ (union?)</p>&#xA;&#xA;<p>$L_a'' = \{ d^*cw \mid w \in \{a,b \}^* \land |w|_a = |w|_b \}$&#xA;(concatenation?)</p>&#xA;&#xA;<p>$L_a''' = \{ w \mid w \in \{a,b \}^* \land |w|_a = |w|_b \}$&#xA;(homomorphism?)</p></li>&#xA;<li><p>$L_b = \{ab^{i_1}ab^{i_2}\ldots ab^{i_n} \mid i_j∈\mathbb N \land\exists j∈[1,n] \ i_j \not= j \}$</p>&#xA;&#xA;<p>$L_b' = \{ab^{i_1}ab^{i_2}\ldots ab^{i_n} \mid i_j∈\mathbb N \land\forall j∈[1,n] \ i_j = j \}$ (complement?)</p>&#xA;&#xA;<p>$L_b'' = \{ac^{i_1}ac^{i_2}\ldots ac^{i_n} \mid i_j∈\mathbb N \land\forall j∈[1,n] \ i_j = j \}$ (homomorphism?)</p></li>&#xA;</ol>&#xA;
formal languages context free closure properties
1
Use closure properties to transform languages to $L := \{ a^nb^n : n\in \mathbb N \}$ -- (formal languages context free closure properties) <p>For the purpose of proving that they are not regular, what closure properties can I use to transform the languages</p>&#xA;&#xA;<ol>&#xA;<li>$L_a = \{ a^*cw \mid w \in \{a,b \}^* \land |w|_a = |w|_b \}$ and</li>&#xA;<li>$L_b = \{ab^{i_1}ab^{i_2}\ldots ab^{i_n} \mid i_j∈\mathbb N \land \exists j∈[1,n] \ i_j \not= j \}$</li>&#xA;</ol>&#xA;&#xA;<p>to $L := \{ a^nb^n \mid n\in \mathbb N \}$, respectively?</p>&#xA;&#xA;<p>I tried: </p>&#xA;&#xA;<ol>&#xA;<li><p>$L_a = \{ a^*cw \mid w \in \{a,b \}^* \land |w|_a = |w|_b \}$ </p>&#xA;&#xA;<p>$L_a' = \{ \{a,d\}^*cw \mid w \in \{a,b,d \}^* \land |w|_a + |w|_d = |w|_b \}$ (union?)</p>&#xA;&#xA;<p>$L_a'' = \{ d^*cw \mid w \in \{a,b \}^* \land |w|_a = |w|_b \}$&#xA;(concatenation?)</p>&#xA;&#xA;<p>$L_a''' = \{ w \mid w \in \{a,b \}^* \land |w|_a = |w|_b \}$&#xA;(homomorphism?)</p></li>&#xA;<li><p>$L_b = \{ab^{i_1}ab^{i_2}\ldots ab^{i_n} \mid i_j∈\mathbb N \land\exists j∈[1,n] \ i_j \not= j \}$</p>&#xA;&#xA;<p>$L_b' = \{ab^{i_1}ab^{i_2}\ldots ab^{i_n} \mid i_j∈\mathbb N \land\forall j∈[1,n] \ i_j = j \}$ (complement?)</p>&#xA;&#xA;<p>$L_b'' = \{ac^{i_1}ac^{i_2}\ldots ac^{i_n} \mid i_j∈\mathbb N \land\forall j∈[1,n] \ i_j = j \}$ (homomorphism?)</p></li>&#xA;</ol>&#xA;
habedi/stack-exchange-dataset
1,957
Master theorem not applicable?
<p>Given the following recursive equation</p>&#xA;&#xA;<p>$$ T(n) = 2T\left(\frac{n}{2}\right)+n\log n$$ we want to apply the Master theorem and note that</p>&#xA;&#xA;<p>$$ n^{\log_2(2)} = n.$$</p>&#xA;&#xA;<p>Now we check the first two cases for $\varepsilon &gt; 0$, that is whether</p>&#xA;&#xA;<ul>&#xA;<li>$n\log n \in O(n^{1-\varepsilon})$ or</li>&#xA;<li>$n\log n \in \Theta(n)$.</li>&#xA;</ul>&#xA;&#xA;<p>The two cases are not satisfied. So we have to check the third case, that is whether</p>&#xA;&#xA;<ul>&#xA;<li>$n\log n \in \Omega(n^{1+\varepsilon})$ .</li>&#xA;</ul>&#xA;&#xA;<p>I think the third condition is not satisfied either. But why? And what would be a good explanation for why the Master theorem cannot be applied in this case?</p>&#xA;
proof techniques asymptotics recurrence relation master theorem
1
Master theorem not applicable? -- (proof techniques asymptotics recurrence relation master theorem) <p>Given the following recursive equation</p>&#xA;&#xA;<p>$$ T(n) = 2T\left(\frac{n}{2}\right)+n\log n$$ we want to apply the Master theorem and note that</p>&#xA;&#xA;<p>$$ n^{\log_2(2)} = n.$$</p>&#xA;&#xA;<p>Now we check the first two cases for $\varepsilon &gt; 0$, that is whether</p>&#xA;&#xA;<ul>&#xA;<li>$n\log n \in O(n^{1-\varepsilon})$ or</li>&#xA;<li>$n\log n \in \Theta(n)$.</li>&#xA;</ul>&#xA;&#xA;<p>The two cases are not satisfied. So we have to check the third case, that is whether</p>&#xA;&#xA;<ul>&#xA;<li>$n\log n \in \Omega(n^{1+\varepsilon})$ .</li>&#xA;</ul>&#xA;&#xA;<p>I think the third condition is not satisfied either. But why? And what would be a good explanation for why the Master theorem cannot be applied in this case?</p>&#xA;
habedi/stack-exchange-dataset
1,958
Relation between simple and regular grammars
<p>I am reading "An Introduction to Formal Languages and Automata" written by Peter Linz and after reading the first five chapters I face below problem with&#xA;simple and regular (especially right linear) grammars which are very similar to each other.</p>&#xA;&#xA;<p>What relation exists between these? What is the difference?&#xA;Can you create (non-deterministic) finite automata for simple grammars (obviously without using a stack)?</p>&#xA;
regular languages automata context free formal grammars
1
Relation between simple and regular grammars -- (regular languages automata context free formal grammars) <p>I am reading "An Introduction to Formal Languages and Automata" written by Peter Linz and after reading the first five chapters I face below problem with&#xA;simple and regular (especially right linear) grammars which are very similar to each other.</p>&#xA;&#xA;<p>What relation exists between these? What is the difference?&#xA;Can you create (non-deterministic) finite automata for simple grammars (obviously without using a stack)?</p>&#xA;
habedi/stack-exchange-dataset
1,959
How to go from a recurrence relation to a final complexity
<p>I have an algorithm, shown below, that I need to analyze. Because it's recursive in nature I set up a recurrence relation. </p>&#xA;&#xA;<pre><code>//Input: Adjacency matrix A[1..n, 1..n]) of an undirected graph G &#xA;//Output: 1 (true) if G is complete and 0 (false) otherwise &#xA;GraphComplete(A[1..n, 1..n]) {&#xA; if ( n = 1 )&#xA; return 1 //one-vertex graph is complete by definition &#xA; else &#xA; if not GraphComplete(A[0..n − 1, 0..n − 1]) &#xA; return 0 &#xA; else &#xA; for ( j ← 1 to n − 1 ) do &#xA; if ( A[n, j] = 0 ) &#xA; return 0 &#xA; end&#xA; return 1&#xA;}&#xA;</code></pre>&#xA;&#xA;<p>Here is what I believe is a valid and correct recurrence relation: </p>&#xA;&#xA;<p>$\qquad \begin{align}&#xD;&#xA; T(1) &amp;= 0 \\&#xD;&#xA; T(n) &amp;= T(n-1) + n - 1 \quad \text{for } n \geq 2&#xD;&#xA;\end{align}$</p>&#xA;&#xA;<p>The "$n - 1$" is how many times the body of the for loop, specifically the "if A[n,j]=0" check, is executed.</p>&#xA;&#xA;<p>The problem is, where do I go from here? How do I convert the above into something that actually shows what the resulting complexity is?</p>&#xA;
algorithms algorithm analysis runtime analysis recursion
1
How to go from a recurrence relation to a final complexity -- (algorithms algorithm analysis runtime analysis recursion) <p>I have an algorithm, shown below, that I need to analyze. Because it's recursive in nature I set up a recurrence relation. </p>&#xA;&#xA;<pre><code>//Input: Adjacency matrix A[1..n, 1..n]) of an undirected graph G &#xA;//Output: 1 (true) if G is complete and 0 (false) otherwise &#xA;GraphComplete(A[1..n, 1..n]) {&#xA; if ( n = 1 )&#xA; return 1 //one-vertex graph is complete by definition &#xA; else &#xA; if not GraphComplete(A[0..n − 1, 0..n − 1]) &#xA; return 0 &#xA; else &#xA; for ( j ← 1 to n − 1 ) do &#xA; if ( A[n, j] = 0 ) &#xA; return 0 &#xA; end&#xA; return 1&#xA;}&#xA;</code></pre>&#xA;&#xA;<p>Here is what I believe is a valid and correct recurrence relation: </p>&#xA;&#xA;<p>$\qquad \begin{align}&#xD;&#xA; T(1) &amp;= 0 \\&#xD;&#xA; T(n) &amp;= T(n-1) + n - 1 \quad \text{for } n \geq 2&#xD;&#xA;\end{align}$</p>&#xA;&#xA;<p>The "$n - 1$" is how many times the body of the for loop, specifically the "if A[n,j]=0" check, is executed.</p>&#xA;&#xA;<p>The problem is, where do I go from here? How do I convert the above into something that actually shows what the resulting complexity is?</p>&#xA;
habedi/stack-exchange-dataset
1,970
Data structure with search, insert and delete in amortised time $O(1)$?
<p>Is there a data structure to maintain an ordered list that supports the following operations in $O(1)$ amortized time? </p>&#xA;&#xA;<ul>&#xA;<li><p><strong>GetElement(k)</strong>: Return the $k$th element of the list.</p></li>&#xA;<li><p><strong>InsertAfter(x,y)</strong>: Insert the new element y into the list immediately after x. </p></li>&#xA;<li><p><strong>Delete(x)</strong>: Remove x from the list.</p></li>&#xA;</ul>&#xA;&#xA;<p>For the last two operations, you can assume that x is given as a pointer directly into the data structure; InsertElement returns the corresponding pointer for y. InsertAfter(NULL, y) inserts y at the beginning of the list.</p>&#xA;&#xA;<p>For example, starting with an empty data structure, the following operations update the ordered list as shown below:</p>&#xA;&#xA;<ul>&#xA;<li>InsertAfter(NULL, a) $\implies$ [a]</li>&#xA;<li>InsertAfter(NULL, b) $\implies$ [b, a]</li>&#xA;<li>InsertAfter(b, c) $\implies$ [b, c, a]</li>&#xA;<li>InsertAfter(a, d) $\implies$ [b, c, a, d]</li>&#xA;<li>Delete(c) $\implies$ [b, a, d]</li>&#xA;</ul>&#xA;&#xA;<p>After these five updates, GetElement(2) should return d, and GetElement(3) should return an error.</p>&#xA;
data structures time complexity asymptotics amortized analysis
1
Data structure with search, insert and delete in amortised time $O(1)$? -- (data structures time complexity asymptotics amortized analysis) <p>Is there a data structure to maintain an ordered list that supports the following operations in $O(1)$ amortized time? </p>&#xA;&#xA;<ul>&#xA;<li><p><strong>GetElement(k)</strong>: Return the $k$th element of the list.</p></li>&#xA;<li><p><strong>InsertAfter(x,y)</strong>: Insert the new element y into the list immediately after x. </p></li>&#xA;<li><p><strong>Delete(x)</strong>: Remove x from the list.</p></li>&#xA;</ul>&#xA;&#xA;<p>For the last two operations, you can assume that x is given as a pointer directly into the data structure; InsertElement returns the corresponding pointer for y. InsertAfter(NULL, y) inserts y at the beginning of the list.</p>&#xA;&#xA;<p>For example, starting with an empty data structure, the following operations update the ordered list as shown below:</p>&#xA;&#xA;<ul>&#xA;<li>InsertAfter(NULL, a) $\implies$ [a]</li>&#xA;<li>InsertAfter(NULL, b) $\implies$ [b, a]</li>&#xA;<li>InsertAfter(b, c) $\implies$ [b, c, a]</li>&#xA;<li>InsertAfter(a, d) $\implies$ [b, c, a, d]</li>&#xA;<li>Delete(c) $\implies$ [b, a, d]</li>&#xA;</ul>&#xA;&#xA;<p>After these five updates, GetElement(2) should return d, and GetElement(3) should return an error.</p>&#xA;
habedi/stack-exchange-dataset
1,972
Decide whether a context-free languages can be accepted by a deterministic pushdown automaton
<p>Given a context-free grammar G, there exists a Nondeterministic Pushdown Automaton N that accepts exactly the language G accepts. (and visa versa)</p>&#xA;&#xA;<p>There <strong>may</strong> also exist a Deterministic Pushdown Automaton D that accepts exactly the language G accepts too. It depends on the grammar.</p>&#xA;&#xA;<p>By what algorithm on the productions of G can we determine if D exists?</p>&#xA;
automata context free pushdown automata
1
Decide whether a context-free languages can be accepted by a deterministic pushdown automaton -- (automata context free pushdown automata) <p>Given a context-free grammar G, there exists a Nondeterministic Pushdown Automaton N that accepts exactly the language G accepts. (and visa versa)</p>&#xA;&#xA;<p>There <strong>may</strong> also exist a Deterministic Pushdown Automaton D that accepts exactly the language G accepts too. It depends on the grammar.</p>&#xA;&#xA;<p>By what algorithm on the productions of G can we determine if D exists?</p>&#xA;
habedi/stack-exchange-dataset
1,974
Compare-and-Swap in an RDBMS for custom locks and lock escalation
<p>I'm applying the Compare-and-Swap technique to a SQL database to create custom row-level locking in my dataset, allowing for safe READ UNCOMMITTED isolation at the database level.</p>&#xA;&#xA;<p>The Resource table includes a LockOwner <code>GUID</code> and a IsLocked <code>BIT</code> field. To acquire a lock, a dirty-read query gets the ID, LockOwner, and LockStatus. If <code>Unlocked</code>, attempt to <code>UPDATE</code> the Resource by (ID, LockOwner) with a newly generated LockOwner and LockStatus of <code>Locked</code>. Abort and start again if no rows are updated - meaning someone else got there first. Otherwise, the Lock is held in the READ UNCOMMITTED transaction. The transaction is needed to allow rollback on client failure/abandon, but the dirty reads avoid locks.</p>&#xA;&#xA;<p><strong>This seems to me to work great for resources that are independent of each other. But what must I add to account for a new kind of lock, ResourceGroup?</strong></p>&#xA;&#xA;<p>ResourceGroup to Resource is a one-to-many relationship. Resources can be locked individually, but if the ResourceGroup needs to be locked, then all of the Resources must also be locked. </p>&#xA;&#xA;<p>Locking a ResourceGroup is a far less frequent need than locking a Resource, so the scheme should be optimized for Resource queries, avoiding requiring joins to ResourceGroup if possible.</p>&#xA;&#xA;<p>I am imagining a scenario where locking a ResourceGroup involves marking the member rows with some flag, but I'm not sure what scheme doesn't interfere with the original Resource-only scheme. Part of the problem comes from the UPDATE of a Resource while it is locked (and therefore already UPDATED in another transaction). I believe that even if the fields are different within the record, the UPDATE will place an UPDATE LOCK on the row, so any lock on ResourceGroup would introduce blocking that we are trying to avoid. Even if we could do this, how would the ResourceGroup lock acquisition mechanism know when all of the Resources (which may have had locks in process as we began locking their peers) have been released?</p>&#xA;&#xA;<p>There may be differences in this locking granularity by RDBMS, I'm on MS SQL 2005+.</p>&#xA;
concurrency database theory
1
Compare-and-Swap in an RDBMS for custom locks and lock escalation -- (concurrency database theory) <p>I'm applying the Compare-and-Swap technique to a SQL database to create custom row-level locking in my dataset, allowing for safe READ UNCOMMITTED isolation at the database level.</p>&#xA;&#xA;<p>The Resource table includes a LockOwner <code>GUID</code> and a IsLocked <code>BIT</code> field. To acquire a lock, a dirty-read query gets the ID, LockOwner, and LockStatus. If <code>Unlocked</code>, attempt to <code>UPDATE</code> the Resource by (ID, LockOwner) with a newly generated LockOwner and LockStatus of <code>Locked</code>. Abort and start again if no rows are updated - meaning someone else got there first. Otherwise, the Lock is held in the READ UNCOMMITTED transaction. The transaction is needed to allow rollback on client failure/abandon, but the dirty reads avoid locks.</p>&#xA;&#xA;<p><strong>This seems to me to work great for resources that are independent of each other. But what must I add to account for a new kind of lock, ResourceGroup?</strong></p>&#xA;&#xA;<p>ResourceGroup to Resource is a one-to-many relationship. Resources can be locked individually, but if the ResourceGroup needs to be locked, then all of the Resources must also be locked. </p>&#xA;&#xA;<p>Locking a ResourceGroup is a far less frequent need than locking a Resource, so the scheme should be optimized for Resource queries, avoiding requiring joins to ResourceGroup if possible.</p>&#xA;&#xA;<p>I am imagining a scenario where locking a ResourceGroup involves marking the member rows with some flag, but I'm not sure what scheme doesn't interfere with the original Resource-only scheme. Part of the problem comes from the UPDATE of a Resource while it is locked (and therefore already UPDATED in another transaction). I believe that even if the fields are different within the record, the UPDATE will place an UPDATE LOCK on the row, so any lock on ResourceGroup would introduce blocking that we are trying to avoid. Even if we could do this, how would the ResourceGroup lock acquisition mechanism know when all of the Resources (which may have had locks in process as we began locking their peers) have been released?</p>&#xA;&#xA;<p>There may be differences in this locking granularity by RDBMS, I'm on MS SQL 2005+.</p>&#xA;
habedi/stack-exchange-dataset
1,979
Proof that $\{⟨M⟩ ∣ L(M) \mbox{ is context-free} \}$ is not (co-)recursively enumerable
<p>I would like to use your help with the following problem:</p>&#xA;&#xA;<p>$L=\{⟨M⟩ ∣ L(M) \mbox{ is context-free} \}$. Show that $L \notin RE \cup CoRE$.</p>&#xA;&#xA;<p>I know that to prove $L\notin RE$, it is enough to find a language $L'$ such that $L'\notin RE$ and show that there is a reduction from $L'$ to $L$ $(L'\leq _M L)$.</p>&#xA;&#xA;<p>I started to think of languages which I already know that they are not in $RE$, and I know that $Halt^* =\{⟨M⟩ ∣ M\mbox{ halts for every input} \} \notin RE$. I thought of this reduction from $Halt^*$ to $L$: $f(⟨M⟩)=(M')$. for every $⟨M⟩$: if $M$ halts for every input $L(M')=0^n1^n$ otherwise it would be $o^n1^n0^n$, but this is not correct, Isn't it? How can I check that $M$ halts for every input to begin with? and- is this the way to do that?</p>&#xA;
formal languages computability context free turing machines
1
Proof that $\{⟨M⟩ ∣ L(M) \mbox{ is context-free} \}$ is not (co-)recursively enumerable -- (formal languages computability context free turing machines) <p>I would like to use your help with the following problem:</p>&#xA;&#xA;<p>$L=\{⟨M⟩ ∣ L(M) \mbox{ is context-free} \}$. Show that $L \notin RE \cup CoRE$.</p>&#xA;&#xA;<p>I know that to prove $L\notin RE$, it is enough to find a language $L'$ such that $L'\notin RE$ and show that there is a reduction from $L'$ to $L$ $(L'\leq _M L)$.</p>&#xA;&#xA;<p>I started to think of languages which I already know that they are not in $RE$, and I know that $Halt^* =\{⟨M⟩ ∣ M\mbox{ halts for every input} \} \notin RE$. I thought of this reduction from $Halt^*$ to $L$: $f(⟨M⟩)=(M')$. for every $⟨M⟩$: if $M$ halts for every input $L(M')=0^n1^n$ otherwise it would be $o^n1^n0^n$, but this is not correct, Isn't it? How can I check that $M$ halts for every input to begin with? and- is this the way to do that?</p>&#xA;
habedi/stack-exchange-dataset
1,986
Prove that regular languages are closed under the cycle operator
<p>I've got in a few days an exam and have problems to solve this task.</p>&#xA;&#xA;<p>Let $L$ be a regular language over the alphabet $\Sigma$. We have the operation &#xA;$\operatorname{cycle}(L) = \{ xy \mid x,y\in \Sigma^* \text{ and } yx\in L\}$&#xA;And now we should show that $\operatorname{cycle}(L)$ is also regular.</p>&#xA;&#xA;<p>The reference is that we could construct out of a DFA $D=(Q,\Sigma,\delta, q_0, F)$ with $L(D) = L$ a $\epsilon$-NFA $N$ with $L(N) = \operatorname{cycle}(L)$ and $2 · |Q|^2 + 1$ states. </p>&#xA;
formal languages regular languages finite automata closure properties
1
Prove that regular languages are closed under the cycle operator -- (formal languages regular languages finite automata closure properties) <p>I've got in a few days an exam and have problems to solve this task.</p>&#xA;&#xA;<p>Let $L$ be a regular language over the alphabet $\Sigma$. We have the operation &#xA;$\operatorname{cycle}(L) = \{ xy \mid x,y\in \Sigma^* \text{ and } yx\in L\}$&#xA;And now we should show that $\operatorname{cycle}(L)$ is also regular.</p>&#xA;&#xA;<p>The reference is that we could construct out of a DFA $D=(Q,\Sigma,\delta, q_0, F)$ with $L(D) = L$ a $\epsilon$-NFA $N$ with $L(N) = \operatorname{cycle}(L)$ and $2 · |Q|^2 + 1$ states. </p>&#xA;
habedi/stack-exchange-dataset
1,990
Is there an undecidable finite language of finite words?
<p>Is there <em>a need</em> for $L\subseteq \Sigma^*$ to be <em>infinite</em> to be undecidable?</p>&#xA;&#xA;<p>I mean what if we choose a language $L'$ be a <em>bounded finite version of</em> $L\subseteq \Sigma^*$, that is $|L'|\leq N$, ($N \in \mathbb{N}$), with $L' \subset L$. Is it possible for $L'$ to be an undecidable language? </p>&#xA;&#xA;<p>I see that there is a problem of "How to choose the $N$ words that $\in$ $L' "$ for which we have to establish a rule for choosing which would be the first $N$ elements of $L'$, a kind of "finite" Kleene star operation. The aim is to find undecidability language without needing an infinite set, but I can't see it.</p>&#xA;&#xA;<p><strong>EDIT Note:</strong> </p>&#xA;&#xA;<p>Although I chose an answer, many answers <strong>and all comments</strong> are important.</p>&#xA;
formal languages computability undecidability
1
Is there an undecidable finite language of finite words? -- (formal languages computability undecidability) <p>Is there <em>a need</em> for $L\subseteq \Sigma^*$ to be <em>infinite</em> to be undecidable?</p>&#xA;&#xA;<p>I mean what if we choose a language $L'$ be a <em>bounded finite version of</em> $L\subseteq \Sigma^*$, that is $|L'|\leq N$, ($N \in \mathbb{N}$), with $L' \subset L$. Is it possible for $L'$ to be an undecidable language? </p>&#xA;&#xA;<p>I see that there is a problem of "How to choose the $N$ words that $\in$ $L' "$ for which we have to establish a rule for choosing which would be the first $N$ elements of $L'$, a kind of "finite" Kleene star operation. The aim is to find undecidability language without needing an infinite set, but I can't see it.</p>&#xA;&#xA;<p><strong>EDIT Note:</strong> </p>&#xA;&#xA;<p>Although I chose an answer, many answers <strong>and all comments</strong> are important.</p>&#xA;
habedi/stack-exchange-dataset
1,993
Why absence of surjection with the power set is not enough to prove the existence of an undecidable language?
<p>From this statement </p>&#xA;&#xA;<blockquote>&#xA; <p>As there is no surjection from $\mathbb{N}$ onto $\mathcal{P}(\mathbb{N})$, thus there must exist an undecidable language.</p>&#xA;</blockquote>&#xA;&#xA;<p>I would like to understand why similar reasoning does not work with a <em>finite</em> set $B$ which also has no surjection onto $\mathcal{P}(B)$! (with $|B|=K$ and $K \in \mathbb{N}$)</p>&#xA;&#xA;<p>Why is there a minimum need for the infinite set? </p>&#xA;&#xA;<p><strong>EDIT Note:</strong> </p>&#xA;&#xA;<p>Although I chose an answer, many answers <strong>and all comments</strong> are important.</p>&#xA;
formal languages computability undecidability
1
Why absence of surjection with the power set is not enough to prove the existence of an undecidable language? -- (formal languages computability undecidability) <p>From this statement </p>&#xA;&#xA;<blockquote>&#xA; <p>As there is no surjection from $\mathbb{N}$ onto $\mathcal{P}(\mathbb{N})$, thus there must exist an undecidable language.</p>&#xA;</blockquote>&#xA;&#xA;<p>I would like to understand why similar reasoning does not work with a <em>finite</em> set $B$ which also has no surjection onto $\mathcal{P}(B)$! (with $|B|=K$ and $K \in \mathbb{N}$)</p>&#xA;&#xA;<p>Why is there a minimum need for the infinite set? </p>&#xA;&#xA;<p><strong>EDIT Note:</strong> </p>&#xA;&#xA;<p>Although I chose an answer, many answers <strong>and all comments</strong> are important.</p>&#xA;
habedi/stack-exchange-dataset
1,998
Low-degree nodes in sparse graphs
<p>Let $G = (V,E)$ be a graph having $n$ vertices, none of which are isolated, and $n−1$ edges, where $n \geq 2$. Show that $G$ contains at least two vertices of degree one.</p>&#xA;&#xA;<p>I have tried to solve this problem by using the property $\sum_{v \in V} \operatorname{deg}(v) = 2|E|$. Can this problem be solved by using <a href="https://en.wikipedia.org/wiki/Pigeon_hole_principle">pigeon hole principle</a>?</p>&#xA;
graphs proof techniques
1
Low-degree nodes in sparse graphs -- (graphs proof techniques) <p>Let $G = (V,E)$ be a graph having $n$ vertices, none of which are isolated, and $n−1$ edges, where $n \geq 2$. Show that $G$ contains at least two vertices of degree one.</p>&#xA;&#xA;<p>I have tried to solve this problem by using the property $\sum_{v \in V} \operatorname{deg}(v) = 2|E|$. Can this problem be solved by using <a href="https://en.wikipedia.org/wiki/Pigeon_hole_principle">pigeon hole principle</a>?</p>&#xA;
habedi/stack-exchange-dataset
2,002
Is the set of LL(*) grammars the same as the set of CFG grammars?
<p>Is the set of LL(*) grammars the same as the set of context-free grammars?</p>&#xA;
formal languages formal grammars
1
Is the set of LL(*) grammars the same as the set of CFG grammars? -- (formal languages formal grammars) <p>Is the set of LL(*) grammars the same as the set of context-free grammars?</p>&#xA;
habedi/stack-exchange-dataset
2,006
Machine Learning algorithms based on "structural risk minimization"?
<p>Which machine learning algorithms (besides SVM's) use the principle of <a href="https://en.wikipedia.org/wiki/Structural_risk_minimization">structural risk minimization</a>?</p>&#xA;
reference request machine learning
1
Machine Learning algorithms based on "structural risk minimization"? -- (reference request machine learning) <p>Which machine learning algorithms (besides SVM's) use the principle of <a href="https://en.wikipedia.org/wiki/Structural_risk_minimization">structural risk minimization</a>?</p>&#xA;
habedi/stack-exchange-dataset
2,011
DLOGTIME complexity class and testing the length of the input string
<p>I read that testing the length of the input string is in DLOGTIME.</p>&#xA;&#xA;<p>The question is how can testing the length of the input string be in DLOGTIME?</p>&#xA;&#xA;<p>$\text{DLOGTIME} = O(\log n)$, so what number would be in $n$? (as it seems that $n$ is definitely not the length of the input string..... or is it?)</p>&#xA;&#xA;<p>So, to summarize, can anyone show me how the algorithm performs and how it is in DLOGTIME? At this point, it seems to me that $n$ is just an arbitary number..</p>&#xA;&#xA;<p>Note: I know what binary search is :) so you do not need to explain me about what that is.</p>&#xA;
complexity theory
1
DLOGTIME complexity class and testing the length of the input string -- (complexity theory) <p>I read that testing the length of the input string is in DLOGTIME.</p>&#xA;&#xA;<p>The question is how can testing the length of the input string be in DLOGTIME?</p>&#xA;&#xA;<p>$\text{DLOGTIME} = O(\log n)$, so what number would be in $n$? (as it seems that $n$ is definitely not the length of the input string..... or is it?)</p>&#xA;&#xA;<p>So, to summarize, can anyone show me how the algorithm performs and how it is in DLOGTIME? At this point, it seems to me that $n$ is just an arbitary number..</p>&#xA;&#xA;<p>Note: I know what binary search is :) so you do not need to explain me about what that is.</p>&#xA;
habedi/stack-exchange-dataset
2,016
How to convert finite automata to regular expressions?
<p>Converting regular expressions into (minimal) NFA that accept the same language is easy with standard algorithms, e.g. <a href="http://en.wikipedia.org/wiki/Thompson%27s_construction_algorithm">Thompson's algorithm</a>. The other direction seems to be more tedious, though, and sometimes the resulting expressions are messy.</p>&#xA;&#xA;<p>What algorithms are there for converting NFA into equivalent regular expressions? Are there advantages regarding time complexity or result size?</p>&#xA;&#xA;<p><sup>This is supposed to be a reference question. Please include a general decription of your method as well as a non-trivial example.</sup></p>&#xA;
algorithms formal languages finite automata regular expressions reference question
1
How to convert finite automata to regular expressions? -- (algorithms formal languages finite automata regular expressions reference question) <p>Converting regular expressions into (minimal) NFA that accept the same language is easy with standard algorithms, e.g. <a href="http://en.wikipedia.org/wiki/Thompson%27s_construction_algorithm">Thompson's algorithm</a>. The other direction seems to be more tedious, though, and sometimes the resulting expressions are messy.</p>&#xA;&#xA;<p>What algorithms are there for converting NFA into equivalent regular expressions? Are there advantages regarding time complexity or result size?</p>&#xA;&#xA;<p><sup>This is supposed to be a reference question. Please include a general decription of your method as well as a non-trivial example.</sup></p>&#xA;
habedi/stack-exchange-dataset
2,028
Finding small node sets that can not be avoided on paths from source to sink
<p>In a directed graph with a starting node and an ending node, how to find a small (doesn't have to be smallest. &lt;10 for example) set S of nodes such that every possible path from the starting node to the ending node contains at least one member of set S. The graph may have loops. This may be NP hard. Is there an approximate method to find one or several such S from the graph? Enumerating and testing every candidate seems not work. thanks.</p>&#xA;
algorithms graphs
1
Finding small node sets that can not be avoided on paths from source to sink -- (algorithms graphs) <p>In a directed graph with a starting node and an ending node, how to find a small (doesn't have to be smallest. &lt;10 for example) set S of nodes such that every possible path from the starting node to the ending node contains at least one member of set S. The graph may have loops. This may be NP hard. Is there an approximate method to find one or several such S from the graph? Enumerating and testing every candidate seems not work. thanks.</p>&#xA;
habedi/stack-exchange-dataset
2,031
Can constraint satisfaction problems be solved with Prolog?
<p>Is <a href="http://iggyfernandez.wordpress.com/2012/05/21/sql-vs-nosql-third-international-nocoug-sql-nosql-challenge-sponsored-by-pythian/">"party attendance"</a> type of problems solvable in Prolog? For example:</p>&#xA;&#xA;<blockquote>&#xA; <p>Burdock Muldoon and Carlotta Pinkstone both said they would come if Albus Dumbledore came. Albus Dumbledore and Daisy Dodderidge both said they would come if Carlotta Pinkstone came. Albus Dumbledore, Burdock Muldoon, and Carlotta Pinkstone all said they would come if Elfrida Clagg came. Carlotta Pinkstone and Daisy Dodderidge both said they would come if Falco Aesalon came. Burdock Muldoon, Elfrida Clagg, and Falco Aesalon all said they would come if Carlotta Pinkstone and Daisy Dodderidge both came. Daisy Dodderidge said she would come if Albus Dumbledore and Burdock Muldoon both came.&#xA; Whom is needs to be persuaded to attend the party in order to ensure that all her invitees attend?</p>&#xA;</blockquote>&#xA;&#xA;<p>I have tried to express this in GNU Prolog:</p>&#xA;&#xA;<pre><code>attend(BM) :- attend(AD).&#xA;attend(CP) :- attend(AD).&#xA;attend(AD) :- attend(CP).&#xA;attend(DD) :- attend(CP). &#xA;attend(AD) :- attend(EC).&#xA;attend(BM) :- attend(EC).&#xA;attend(CP) :- attend(EC). &#xA;attend(CP) :- attend(FA).&#xA;attend(DD) :- attend(FA).&#xA;attend(BM) :- attend(CP),attend(DD).&#xA;attend(EC) :- attend(CP),attend(DD).&#xA;attend(FA) :- attend(CP),attend(DD).&#xA;attend(DD) :- attend(AD),attend(BM).&#xA;&#xA;attend(FA). /* try different seed invitees in order to see if all would attend*/&#xA;&#xA;/* input:&#xA;write('invited:'),nl,&#xA; attend(X),write(X),nl,&#xA; fail.*/&#xA;</code></pre>&#xA;&#xA;<p>I'm experiencing stack overflow (no pun), and have no knowledge of prolog evaluation, this is why I'm asking.</p>&#xA;&#xA;<p>Generally speaking, this problem can be cast into Boolean CNF satisfaction formula (with 6 boolean variables). Therefore, does the prolog perspective have any merit?</p>&#xA;
logic constraint programming prolog logic programming
1
Can constraint satisfaction problems be solved with Prolog? -- (logic constraint programming prolog logic programming) <p>Is <a href="http://iggyfernandez.wordpress.com/2012/05/21/sql-vs-nosql-third-international-nocoug-sql-nosql-challenge-sponsored-by-pythian/">"party attendance"</a> type of problems solvable in Prolog? For example:</p>&#xA;&#xA;<blockquote>&#xA; <p>Burdock Muldoon and Carlotta Pinkstone both said they would come if Albus Dumbledore came. Albus Dumbledore and Daisy Dodderidge both said they would come if Carlotta Pinkstone came. Albus Dumbledore, Burdock Muldoon, and Carlotta Pinkstone all said they would come if Elfrida Clagg came. Carlotta Pinkstone and Daisy Dodderidge both said they would come if Falco Aesalon came. Burdock Muldoon, Elfrida Clagg, and Falco Aesalon all said they would come if Carlotta Pinkstone and Daisy Dodderidge both came. Daisy Dodderidge said she would come if Albus Dumbledore and Burdock Muldoon both came.&#xA; Whom is needs to be persuaded to attend the party in order to ensure that all her invitees attend?</p>&#xA;</blockquote>&#xA;&#xA;<p>I have tried to express this in GNU Prolog:</p>&#xA;&#xA;<pre><code>attend(BM) :- attend(AD).&#xA;attend(CP) :- attend(AD).&#xA;attend(AD) :- attend(CP).&#xA;attend(DD) :- attend(CP). &#xA;attend(AD) :- attend(EC).&#xA;attend(BM) :- attend(EC).&#xA;attend(CP) :- attend(EC). &#xA;attend(CP) :- attend(FA).&#xA;attend(DD) :- attend(FA).&#xA;attend(BM) :- attend(CP),attend(DD).&#xA;attend(EC) :- attend(CP),attend(DD).&#xA;attend(FA) :- attend(CP),attend(DD).&#xA;attend(DD) :- attend(AD),attend(BM).&#xA;&#xA;attend(FA). /* try different seed invitees in order to see if all would attend*/&#xA;&#xA;/* input:&#xA;write('invited:'),nl,&#xA; attend(X),write(X),nl,&#xA; fail.*/&#xA;</code></pre>&#xA;&#xA;<p>I'm experiencing stack overflow (no pun), and have no knowledge of prolog evaluation, this is why I'm asking.</p>&#xA;&#xA;<p>Generally speaking, this problem can be cast into Boolean CNF satisfaction formula (with 6 boolean variables). Therefore, does the prolog perspective have any merit?</p>&#xA;
habedi/stack-exchange-dataset
2,040
Ternary processing instead of Binary
<p>Most of the computers available today are designed to work with binary system. It comes from the fact that information comes in two natural form, <strong>true</strong> or <strong>false</strong>.</p>&#xA;&#xA;<p>We humans accept another form of information called "maybe" :)</p>&#xA;&#xA;<p>I know there are ternary processing computers but not much information about them.</p>&#xA;&#xA;<ol>&#xA;<li>What is the <strong>advantages</strong> / <strong>disadvantages</strong> of designing and using ternary or higher levels of data signals in computers? </li>&#xA;<li>Is it feasible? </li>&#xA;<li>In which domain can it be better than classic binary systems?</li>&#xA;<li>Can we give computers the chance to make mistakes and expect to see performance &#xA;improvements in most situations by this way? (I think performance gains can be observed if computers are not so strict about being absolutely correct)</li>&#xA;</ol>&#xA;&#xA;<p><strong>EDIT:</strong> Are there difficulties differentiating between 3 levels of signal? Would it be too hard to keep data in memory since memory voltage is frequently released and loaded, (maybe hundreds of time a second?).</p>&#xA;
computer architecture
1
Ternary processing instead of Binary -- (computer architecture) <p>Most of the computers available today are designed to work with binary system. It comes from the fact that information comes in two natural form, <strong>true</strong> or <strong>false</strong>.</p>&#xA;&#xA;<p>We humans accept another form of information called "maybe" :)</p>&#xA;&#xA;<p>I know there are ternary processing computers but not much information about them.</p>&#xA;&#xA;<ol>&#xA;<li>What is the <strong>advantages</strong> / <strong>disadvantages</strong> of designing and using ternary or higher levels of data signals in computers? </li>&#xA;<li>Is it feasible? </li>&#xA;<li>In which domain can it be better than classic binary systems?</li>&#xA;<li>Can we give computers the chance to make mistakes and expect to see performance &#xA;improvements in most situations by this way? (I think performance gains can be observed if computers are not so strict about being absolutely correct)</li>&#xA;</ol>&#xA;&#xA;<p><strong>EDIT:</strong> Are there difficulties differentiating between 3 levels of signal? Would it be too hard to keep data in memory since memory voltage is frequently released and loaded, (maybe hundreds of time a second?).</p>&#xA;
habedi/stack-exchange-dataset
2,049
How many layers should a neural network have?
<p>Are there any advantages of having more than 2 hidden layers in a Neural Network?</p>&#xA;&#xA;<p>I've seen some places that recommend it, others prove that there is no advantage.</p>&#xA;&#xA;<p>Which one is right?</p>&#xA;
artificial intelligence neural networks neural computing
1
How many layers should a neural network have? -- (artificial intelligence neural networks neural computing) <p>Are there any advantages of having more than 2 hidden layers in a Neural Network?</p>&#xA;&#xA;<p>I've seen some places that recommend it, others prove that there is no advantage.</p>&#xA;&#xA;<p>Which one is right?</p>&#xA;
habedi/stack-exchange-dataset
2,064
Block detection in repeated stream
<p>I need to recover a data block from a repeated stream of data. I'm looking to see what algorithms may already exist for this as it does not feel like a novel situation.</p>&#xA;&#xA;<p>Here are the specifics:</p>&#xA;&#xA;<ol>&#xA;<li>There is an N-length block of data contained in a stream</li>&#xA;<li>The block is repeated many times in the stream</li>&#xA;<li>the data is highly corrupted, some bytes could just be wrong, where as others can be detected as missing (erasures)</li>&#xA;<li>There is a function <code>F(data)</code> which can say if a block represents valid data (the probability of a false positive is virtually zero)</li>&#xA;<li><code>F</code> can also provide a probability value that even if the block is not valid data whether the block itself is valid (but just has too much corruption to be recovered)</li>&#xA;<li>The chance of corrupted data is very low compared to missing data</li>&#xA;</ol>&#xA;&#xA;<p>For example, say I have this data stream and wish to recover the 10 length sequence <code>1234567890</code>. The data is just a rough visual example (I can't guarantee recovery is actually possible from this bit). A <code>.</code> represents a missing byte, and <code>&lt;break&gt;</code> indicates an unknown block of data (no data and not length known). Note also the <code>Q</code>s as an example of corrupt data.</p>&#xA;&#xA;<p><code>23.5678901.3456789&lt;break&gt;2345678..1..4567QQ012345678..3456</code></p>&#xA;&#xA;<p>How can I take such a stream of data and recovery probably blocks of N data? As the actual data includes forward error recovery the block recovery need not be perfect. All it needs to do is give probable reconstructed blocks of data and the <code>F</code> function will attempt to do error recovery. Thus I expect <code>F</code> fill have to be called several times. </p>&#xA;&#xA;<p>I'd like to find something better than simply calling <code>F</code> at each point in the stream since the error rate could be high enough that no single run block of N can be recovered -- the repetitions in the stream must be used somehow.</p>&#xA;
algorithms online algorithms communication protocols
1
Block detection in repeated stream -- (algorithms online algorithms communication protocols) <p>I need to recover a data block from a repeated stream of data. I'm looking to see what algorithms may already exist for this as it does not feel like a novel situation.</p>&#xA;&#xA;<p>Here are the specifics:</p>&#xA;&#xA;<ol>&#xA;<li>There is an N-length block of data contained in a stream</li>&#xA;<li>The block is repeated many times in the stream</li>&#xA;<li>the data is highly corrupted, some bytes could just be wrong, where as others can be detected as missing (erasures)</li>&#xA;<li>There is a function <code>F(data)</code> which can say if a block represents valid data (the probability of a false positive is virtually zero)</li>&#xA;<li><code>F</code> can also provide a probability value that even if the block is not valid data whether the block itself is valid (but just has too much corruption to be recovered)</li>&#xA;<li>The chance of corrupted data is very low compared to missing data</li>&#xA;</ol>&#xA;&#xA;<p>For example, say I have this data stream and wish to recover the 10 length sequence <code>1234567890</code>. The data is just a rough visual example (I can't guarantee recovery is actually possible from this bit). A <code>.</code> represents a missing byte, and <code>&lt;break&gt;</code> indicates an unknown block of data (no data and not length known). Note also the <code>Q</code>s as an example of corrupt data.</p>&#xA;&#xA;<p><code>23.5678901.3456789&lt;break&gt;2345678..1..4567QQ012345678..3456</code></p>&#xA;&#xA;<p>How can I take such a stream of data and recovery probably blocks of N data? As the actual data includes forward error recovery the block recovery need not be perfect. All it needs to do is give probable reconstructed blocks of data and the <code>F</code> function will attempt to do error recovery. Thus I expect <code>F</code> fill have to be called several times. </p>&#xA;&#xA;<p>I'd like to find something better than simply calling <code>F</code> at each point in the stream since the error rate could be high enough that no single run block of N can be recovered -- the repetitions in the stream must be used somehow.</p>&#xA;
habedi/stack-exchange-dataset
2,067
What does this performance formula mean?
<p>I have to make a quick clustering program but the following formula is gibberish to me:</p>&#xA;&#xA;<blockquote>&#xA; <p>$\operatorname{Perf}(X,C) = \sum\limits_{i=1}^n\min\{||X_i-C_l||^2 \mid l = 1,...,K\}$</p>&#xA; &#xA; <p>where $X$ is a set of multi-dimensional data and $C$ is a set of centroids for each data cluster.</p>&#xA;</blockquote>&#xA;&#xA;<p>This formula is a fitness function for an <a href="https://en.wikipedia.org/wiki/Artificial_bee_colony_algorithm" rel="nofollow">artificial bee colony clustering algorithm</a> as a substitute for <a href="https://en.wikipedia.org/wiki/K-means_clustering_algorithm" rel="nofollow">k-means clustering algorithm</a>. It is described as a total&#xA;within-cluster variance or the total mean-square quantization error (MSE).</p>&#xA;&#xA;<p>Can anyone translate it to <em>pseudo-code</em>, normal human <em>English</em>, or at least enlighten me?</p>&#xA;
algorithms terminology evolutionary computing
1
What does this performance formula mean? -- (algorithms terminology evolutionary computing) <p>I have to make a quick clustering program but the following formula is gibberish to me:</p>&#xA;&#xA;<blockquote>&#xA; <p>$\operatorname{Perf}(X,C) = \sum\limits_{i=1}^n\min\{||X_i-C_l||^2 \mid l = 1,...,K\}$</p>&#xA; &#xA; <p>where $X$ is a set of multi-dimensional data and $C$ is a set of centroids for each data cluster.</p>&#xA;</blockquote>&#xA;&#xA;<p>This formula is a fitness function for an <a href="https://en.wikipedia.org/wiki/Artificial_bee_colony_algorithm" rel="nofollow">artificial bee colony clustering algorithm</a> as a substitute for <a href="https://en.wikipedia.org/wiki/K-means_clustering_algorithm" rel="nofollow">k-means clustering algorithm</a>. It is described as a total&#xA;within-cluster variance or the total mean-square quantization error (MSE).</p>&#xA;&#xA;<p>Can anyone translate it to <em>pseudo-code</em>, normal human <em>English</em>, or at least enlighten me?</p>&#xA;
habedi/stack-exchange-dataset
2,076
Could someone suggest me a good introductory book or an article on graph clustering?
<p>For my pet project I need to cluster some data which could be easily represented as graph, so I want to use this as an opportunity to educate myself and play with various algorithms. I'd prefer the book on graph clustering as it often more self contained but articles are fine too. Back in the days I used to work in the field of numerical linear algebra so I'd also prefer algebraical view on things (so books which view graph as a matrix with specific properties are more accessible to me).</p>&#xA;&#xA;<p>p.s. I've tried scholar.google.com but was overwhelmed by vast number of results. </p>&#xA;
algorithms graphs reference request books
1
Could someone suggest me a good introductory book or an article on graph clustering? -- (algorithms graphs reference request books) <p>For my pet project I need to cluster some data which could be easily represented as graph, so I want to use this as an opportunity to educate myself and play with various algorithms. I'd prefer the book on graph clustering as it often more self contained but articles are fine too. Back in the days I used to work in the field of numerical linear algebra so I'd also prefer algebraical view on things (so books which view graph as a matrix with specific properties are more accessible to me).</p>&#xA;&#xA;<p>p.s. I've tried scholar.google.com but was overwhelmed by vast number of results. </p>&#xA;
habedi/stack-exchange-dataset
2,079
Determine missing number in data stream
<p>We receive a stream of $n-1$ pairwise different numbers from the set $\left\{1,\dots,n\right\}$.</p>&#xA;&#xA;<p>How can I determine the missing number with an algorithm that reads the stream once and uses a memory of only $O(\log_2 n)$ bits?</p>&#xA;
algorithms integers online algorithms
1
Determine missing number in data stream -- (algorithms integers online algorithms) <p>We receive a stream of $n-1$ pairwise different numbers from the set $\left\{1,\dots,n\right\}$.</p>&#xA;&#xA;<p>How can I determine the missing number with an algorithm that reads the stream once and uses a memory of only $O(\log_2 n)$ bits?</p>&#xA;
habedi/stack-exchange-dataset
2,081
Is there a context free, non-regular language $L$, for which $L^*$ is regular?
<p>I know that there are non-regular languages, so that $L^*$ is regular, but all examples I can find are context-sensitive but not context free.</p>&#xA;&#xA;<p>In case there are none how do you prove it?</p>&#xA;
formal languages context free regular languages
1
Is there a context free, non-regular language $L$, for which $L^*$ is regular? -- (formal languages context free regular languages) <p>I know that there are non-regular languages, so that $L^*$ is regular, but all examples I can find are context-sensitive but not context free.</p>&#xA;&#xA;<p>In case there are none how do you prove it?</p>&#xA;
habedi/stack-exchange-dataset
2,088
Complete Problems for $DSPACE(\log(n)^k)$
<p>We know that the $polyL$-hierarchy doesn't have complete problems, as it would conflict with the space hierarchy theorem. But: Are there complete problems for each level of this hierarchy?</p>&#xA;&#xA;<p>To be precise: Does the class $DSPACE(\log(n)^k)$ have complete problems under $L$-reductions for each $k &gt; 0$?</p>&#xA;
complexity theory reductions space complexity
1
Complete Problems for $DSPACE(\log(n)^k)$ -- (complexity theory reductions space complexity) <p>We know that the $polyL$-hierarchy doesn't have complete problems, as it would conflict with the space hierarchy theorem. But: Are there complete problems for each level of this hierarchy?</p>&#xA;&#xA;<p>To be precise: Does the class $DSPACE(\log(n)^k)$ have complete problems under $L$-reductions for each $k &gt; 0$?</p>&#xA;
habedi/stack-exchange-dataset
2,100
Need help understanding this optimization problem on graphs
<p>Has anyone seen this problem before? It's suppose to be NP-complete.</p>&#xA;&#xA;<blockquote>&#xA; <p>We are given vertices $V_1,\dots ,V_n$ and possible parent sets for each vertex. Each parent set has an associated cost. Let $O$ be an ordering (a permutation) of the vertices. We say that a parent set of a vertex $V_i$ is consistent with an ordering $O$ if all of the parents come before the vertex in the ordering. Let $mcc(V_i, O)$ be the minimum cost of the parent sets of vertex $V_i$ that are consistent with ordering $O$. I need to find an ordering $O$ that minimizes the total cost: $mcc(V_1, O), \dots ,mcc(V_n, O)$.</p>&#xA;</blockquote>&#xA;&#xA;<p>I don't quite understand the part "...if all of the parents come before the vertex in the ordering." What does it mean?</p>&#xA;
algorithms graphs terminology optimization
1
Need help understanding this optimization problem on graphs -- (algorithms graphs terminology optimization) <p>Has anyone seen this problem before? It's suppose to be NP-complete.</p>&#xA;&#xA;<blockquote>&#xA; <p>We are given vertices $V_1,\dots ,V_n$ and possible parent sets for each vertex. Each parent set has an associated cost. Let $O$ be an ordering (a permutation) of the vertices. We say that a parent set of a vertex $V_i$ is consistent with an ordering $O$ if all of the parents come before the vertex in the ordering. Let $mcc(V_i, O)$ be the minimum cost of the parent sets of vertex $V_i$ that are consistent with ordering $O$. I need to find an ordering $O$ that minimizes the total cost: $mcc(V_1, O), \dots ,mcc(V_n, O)$.</p>&#xA;</blockquote>&#xA;&#xA;<p>I don't quite understand the part "...if all of the parents come before the vertex in the ordering." What does it mean?</p>&#xA;
habedi/stack-exchange-dataset
2,101
Finding the point nearest to the x-axis over some segment
<p>I have problem with solving the following exercise</p>&#xA;&#xA;<blockquote>&#xA; <p>Given the set $P$ on $n$ points in two dimensions, build in time $O(n\log n)$ a data structure of $P$ such that given a horizontal segment $s$ find the first point that $s$ touches when moving upwards from the x-axis in time $O(\log^2n)$.</p>&#xA;</blockquote>&#xA;&#xA;<p>The preprocessing time is equivalent to sorting, so we can perform sorting by one dimension.</p>&#xA;&#xA;<p>The query time is a little bit confusing - $\log^2$n. I would say it's $\log n$ binary searchs but it doesn't make sense.</p>&#xA;
algorithms computational geometry
1
Finding the point nearest to the x-axis over some segment -- (algorithms computational geometry) <p>I have problem with solving the following exercise</p>&#xA;&#xA;<blockquote>&#xA; <p>Given the set $P$ on $n$ points in two dimensions, build in time $O(n\log n)$ a data structure of $P$ such that given a horizontal segment $s$ find the first point that $s$ touches when moving upwards from the x-axis in time $O(\log^2n)$.</p>&#xA;</blockquote>&#xA;&#xA;<p>The preprocessing time is equivalent to sorting, so we can perform sorting by one dimension.</p>&#xA;&#xA;<p>The query time is a little bit confusing - $\log^2$n. I would say it's $\log n$ binary searchs but it doesn't make sense.</p>&#xA;
habedi/stack-exchange-dataset
2,103
Depth-2 circuits with OR and MOD gates are not universal?
<p>It is well-known that every boolean function $f:\{0,1\}^n\to \{0,1\}$ can be realized using a boolean circuit of depth 2 (over the variables, their negation and constant values) containing AND gates in the first level and one single OR gate in the upper level; this is simply the <a href="http://en.wikipedia.org/wiki/Disjunctive_normal_form" rel="nofollow">DNF representation</a> of $f$.</p>&#xA;&#xA;<p>Another type of gate which is of great interest in circuit complexity is the $MOD_m$ gate. The usual definition is the following:</p>&#xA;&#xA;<p>$$\mathrm{MOD}_m(x_1,\dots,x_k)=\cases{&#xA; 1 &amp; if \(\sum x_i \equiv 0 \mod m\) \\&#xA; 0 &amp; if \(\sum x_i \not\equiv 0 \mod m\) \\&#xA;}$$</p>&#xA;&#xA;<p>These gates sometimes have surprising power; for example, any boolean function can be represented by a depth-2 circuit having only $\mathrm{MOD}_6$ gates (this is folklore but I can elaborate is someone is interested).</p>&#xA;&#xA;<p>However, another folklore is that circuits with a single OR gate at the top and $\mathrm{MOD}_m$ gates in the bottom layer (with $m$ being fixed once and for all, and in particular being the same for all the gates) is not universal, i.e. for any value of $m$, there are boolean functions that cannot be computed by $\mathrm{OR} \circ \mathrm{MOD}_m$ circuit.</p>&#xA;&#xA;<p>I'm looking for a proof for this claim, or at least some direction.</p>&#xA;
complexity theory logic circuits
1
Depth-2 circuits with OR and MOD gates are not universal? -- (complexity theory logic circuits) <p>It is well-known that every boolean function $f:\{0,1\}^n\to \{0,1\}$ can be realized using a boolean circuit of depth 2 (over the variables, their negation and constant values) containing AND gates in the first level and one single OR gate in the upper level; this is simply the <a href="http://en.wikipedia.org/wiki/Disjunctive_normal_form" rel="nofollow">DNF representation</a> of $f$.</p>&#xA;&#xA;<p>Another type of gate which is of great interest in circuit complexity is the $MOD_m$ gate. The usual definition is the following:</p>&#xA;&#xA;<p>$$\mathrm{MOD}_m(x_1,\dots,x_k)=\cases{&#xA; 1 &amp; if \(\sum x_i \equiv 0 \mod m\) \\&#xA; 0 &amp; if \(\sum x_i \not\equiv 0 \mod m\) \\&#xA;}$$</p>&#xA;&#xA;<p>These gates sometimes have surprising power; for example, any boolean function can be represented by a depth-2 circuit having only $\mathrm{MOD}_6$ gates (this is folklore but I can elaborate is someone is interested).</p>&#xA;&#xA;<p>However, another folklore is that circuits with a single OR gate at the top and $\mathrm{MOD}_m$ gates in the bottom layer (with $m$ being fixed once and for all, and in particular being the same for all the gates) is not universal, i.e. for any value of $m$, there are boolean functions that cannot be computed by $\mathrm{OR} \circ \mathrm{MOD}_m$ circuit.</p>&#xA;&#xA;<p>I'm looking for a proof for this claim, or at least some direction.</p>&#xA;
habedi/stack-exchange-dataset
2,110
Space bounded Turing Machine - clarification on Computational Complexity (book: Arora-Barak ) question 4.1
<p>I have the following question from <a href="http://www.cs.princeton.edu/theory/complexity/" rel="noreferrer">Computational Complexity - A modern Approach</a> by Sanjeev Arora and Boaz Barak:</p>&#xA;&#xA;<blockquote>&#xA; <p><em>[Q 4.1]</em><br>&#xA; Prove the existence of a universal TM for space bounded computation (analogously to the deterministic universal TM of Theorem 1.9). </p>&#xA;</blockquote>&#xA;&#xA;<p>That is, prove that there exists a Turing Machine $SU$ such that for every string $\alpha$ and input $x$, if the TM $M_\alpha$ -- the TM represented by $\alpha$ -- halts on $x$ before using $t$ cells of its work tape, then $SU(\alpha, t, x) = M_\alpha(x)$ and moreover, $SU$ uses at most $C\cdot t$ cells of its work tape, where $C$ is a constant depending only on $M_\alpha$.</p>&#xA;&#xA;<p>After checking theorem 1.9 and the universal TM with time bound, I see that the construct $SU(\alpha, t, x)$ means that the Turing machine SU stops after $t$ steps. However if this is the case, then it means that we can create a Turing Machine equivalent to $M_\alpha$ such that the new Turing Machine stops in $t$ steps where $t$ is the "space" used in the original.</p>&#xA;&#xA;<p>However, this seems a dubious interchange of space and time. If on the other hand, $t$ actually meant that the second machine stops within $t$ space, too, then the second part does not make sense any more because it says $SU$ uses $Ct$ cells, which is not $t$.</p>&#xA;&#xA;<p>So my question is how do I interpret this? Is the first interpretation really possible?</p>&#xA;
complexity theory terminology turing machines space complexity
1
Space bounded Turing Machine - clarification on Computational Complexity (book: Arora-Barak ) question 4.1 -- (complexity theory terminology turing machines space complexity) <p>I have the following question from <a href="http://www.cs.princeton.edu/theory/complexity/" rel="noreferrer">Computational Complexity - A modern Approach</a> by Sanjeev Arora and Boaz Barak:</p>&#xA;&#xA;<blockquote>&#xA; <p><em>[Q 4.1]</em><br>&#xA; Prove the existence of a universal TM for space bounded computation (analogously to the deterministic universal TM of Theorem 1.9). </p>&#xA;</blockquote>&#xA;&#xA;<p>That is, prove that there exists a Turing Machine $SU$ such that for every string $\alpha$ and input $x$, if the TM $M_\alpha$ -- the TM represented by $\alpha$ -- halts on $x$ before using $t$ cells of its work tape, then $SU(\alpha, t, x) = M_\alpha(x)$ and moreover, $SU$ uses at most $C\cdot t$ cells of its work tape, where $C$ is a constant depending only on $M_\alpha$.</p>&#xA;&#xA;<p>After checking theorem 1.9 and the universal TM with time bound, I see that the construct $SU(\alpha, t, x)$ means that the Turing machine SU stops after $t$ steps. However if this is the case, then it means that we can create a Turing Machine equivalent to $M_\alpha$ such that the new Turing Machine stops in $t$ steps where $t$ is the "space" used in the original.</p>&#xA;&#xA;<p>However, this seems a dubious interchange of space and time. If on the other hand, $t$ actually meant that the second machine stops within $t$ space, too, then the second part does not make sense any more because it says $SU$ uses $Ct$ cells, which is not $t$.</p>&#xA;&#xA;<p>So my question is how do I interpret this? Is the first interpretation really possible?</p>&#xA;
habedi/stack-exchange-dataset
2,118
Number of clique in random graphs
<p>There is a family of random graphs $G(n, p)$ with $n$ nodes (<a href="https://en.wikipedia.org/wiki/Random_graph">due to Gilbert</a>). Each possible edge is independently inserted into $G(n, p)$ with probability $p$. Let $X_k$ be the number of cliques of size $k$ in $G(n, p)$.</p>&#xA;&#xA;<p>I know that $\mathbb{E}(X_k)=\tbinom{n}{k}\cdot p^{\tbinom{k}{2}}$, but how do I prove it?</p>&#xA;&#xA;<p>How to show that $\mathbb{E}(X_{\log_2n})\ge1$ for $n\to\infty$? And how to show that $\mathbb{E}(X_{c\cdot\log_2n}) \to 0$ for $n\to\infty$ and a fixed, arbitrary constant $c&gt;1$?</p>&#xA;
graphs combinatorics probability theory random graphs
1
Number of clique in random graphs -- (graphs combinatorics probability theory random graphs) <p>There is a family of random graphs $G(n, p)$ with $n$ nodes (<a href="https://en.wikipedia.org/wiki/Random_graph">due to Gilbert</a>). Each possible edge is independently inserted into $G(n, p)$ with probability $p$. Let $X_k$ be the number of cliques of size $k$ in $G(n, p)$.</p>&#xA;&#xA;<p>I know that $\mathbb{E}(X_k)=\tbinom{n}{k}\cdot p^{\tbinom{k}{2}}$, but how do I prove it?</p>&#xA;&#xA;<p>How to show that $\mathbb{E}(X_{\log_2n})\ge1$ for $n\to\infty$? And how to show that $\mathbb{E}(X_{c\cdot\log_2n}) \to 0$ for $n\to\infty$ and a fixed, arbitrary constant $c&gt;1$?</p>&#xA;
habedi/stack-exchange-dataset
2,127
Context-free grammar for $\{ a^n b^m a^{n+m} \}$
<p>I've got a problem with this task. I should declare a context-free grammar for this language:</p>&#xA;&#xA;<p>$\qquad \displaystyle L := \{\, a^nb^ma^{n+m} : n,m \in \mathbb{N}\,\}$</p>&#xA;&#xA;<p>My idea is: We need a start symbol, for example $S$. I know that I can generate the first $a$ and the last $a$ by $S \to a a$. I don't know what is the next idea to solve this task.</p>&#xA;
formal languages context free formal grammars
1
Context-free grammar for $\{ a^n b^m a^{n+m} \}$ -- (formal languages context free formal grammars) <p>I've got a problem with this task. I should declare a context-free grammar for this language:</p>&#xA;&#xA;<p>$\qquad \displaystyle L := \{\, a^nb^ma^{n+m} : n,m \in \mathbb{N}\,\}$</p>&#xA;&#xA;<p>My idea is: We need a start symbol, for example $S$. I know that I can generate the first $a$ and the last $a$ by $S \to a a$. I don't know what is the next idea to solve this task.</p>&#xA;
habedi/stack-exchange-dataset
2,149
Any very user friendly resources on the Baum-Welch algorithm?
<p>I'd like to understand the <a href="https://en.wikipedia.org/wiki/Baum%E2%80%93Welch_algorithm" rel="nofollow">Baum-Welch algorithm</a>. I liked <a href="http://www.youtube.com/watch?v=7zDARfKVm7s&amp;feature=related" rel="nofollow">this video</a> on the Forward-Backward algorithm so I'd like a similar one for Baum-Welch.</p>&#xA;&#xA;<p>I'm having trouble coming up with good resources for Baum-Welch. Any ideas?</p>&#xA;
algorithms reference request hidden markov models
1
Any very user friendly resources on the Baum-Welch algorithm? -- (algorithms reference request hidden markov models) <p>I'd like to understand the <a href="https://en.wikipedia.org/wiki/Baum%E2%80%93Welch_algorithm" rel="nofollow">Baum-Welch algorithm</a>. I liked <a href="http://www.youtube.com/watch?v=7zDARfKVm7s&amp;feature=related" rel="nofollow">this video</a> on the Forward-Backward algorithm so I'd like a similar one for Baum-Welch.</p>&#xA;&#xA;<p>I'm having trouble coming up with good resources for Baum-Welch. Any ideas?</p>&#xA;
habedi/stack-exchange-dataset
2,152
How to prove correctness of a shuffle algorithm?
<p>I have two ways of producing a list of items in a random order and would like to determine if they are equally fair (unbiased).</p>&#xA;&#xA;<p>The first method I use is to construct the entire list of elements and then do a shuffle on it (say a Fisher-Yates shuffle). The second method is more of an iterative method which keeps the list shuffled at every insertion. In pseudo-code the insertion function is:</p>&#xA;&#xA;<pre><code>insert( list, item )&#xA; list.append( item )&#xA; swap( list.random_item, list.last_item )&#xA;</code></pre>&#xA;&#xA;<p>I'm interested in how one goes about showing the fairness of this particular shuffling. The advantages of this algorithm, where it is used, are enough that even if slightly unfair it'd be okay. To decide I need a way to evaluate its fairness.</p>&#xA;&#xA;<p>My first idea is that I need to calculate the total permutations possible this way versus the total permutations possible for a set of the final length. I'm a bit at a loss however on how to calculate the permutations resulting from this algorithm. I also can't be certain this is the best, or easiest approach.</p>&#xA;
algorithms proof techniques randomized algorithms correctness proof randomness
1
How to prove correctness of a shuffle algorithm? -- (algorithms proof techniques randomized algorithms correctness proof randomness) <p>I have two ways of producing a list of items in a random order and would like to determine if they are equally fair (unbiased).</p>&#xA;&#xA;<p>The first method I use is to construct the entire list of elements and then do a shuffle on it (say a Fisher-Yates shuffle). The second method is more of an iterative method which keeps the list shuffled at every insertion. In pseudo-code the insertion function is:</p>&#xA;&#xA;<pre><code>insert( list, item )&#xA; list.append( item )&#xA; swap( list.random_item, list.last_item )&#xA;</code></pre>&#xA;&#xA;<p>I'm interested in how one goes about showing the fairness of this particular shuffling. The advantages of this algorithm, where it is used, are enough that even if slightly unfair it'd be okay. To decide I need a way to evaluate its fairness.</p>&#xA;&#xA;<p>My first idea is that I need to calculate the total permutations possible this way versus the total permutations possible for a set of the final length. I'm a bit at a loss however on how to calculate the permutations resulting from this algorithm. I also can't be certain this is the best, or easiest approach.</p>&#xA;
habedi/stack-exchange-dataset
2,154
Swap space management during pure demand paging
<p>The following is a doubt that I came across while doing a OS home assignment - however, it seems more concept-based than a straightforward coding question, so IMHO I don't think the homework tag is appropriate for this.</p>&#xA;&#xA;<p>In a pure demand paging scheme for multiple processes running at the same time, given a fixed amount of RAM and Swap memory, what happens in the following 2 cases w.r.t the swap space, when</p>&#xA;&#xA;<ol>&#xA;<li><p>A process encounters a page-fault, and there are no free frames available in the RAM, hence requiring one of the pages from the process' chunk of Kernel Frames to be written out to swap (for simplicity, I'm not considering the copy-on-write case). Explicitly, where in the Swap space would this frame be written, and what data structures need to be updated for that?</p></li>&#xA;<li><p>When a process needs to page-in a particular page, where does it look in the Swap memory, and how would it know if that particular page be present in Swap at all ?</p></li>&#xA;</ol>&#xA;&#xA;<p>As you can well imagine, I'm having difficulty understanding in what way to manage the Swap space during pure demand management scheme, and what data structures would be essential. It would be great if you could refer to any links in your answer (I searched in "Operating System Concepts - 8th edition by Silberschatz, I couldn't find an explicit answer for my question).</p>&#xA;
operating systems memory allocation virtual memory paging memory management
1
Swap space management during pure demand paging -- (operating systems memory allocation virtual memory paging memory management) <p>The following is a doubt that I came across while doing a OS home assignment - however, it seems more concept-based than a straightforward coding question, so IMHO I don't think the homework tag is appropriate for this.</p>&#xA;&#xA;<p>In a pure demand paging scheme for multiple processes running at the same time, given a fixed amount of RAM and Swap memory, what happens in the following 2 cases w.r.t the swap space, when</p>&#xA;&#xA;<ol>&#xA;<li><p>A process encounters a page-fault, and there are no free frames available in the RAM, hence requiring one of the pages from the process' chunk of Kernel Frames to be written out to swap (for simplicity, I'm not considering the copy-on-write case). Explicitly, where in the Swap space would this frame be written, and what data structures need to be updated for that?</p></li>&#xA;<li><p>When a process needs to page-in a particular page, where does it look in the Swap memory, and how would it know if that particular page be present in Swap at all ?</p></li>&#xA;</ol>&#xA;&#xA;<p>As you can well imagine, I'm having difficulty understanding in what way to manage the Swap space during pure demand management scheme, and what data structures would be essential. It would be great if you could refer to any links in your answer (I searched in "Operating System Concepts - 8th edition by Silberschatz, I couldn't find an explicit answer for my question).</p>&#xA;
habedi/stack-exchange-dataset
2,155
How to read typing rules?
<p>I started reading more and more language research papers. I find it very interesting and a good way to learn more about programming in general. However, there usually comes a section where I always struggle with (take for instance part three of <a href="http://math.andrej.com/wp-content/uploads/2012/03/eff.pdf">this</a>) since I lack the theoretical background in computer science: Type Rules.</p>&#xA;&#xA;<p>Are there any good books or online resources available to get started in this area? <a href="http://en.wikipedia.org/wiki/Type_rules">Wikipedia</a> is incredibly vague and doesn't really help a beginner.</p>&#xA;
logic reference request terminology type theory
1
How to read typing rules? -- (logic reference request terminology type theory) <p>I started reading more and more language research papers. I find it very interesting and a good way to learn more about programming in general. However, there usually comes a section where I always struggle with (take for instance part three of <a href="http://math.andrej.com/wp-content/uploads/2012/03/eff.pdf">this</a>) since I lack the theoretical background in computer science: Type Rules.</p>&#xA;&#xA;<p>Are there any good books or online resources available to get started in this area? <a href="http://en.wikipedia.org/wiki/Type_rules">Wikipedia</a> is incredibly vague and doesn't really help a beginner.</p>&#xA;
habedi/stack-exchange-dataset
2,157
NP-Completeness of a Graph Coloring Problem
<p><strong>Alternative Formulation</strong></p>&#xA;&#xA;<p>I came up with an alternative formulation to the below problem. The alternative formulation is actually a special case of the problem bellow and uses bipartite graphs to describe the problem. However, I believe that the alternative formulation is still NP-hard. The alternative formulation uses a disjoint set of incoming and outgoing nodes that simplifies the problem definition.</p>&#xA;&#xA;<p>Given $n$ outgoing and $n$ incoming nodes (the red and blue nodes in the figure respectively), and a set $w_{ij}$'s of size $n \times n$ of edge weights between the outgoing and incoming vertices. The goal of the problem is to color the thick edges in the figure so that for every incoming node, a condition holds.</p>&#xA;&#xA;<p><img src="https://i.stack.imgur.com/CsXJr.png" alt="Bipartite graph of the problem"></p>&#xA;&#xA;<blockquote>&#xA; <p>Given a set $\{ O_i \; | \; i=1 \dots n \}$ of output vertices, a set $\{ I_i\; | \; i=1 \dots n \}$ of input vertices, $n \times n$ weights&#xA; $w_{ij} \ge 0$ between $O_i$'s and $I_j$'s for $i,j=1 \dots n$, and a positive&#xA; constant $\beta$, find the minimum number of colors for the edges&#xA; $e_{ii}$ (thick edges in the above figure) such that for all $j=1 \dots n$,</p>&#xA; &#xA; <p>$$ \frac{w_{jj}}{1+\sum_{c(i)=c(j),i \neq j} w_{ij}} \ge \beta $$</p>&#xA; &#xA; <p>where $c(i)$ shows the color of the edge $e_{ii}$.</p>&#xA;</blockquote>&#xA;&#xA;<hr>&#xA;&#xA;<p><strong>Old Formulation</strong></p>&#xA;&#xA;<p>The following problem looks NP-hard to me, but I couldn't show it. Any proof/comment to show the hardness or easiness of it is appreciated.</p>&#xA;&#xA;<blockquote>&#xA; <p>Assume $K_n=\langle V,E \rangle$ is a complete weighted directed graph&#xA; with $n$ nodes and $n(n-1)$ edges. Let $w_{ij} \ge 0$ show the weight&#xA; of the edge $ij$ and $c(ij)$ shows the color of edge $ij$. Given a subset&#xA; of the edges $T \subseteq E$ and a positive constant $\beta$ the goal is:&#xA; find the minimum number of colors such that for each $e_{ij} \in T$:</p>&#xA; &#xA; <p>$$ \frac{w_{ij}}{1+\sum_{c(kl)=c(ij),kl \neq ij} w_{kj}} \ge \beta. $$&#xA; and&#xA; $$ c(ij) \neq c(ik) \quad for \quad j \neq k $$</p>&#xA;</blockquote>&#xA;&#xA;<p>Please note that in the above problem, only the edges in $T$ needs to be colored. That is the problem can be solved in $\mathcal{O}(|T|!)$.</p>&#xA;&#xA;<p><strong>Update:</strong></p>&#xA;&#xA;<p>After Tsuyoshi Ito's comment I updated the problem. The denominator is changed from $1+\sum_{c(kj)=c(ij),k \neq i,e_{kj} \in T} w_{kj}$ to $1+\sum_{c(kl)=c(ij),kl \neq ij} w_{kj}$. Therefore, the denominator contains the weights outside $T$ as well. That's actually why I mentioned the complete graph in the definition.</p>&#xA;&#xA;<p>I also added an additional constraint $c(ij) \neq c(ik) \quad for \quad j \neq k$. That means, the outgoing edges from a node must be of different colors (but the incoming colors can be the same as long as the inequality holds). This puts an intuitive lower bound on the number of colors, which is the maximum out-degree of the nodes in $T$.</p>&#xA;&#xA;<p>As Tsuyoshi mentioned, $w_{ij}$'s, $T$, and $\beta$ are inputs to the problem and the edge colors are the output.</p>&#xA;&#xA;<p><strong>Update 2:</strong></p>&#xA;&#xA;<p>Problem does not enforce the edges $e_{ij}$ and $e_{ji}$ be of a same color.</p>&#xA;
complexity theory graphs np complete
1
NP-Completeness of a Graph Coloring Problem -- (complexity theory graphs np complete) <p><strong>Alternative Formulation</strong></p>&#xA;&#xA;<p>I came up with an alternative formulation to the below problem. The alternative formulation is actually a special case of the problem bellow and uses bipartite graphs to describe the problem. However, I believe that the alternative formulation is still NP-hard. The alternative formulation uses a disjoint set of incoming and outgoing nodes that simplifies the problem definition.</p>&#xA;&#xA;<p>Given $n$ outgoing and $n$ incoming nodes (the red and blue nodes in the figure respectively), and a set $w_{ij}$'s of size $n \times n$ of edge weights between the outgoing and incoming vertices. The goal of the problem is to color the thick edges in the figure so that for every incoming node, a condition holds.</p>&#xA;&#xA;<p><img src="https://i.stack.imgur.com/CsXJr.png" alt="Bipartite graph of the problem"></p>&#xA;&#xA;<blockquote>&#xA; <p>Given a set $\{ O_i \; | \; i=1 \dots n \}$ of output vertices, a set $\{ I_i\; | \; i=1 \dots n \}$ of input vertices, $n \times n$ weights&#xA; $w_{ij} \ge 0$ between $O_i$'s and $I_j$'s for $i,j=1 \dots n$, and a positive&#xA; constant $\beta$, find the minimum number of colors for the edges&#xA; $e_{ii}$ (thick edges in the above figure) such that for all $j=1 \dots n$,</p>&#xA; &#xA; <p>$$ \frac{w_{jj}}{1+\sum_{c(i)=c(j),i \neq j} w_{ij}} \ge \beta $$</p>&#xA; &#xA; <p>where $c(i)$ shows the color of the edge $e_{ii}$.</p>&#xA;</blockquote>&#xA;&#xA;<hr>&#xA;&#xA;<p><strong>Old Formulation</strong></p>&#xA;&#xA;<p>The following problem looks NP-hard to me, but I couldn't show it. Any proof/comment to show the hardness or easiness of it is appreciated.</p>&#xA;&#xA;<blockquote>&#xA; <p>Assume $K_n=\langle V,E \rangle$ is a complete weighted directed graph&#xA; with $n$ nodes and $n(n-1)$ edges. Let $w_{ij} \ge 0$ show the weight&#xA; of the edge $ij$ and $c(ij)$ shows the color of edge $ij$. Given a subset&#xA; of the edges $T \subseteq E$ and a positive constant $\beta$ the goal is:&#xA; find the minimum number of colors such that for each $e_{ij} \in T$:</p>&#xA; &#xA; <p>$$ \frac{w_{ij}}{1+\sum_{c(kl)=c(ij),kl \neq ij} w_{kj}} \ge \beta. $$&#xA; and&#xA; $$ c(ij) \neq c(ik) \quad for \quad j \neq k $$</p>&#xA;</blockquote>&#xA;&#xA;<p>Please note that in the above problem, only the edges in $T$ needs to be colored. That is the problem can be solved in $\mathcal{O}(|T|!)$.</p>&#xA;&#xA;<p><strong>Update:</strong></p>&#xA;&#xA;<p>After Tsuyoshi Ito's comment I updated the problem. The denominator is changed from $1+\sum_{c(kj)=c(ij),k \neq i,e_{kj} \in T} w_{kj}$ to $1+\sum_{c(kl)=c(ij),kl \neq ij} w_{kj}$. Therefore, the denominator contains the weights outside $T$ as well. That's actually why I mentioned the complete graph in the definition.</p>&#xA;&#xA;<p>I also added an additional constraint $c(ij) \neq c(ik) \quad for \quad j \neq k$. That means, the outgoing edges from a node must be of different colors (but the incoming colors can be the same as long as the inequality holds). This puts an intuitive lower bound on the number of colors, which is the maximum out-degree of the nodes in $T$.</p>&#xA;&#xA;<p>As Tsuyoshi mentioned, $w_{ij}$'s, $T$, and $\beta$ are inputs to the problem and the edge colors are the output.</p>&#xA;&#xA;<p><strong>Update 2:</strong></p>&#xA;&#xA;<p>Problem does not enforce the edges $e_{ij}$ and $e_{ji}$ be of a same color.</p>&#xA;
habedi/stack-exchange-dataset
2,164
Transform in linear grammar
<p>i have the following regular grammar :&#xA;$$S \rightarrow aS | cS | bQ_1$$&#xA;$$Q_1 \rightarrow bQ_2$$&#xA;$$Q_2 \rightarrow aQ_3 | cQ_3 | bQ_1$$&#xA;$$Q_3 \rightarrow aQ_4 | cQ_4$$ &#xA;$$Q_4 \rightarrow \varepsilon$$</p>&#xA;&#xA;<p>The question is to transform that into a linear grammar with less nonterminals than the regular grammar and my idea was:&#xA;$$S \rightarrow aSa | cSc | aSc | cSa | bQ_1a | bQ_1c$$&#xA;$$Q_1 \rightarrow b$$</p>&#xA;&#xA;<p>and the rest i don't know. Could you help me to solve this problem?</p>&#xA;
formal grammars
1
Transform in linear grammar -- (formal grammars) <p>i have the following regular grammar :&#xA;$$S \rightarrow aS | cS | bQ_1$$&#xA;$$Q_1 \rightarrow bQ_2$$&#xA;$$Q_2 \rightarrow aQ_3 | cQ_3 | bQ_1$$&#xA;$$Q_3 \rightarrow aQ_4 | cQ_4$$ &#xA;$$Q_4 \rightarrow \varepsilon$$</p>&#xA;&#xA;<p>The question is to transform that into a linear grammar with less nonterminals than the regular grammar and my idea was:&#xA;$$S \rightarrow aSa | cSc | aSc | cSa | bQ_1a | bQ_1c$$&#xA;$$Q_1 \rightarrow b$$</p>&#xA;&#xA;<p>and the rest i don't know. Could you help me to solve this problem?</p>&#xA;
habedi/stack-exchange-dataset
2,166
generation of linear grammar
<p>We have the following linear grammar:&#xA;$$E \rightarrow aO | bO | bbE | bb$$&#xA;$$O \rightarrow aE | bE | abaE | aba$$&#xA;Does the linear grammar generate a regular language, if yes why ?&#xA;Our alphabet is $\Sigma$ = {a,b} and our nonterminals are E and O. We begin by E.</p>&#xA;
formal languages formal grammars
1
generation of linear grammar -- (formal languages formal grammars) <p>We have the following linear grammar:&#xA;$$E \rightarrow aO | bO | bbE | bb$$&#xA;$$O \rightarrow aE | bE | abaE | aba$$&#xA;Does the linear grammar generate a regular language, if yes why ?&#xA;Our alphabet is $\Sigma$ = {a,b} and our nonterminals are E and O. We begin by E.</p>&#xA;
habedi/stack-exchange-dataset
2,175
Constructing a data structure for a computer algebra system
<p>In thinking about how to approach this problem I think several things will be required, some tivial:</p>&#xA;&#xA;<ol>&#xA;<li>An expression tree where non-leaf node is an operation (not sure if that part is redundant), but not every node has just two children.</li>&#xA;<li>All nodes for operations have a defined number of children that they must have (some operators are unary (like $!$) while others are binary ($*,+,-,$ etc) and still other are n-ary ($f(a,b,d)$ and versions with different amounts of variables).</li>&#xA;<li>All leaf nodes are some type of number</li>&#xA;</ol>&#xA;&#xA;<p>I am under the impression that the tree should not explicitly retain information regarding the order of operations, but rather that information should be used in the parsing stage to insert things into the tree correctly.</p>&#xA;&#xA;<p>This leads to the question, how should inserting to a specific position in the tree be done? Simply passing a list of directions (from root, take node zero, then node 1, etc, then insert) will work, but it seems overly clunky.</p>&#xA;&#xA;<p>Or should I avoid that situation entirely (not talking about editing an equation here, just building a representation of one) by using the fact that in some sense the tree must be complete (all binary operations MUST have two children, etc, and even operators that are seemingly ambiguous (the $_{^-}$ sign for example) but these ambiguities are resolved before this point. That would all me to insert "in order"</p>&#xA;&#xA;<p>Am I taking a reasonable approach? Does it make no sense whatsoever?</p>&#xA;&#xA;<p>Additionally, are there papers or articles that I should read about CAS systems?</p>&#xA;&#xA;<p><strong>Clarification:</strong> The tree will need to support three different compound operations.</p>&#xA;&#xA;<ol>&#xA;<li>Creation: (from a string, but how to actually do that is beyond the scope of this question)</li>&#xA;<li>Reduction: (to some type of canonical form) so that if $a+b$ and $b+a$ are both entered and reduced, they will form identical trees.</li>&#xA;<li>Evaluation: Be able to traverse the tree</li>&#xA;</ol>&#xA;&#xA;<p>These are all the operations that need to be supported. There are probably many other more basic operations that may need to be supported, but in this case it only matters that the three operations above are supported. My understanding is that search for example is not a property that will be required, but deletion will be (of a whole subtree).</p>&#xA;
data structures computer algebra mathematical software
1
Constructing a data structure for a computer algebra system -- (data structures computer algebra mathematical software) <p>In thinking about how to approach this problem I think several things will be required, some tivial:</p>&#xA;&#xA;<ol>&#xA;<li>An expression tree where non-leaf node is an operation (not sure if that part is redundant), but not every node has just two children.</li>&#xA;<li>All nodes for operations have a defined number of children that they must have (some operators are unary (like $!$) while others are binary ($*,+,-,$ etc) and still other are n-ary ($f(a,b,d)$ and versions with different amounts of variables).</li>&#xA;<li>All leaf nodes are some type of number</li>&#xA;</ol>&#xA;&#xA;<p>I am under the impression that the tree should not explicitly retain information regarding the order of operations, but rather that information should be used in the parsing stage to insert things into the tree correctly.</p>&#xA;&#xA;<p>This leads to the question, how should inserting to a specific position in the tree be done? Simply passing a list of directions (from root, take node zero, then node 1, etc, then insert) will work, but it seems overly clunky.</p>&#xA;&#xA;<p>Or should I avoid that situation entirely (not talking about editing an equation here, just building a representation of one) by using the fact that in some sense the tree must be complete (all binary operations MUST have two children, etc, and even operators that are seemingly ambiguous (the $_{^-}$ sign for example) but these ambiguities are resolved before this point. That would all me to insert "in order"</p>&#xA;&#xA;<p>Am I taking a reasonable approach? Does it make no sense whatsoever?</p>&#xA;&#xA;<p>Additionally, are there papers or articles that I should read about CAS systems?</p>&#xA;&#xA;<p><strong>Clarification:</strong> The tree will need to support three different compound operations.</p>&#xA;&#xA;<ol>&#xA;<li>Creation: (from a string, but how to actually do that is beyond the scope of this question)</li>&#xA;<li>Reduction: (to some type of canonical form) so that if $a+b$ and $b+a$ are both entered and reduced, they will form identical trees.</li>&#xA;<li>Evaluation: Be able to traverse the tree</li>&#xA;</ol>&#xA;&#xA;<p>These are all the operations that need to be supported. There are probably many other more basic operations that may need to be supported, but in this case it only matters that the three operations above are supported. My understanding is that search for example is not a property that will be required, but deletion will be (of a whole subtree).</p>&#xA;
habedi/stack-exchange-dataset
2,184
Massalin's Synthesis Quajects equivalent to ASM generating macros used in Game Oriented Assembly LISP?
<p><a href="http://valerieaurora.org/synthesis/SynthesisOS/abs.html" rel="nofollow">Alexia Massalin's Dissertation on Synthesis</a> was a Phd thesis on Operating Systems that contained a concept called 'Quajects' (see <a href="http://valerieaurora.org/synthesis/SynthesisOS/ch4.html" rel="nofollow">Chapter 4</a>). </p>&#xA;&#xA;<p>This is some <a href="http://news.ycombinator.com/item?id=4030665" rel="nofollow">additional commentary on the Phd Thesis</a>. </p>&#xA;&#xA;<p>Best I can work out - a Quaject is construct that generates Assembler customised for the function being used at the time. (Perhaps like a <a href="http://en.wikipedia.org/wiki/Just-in-time_compilation" rel="nofollow">JIT</a>). </p>&#xA;&#xA;<p>The project that I've seen that came closest to this was <a href="http://en.wikipedia.org/wiki/Game_Oriented_Assembly_Lisp" rel="nofollow">Game Oriented Assembly LISP</a> (GOAL), a framework used in Crash Bandicoot that used ASM-generating LISP macros to speed up the development iteration process and generate the production code. </p>&#xA;&#xA;<p>Can we say that the Macros generating ASM in GOAL were quajects? (yes or no question - please explain why if yes, and reasons if no.)</p>&#xA;
operating systems
1
Massalin's Synthesis Quajects equivalent to ASM generating macros used in Game Oriented Assembly LISP? -- (operating systems) <p><a href="http://valerieaurora.org/synthesis/SynthesisOS/abs.html" rel="nofollow">Alexia Massalin's Dissertation on Synthesis</a> was a Phd thesis on Operating Systems that contained a concept called 'Quajects' (see <a href="http://valerieaurora.org/synthesis/SynthesisOS/ch4.html" rel="nofollow">Chapter 4</a>). </p>&#xA;&#xA;<p>This is some <a href="http://news.ycombinator.com/item?id=4030665" rel="nofollow">additional commentary on the Phd Thesis</a>. </p>&#xA;&#xA;<p>Best I can work out - a Quaject is construct that generates Assembler customised for the function being used at the time. (Perhaps like a <a href="http://en.wikipedia.org/wiki/Just-in-time_compilation" rel="nofollow">JIT</a>). </p>&#xA;&#xA;<p>The project that I've seen that came closest to this was <a href="http://en.wikipedia.org/wiki/Game_Oriented_Assembly_Lisp" rel="nofollow">Game Oriented Assembly LISP</a> (GOAL), a framework used in Crash Bandicoot that used ASM-generating LISP macros to speed up the development iteration process and generate the production code. </p>&#xA;&#xA;<p>Can we say that the Macros generating ASM in GOAL were quajects? (yes or no question - please explain why if yes, and reasons if no.)</p>&#xA;
habedi/stack-exchange-dataset
2,188
How to use a greedy algorithm to find the non-decreasing sequence closest to the given one?
<p>You are given n integers $a_1, \ldots, a_n$ all between $0$ and $l$. Under each integer $a_i$ you should write an integer $b_i$ between $0$ and $l$ with the requirement that the $b_i$'s form a non-decreasing sequence. Define the deviation of such a sequence to be $\max(|a_1-b_1|, \ldots, |a_n-b_n|)$. Design an algorithm that finds the $b_i$'s with the minimum deviation in runtime $O(n\sqrt[4]{l})$.</p>&#xA;&#xA;<p>I honestly have no clue whatsoever how to even begin to solve this question. It looks like a dynamic programming question to me, but the professor said that this should be solved using a greedy algorithm. It would be much appreciated if someone can point me in the right direction by giving a small hint.</p>&#xA;
algorithms optimization greedy algorithms subsequences
1
How to use a greedy algorithm to find the non-decreasing sequence closest to the given one? -- (algorithms optimization greedy algorithms subsequences) <p>You are given n integers $a_1, \ldots, a_n$ all between $0$ and $l$. Under each integer $a_i$ you should write an integer $b_i$ between $0$ and $l$ with the requirement that the $b_i$'s form a non-decreasing sequence. Define the deviation of such a sequence to be $\max(|a_1-b_1|, \ldots, |a_n-b_n|)$. Design an algorithm that finds the $b_i$'s with the minimum deviation in runtime $O(n\sqrt[4]{l})$.</p>&#xA;&#xA;<p>I honestly have no clue whatsoever how to even begin to solve this question. It looks like a dynamic programming question to me, but the professor said that this should be solved using a greedy algorithm. It would be much appreciated if someone can point me in the right direction by giving a small hint.</p>&#xA;
habedi/stack-exchange-dataset
2,192
Finding lambda of Master Theorem
<p>Suppose I have a recurrence like $T(n)=2T(n/4)+\log(n)$ with $a=2, b=4$ and $f(n)=\log(n)$.</p>&#xA;&#xA;<p>That should be <a href="http://en.wikipedia.org/wiki/Master_theorem#Case_1" rel="nofollow">case 1 of the Master theorem</a> because $n^{1/2}&gt;\log(n)$. There is also a lambda in case 1: $f(n)=O(n^{(1/2)-\lambda})$. Is this correct? And how can I find this lambda?</p>&#xA;
proof techniques asymptotics recurrence relation master theorem
1
Finding lambda of Master Theorem -- (proof techniques asymptotics recurrence relation master theorem) <p>Suppose I have a recurrence like $T(n)=2T(n/4)+\log(n)$ with $a=2, b=4$ and $f(n)=\log(n)$.</p>&#xA;&#xA;<p>That should be <a href="http://en.wikipedia.org/wiki/Master_theorem#Case_1" rel="nofollow">case 1 of the Master theorem</a> because $n^{1/2}&gt;\log(n)$. There is also a lambda in case 1: $f(n)=O(n^{(1/2)-\lambda})$. Is this correct? And how can I find this lambda?</p>&#xA;
habedi/stack-exchange-dataset
2,193
How can I prove that a complete binary tree has $\lceil n/2 \rceil$ leaves?
<p>Given a complete binary tree with $n$ nodes. I'm trying to prove that a complete binary tree has exactly $\lceil n/2 \rceil$ leaves.&#xA;I think I can do this by induction.</p>&#xA;&#xA;<p>For $h(t)=0$, the tree is empty. So there are no leaves and the claim holds for an empty tree.</p>&#xA;&#xA;<p>For $h(t)=1$, the tree has 1 node, that also is a leaf, so the claim holds.&#xA;Here I'm stuck, I don't know what to choose as induction hypothesis and how to do the induction step.</p>&#xA;
data structures graphs proof techniques combinatorics binary trees
1
How can I prove that a complete binary tree has $\lceil n/2 \rceil$ leaves? -- (data structures graphs proof techniques combinatorics binary trees) <p>Given a complete binary tree with $n$ nodes. I'm trying to prove that a complete binary tree has exactly $\lceil n/2 \rceil$ leaves.&#xA;I think I can do this by induction.</p>&#xA;&#xA;<p>For $h(t)=0$, the tree is empty. So there are no leaves and the claim holds for an empty tree.</p>&#xA;&#xA;<p>For $h(t)=1$, the tree has 1 node, that also is a leaf, so the claim holds.&#xA;Here I'm stuck, I don't know what to choose as induction hypothesis and how to do the induction step.</p>&#xA;
habedi/stack-exchange-dataset
2,197
How do I test if a polygon is monotone with respect to an arbitrary line?
<blockquote>&#xA; <p><strong>Definition</strong>: A polygon $P$ in the plane is called monotone with respect to a straight line $L$, if every line orthogonal to $L$ intersects $P$ at most twice.</p>&#xA;</blockquote>&#xA;&#xA;<p>Given a polygon $P$, is it possible to determine if there exists any line $L$ such that the polygon $P$ is monotone with respect to $L$? If yes, how?</p>&#xA;&#xA;<p>Previously, I asked a <a href="https://cs.stackexchange.com/q/1577/20691">related question</a> (where I asked how to determine if a polygon is monotone with respect to a particular line), but now I am interested in the case when $L$ is <strong>not</strong> given or specified in advance.</p>&#xA;
algorithms computational geometry
1
How do I test if a polygon is monotone with respect to an arbitrary line? -- (algorithms computational geometry) <blockquote>&#xA; <p><strong>Definition</strong>: A polygon $P$ in the plane is called monotone with respect to a straight line $L$, if every line orthogonal to $L$ intersects $P$ at most twice.</p>&#xA;</blockquote>&#xA;&#xA;<p>Given a polygon $P$, is it possible to determine if there exists any line $L$ such that the polygon $P$ is monotone with respect to $L$? If yes, how?</p>&#xA;&#xA;<p>Previously, I asked a <a href="https://cs.stackexchange.com/q/1577/20691">related question</a> (where I asked how to determine if a polygon is monotone with respect to a particular line), but now I am interested in the case when $L$ is <strong>not</strong> given or specified in advance.</p>&#xA;
habedi/stack-exchange-dataset
2,200
Weighted subset sum problem
<p>Given an integer sequence $\{ a_1, a_2, \ldots, a_N \}$ that has length $N$ and a fixed integer $M\leq N$, the <a href="http://opc.iarcs.org.in/public/WEIGHTED-SUM.pdf" rel="nofollow noreferrer">problem</a> is to find a subset $A =\{i_1, \dots, i_M\} \subseteq [N]$ with $1 \leq i_1 \lt i_1 \lt \dots \lt i_M \leq N$ such that</p>&#xA;&#xA;<p>$\qquad \displaystyle \sum_{j=1}^M j \cdot a_{i_j}$ </p>&#xA;&#xA;<p>is maximized.</p>&#xA;&#xA;<hr>&#xA;&#xA;<p>For instance, if the given sequence is $-50; 100; -20; 40; 30$ and $M = 2$, the best weighted sum arises when we choose positions 2 and 4. </p>&#xA;&#xA;<p>So that we get a value $1 \cdot 100 + 2 \cdot 40 = 180$.</p>&#xA;&#xA;<p>On the other hand, if the given sequence is $10; 50; 20$ and $M$ is again 2, the best option is to choose positions 1 and 2 that we get a value $1 \cdot 10 + 2 \cdot 50 = 110$.</p>&#xA;&#xA;<hr>&#xA;&#xA;<p>To me it looks similar to the <a href="http://en.wikipedia.org/wiki/Maximum_subarray_problem" rel="nofollow noreferrer">maximum subarray problem</a>, but I can think of many examples in which the maximum subarray is not the best solution.</p>&#xA;&#xA;<p>Is this problem an instance of a well studied problem? What is the best algorithm to solve it?</p>&#xA;&#xA;<p>This question was inspired by <a href="https://stackoverflow.com/questions/10861642/find-maximum-weighted-sum-over-all-m-subsequences">this StackOverflow question</a>.</p>&#xA;
algorithms optimization
1
Weighted subset sum problem -- (algorithms optimization) <p>Given an integer sequence $\{ a_1, a_2, \ldots, a_N \}$ that has length $N$ and a fixed integer $M\leq N$, the <a href="http://opc.iarcs.org.in/public/WEIGHTED-SUM.pdf" rel="nofollow noreferrer">problem</a> is to find a subset $A =\{i_1, \dots, i_M\} \subseteq [N]$ with $1 \leq i_1 \lt i_1 \lt \dots \lt i_M \leq N$ such that</p>&#xA;&#xA;<p>$\qquad \displaystyle \sum_{j=1}^M j \cdot a_{i_j}$ </p>&#xA;&#xA;<p>is maximized.</p>&#xA;&#xA;<hr>&#xA;&#xA;<p>For instance, if the given sequence is $-50; 100; -20; 40; 30$ and $M = 2$, the best weighted sum arises when we choose positions 2 and 4. </p>&#xA;&#xA;<p>So that we get a value $1 \cdot 100 + 2 \cdot 40 = 180$.</p>&#xA;&#xA;<p>On the other hand, if the given sequence is $10; 50; 20$ and $M$ is again 2, the best option is to choose positions 1 and 2 that we get a value $1 \cdot 10 + 2 \cdot 50 = 110$.</p>&#xA;&#xA;<hr>&#xA;&#xA;<p>To me it looks similar to the <a href="http://en.wikipedia.org/wiki/Maximum_subarray_problem" rel="nofollow noreferrer">maximum subarray problem</a>, but I can think of many examples in which the maximum subarray is not the best solution.</p>&#xA;&#xA;<p>Is this problem an instance of a well studied problem? What is the best algorithm to solve it?</p>&#xA;&#xA;<p>This question was inspired by <a href="https://stackoverflow.com/questions/10861642/find-maximum-weighted-sum-over-all-m-subsequences">this StackOverflow question</a>.</p>&#xA;
habedi/stack-exchange-dataset
2,201
Optimal myopic maze solver
<p>I was fooling around with <a href="http://neil.fraser.name/software/blockly/demos/maze/index.html" rel="nofollow noreferrer">Google Blocky's Maze demo</a>, and remembered the old rule that if you want to solve a maze, just keep your left hand to the wall. This works for any simple-connected maze and can be implemented by a finite transducer.</p>&#xA;&#xA;<p>Let our robot be represented by a transducer with the following actions, and observables:</p>&#xA;&#xA;<ul>&#xA;<li>Actions: go forward ($\uparrow$), turn left ($\leftarrow$), turn right ($\rightarrow$)</li>&#xA;<li>Observables: wall ahead ($\bot$), no wall ahead ($\top$)</li>&#xA;</ul>&#xA;&#xA;<p>Then we can build the left-hand maze solver as (pardon my lazy drawing):</p>&#xA;&#xA;<p><img src="https://i.stack.imgur.com/vAnFO.png" alt="transducer to solve the maze"></p>&#xA;&#xA;<p>Where seeing an observable will make us follow the appropriate edge out of the state while executing the action associated with that edge. This automaton will solve all simply-connected mazes, although it might take its time following dead ends. We call another automaton $B$ <em>better than</em> $A$ if:</p>&#xA;&#xA;<ol>&#xA;<li><p>$B$ takes strictly more steps on only a finite number of mazes, and</p></li>&#xA;<li><p>$B$ takes strictly fewer steps (on average; for probabilistic variants) on an infinite number of mazes.</p></li>&#xA;</ol>&#xA;&#xA;<p>My two questions:</p>&#xA;&#xA;<ol>&#xA;<li><p><strong>Is there a finite automaton <em>better than</em> the one drawn above?</strong> What if we allow probabilistic transducers?</p></li>&#xA;<li><p><strong>Is there a finite automaton for solving mazes that are not necessarily simply-connected?</strong></p></li>&#xA;</ol>&#xA;
automata finite automata artificial intelligence
1
Optimal myopic maze solver -- (automata finite automata artificial intelligence) <p>I was fooling around with <a href="http://neil.fraser.name/software/blockly/demos/maze/index.html" rel="nofollow noreferrer">Google Blocky's Maze demo</a>, and remembered the old rule that if you want to solve a maze, just keep your left hand to the wall. This works for any simple-connected maze and can be implemented by a finite transducer.</p>&#xA;&#xA;<p>Let our robot be represented by a transducer with the following actions, and observables:</p>&#xA;&#xA;<ul>&#xA;<li>Actions: go forward ($\uparrow$), turn left ($\leftarrow$), turn right ($\rightarrow$)</li>&#xA;<li>Observables: wall ahead ($\bot$), no wall ahead ($\top$)</li>&#xA;</ul>&#xA;&#xA;<p>Then we can build the left-hand maze solver as (pardon my lazy drawing):</p>&#xA;&#xA;<p><img src="https://i.stack.imgur.com/vAnFO.png" alt="transducer to solve the maze"></p>&#xA;&#xA;<p>Where seeing an observable will make us follow the appropriate edge out of the state while executing the action associated with that edge. This automaton will solve all simply-connected mazes, although it might take its time following dead ends. We call another automaton $B$ <em>better than</em> $A$ if:</p>&#xA;&#xA;<ol>&#xA;<li><p>$B$ takes strictly more steps on only a finite number of mazes, and</p></li>&#xA;<li><p>$B$ takes strictly fewer steps (on average; for probabilistic variants) on an infinite number of mazes.</p></li>&#xA;</ol>&#xA;&#xA;<p>My two questions:</p>&#xA;&#xA;<ol>&#xA;<li><p><strong>Is there a finite automaton <em>better than</em> the one drawn above?</strong> What if we allow probabilistic transducers?</p></li>&#xA;<li><p><strong>Is there a finite automaton for solving mazes that are not necessarily simply-connected?</strong></p></li>&#xA;</ol>&#xA;
habedi/stack-exchange-dataset
2,204
Do the minimum spanning trees of a weighted graph have the same number of edges with a given weight?
<p>If a weighted graph $G$ has two different minimum spanning trees $T_1 = (V_1, E_1)$ and $T_2 = (V_2, E_2)$, then is it true that for any edge $e$ in $E_1$, the number of edges in $E_1$ with the same weight as $e$ (including $e$ itself) is the same as the number of edges in $E_2$ with the same weight as $e$? If the statement is true, then how can we prove it?</p>&#xA;
graphs spanning trees weighted graphs
1
Do the minimum spanning trees of a weighted graph have the same number of edges with a given weight? -- (graphs spanning trees weighted graphs) <p>If a weighted graph $G$ has two different minimum spanning trees $T_1 = (V_1, E_1)$ and $T_2 = (V_2, E_2)$, then is it true that for any edge $e$ in $E_1$, the number of edges in $E_1$ with the same weight as $e$ (including $e$ itself) is the same as the number of edges in $E_2$ with the same weight as $e$? If the statement is true, then how can we prove it?</p>&#xA;
habedi/stack-exchange-dataset
2,206
Advanced placement CS A Exam
<p>What would be the standard topics covered in an 'Advanced Placement Computer Science A' test? Is there any good study reference someone can share? </p>&#xA;&#xA;<p><strong>Edit: Answer</strong></p>&#xA;&#xA;<p>An adjustment for my search term returned a <a href="http://en.wikipedia.org/wiki/Advanced_Placement_Computer_Science" rel="nofollow">Wikipedia page</a> just for this type of exam and the AB version.</p>&#xA;
reference request education
1
Advanced placement CS A Exam -- (reference request education) <p>What would be the standard topics covered in an 'Advanced Placement Computer Science A' test? Is there any good study reference someone can share? </p>&#xA;&#xA;<p><strong>Edit: Answer</strong></p>&#xA;&#xA;<p>An adjustment for my search term returned a <a href="http://en.wikipedia.org/wiki/Advanced_Placement_Computer_Science" rel="nofollow">Wikipedia page</a> just for this type of exam and the AB version.</p>&#xA;
habedi/stack-exchange-dataset
2,212
Show that the halting problem is decidable for one-pass Turing machines
<p>$L=\{&lt;\!M,x\!&gt;\, \mid M's \text{ transition function can only move right and } M\text{ halts on } x \}$. I need to show that $L$ is recursive/decidable.</p>&#xA;&#xA;<p>I thought of checking the encoding of $M$ first and determine whether its transition function moves only right (Can I do that?). If so then try to simulate $M$ on $x$ for $|Q|+1$ steps, if it stops then $&lt;\!M,x\!&gt;\, \in L$ otherwise it is not.</p>&#xA;&#xA;<p>Is this correct?</p>&#xA;
formal languages computability turing machines check my proof
1
Show that the halting problem is decidable for one-pass Turing machines -- (formal languages computability turing machines check my proof) <p>$L=\{&lt;\!M,x\!&gt;\, \mid M's \text{ transition function can only move right and } M\text{ halts on } x \}$. I need to show that $L$ is recursive/decidable.</p>&#xA;&#xA;<p>I thought of checking the encoding of $M$ first and determine whether its transition function moves only right (Can I do that?). If so then try to simulate $M$ on $x$ for $|Q|+1$ steps, if it stops then $&lt;\!M,x\!&gt;\, \in L$ otherwise it is not.</p>&#xA;&#xA;<p>Is this correct?</p>&#xA;
habedi/stack-exchange-dataset
2,218
Turing machine and language decidability
<p>The document I am reading is here: <a href="http://www.cs.odu.edu/~toida/nerzic/390teched/tm/definitions.html" rel="nofollow noreferrer">Turing Machines</a></p>&#xA;&#xA;<p>Before getting into the question, here is the notation used on the picture:</p>&#xA;&#xA;<blockquote>&#xA; <p>Here $\Delta$ denotes the blank and R, L and S denote move the head right, left&#xA; and do not move it, respectively. A transition diagram can also be&#xA; drawn for a Turing machine. The states are represented by vertices and&#xA; for a transition $\delta( q, X ) = ( r, Y, D )$ , where D represents R, L &#xA; or S , an arc from q to r is drawn with&#xA; label ( X/Y , D ) indicating that the state is changed from q to r,&#xA; the symbol X currently being read is changed to Y and the tape head is&#xA; moved as directed by D.</p>&#xA;</blockquote>&#xA;&#xA;<p>According to the document:</p>&#xA;&#xA;<blockquote>&#xA; <p>A Turing machine T is said to decide a language L if and only if T&#xA; writes "yes" and halts if a string is in L and T writes "no" and halts&#xA; if a string is not in L</p>&#xA;</blockquote>&#xA;&#xA;<p>Here is the three examples:</p>&#xA;&#xA;<ul>&#xA;<li>Case 1:</li>&#xA;</ul>&#xA;&#xA;<p><img src="https://i.stack.imgur.com/lGDWj.jpg" alt="Case 1"></p>&#xA;&#xA;<ul>&#xA;<li>Case 2:</li>&#xA;</ul>&#xA;&#xA;<p><img src="https://i.stack.imgur.com/SlYEj.jpg" alt="Case 2"></p>&#xA;&#xA;<ul>&#xA;<li>Case 3:</li>&#xA;</ul>&#xA;&#xA;<p><img src="https://i.stack.imgur.com/Eextt.jpg" alt="Case 3"></p>&#xA;&#xA;<p>I just want to verify my understanding. According to the definition, in case 1 and case 2, its turing machines cannot decide because the machines cannot tell whether invalid inputs rather than { a } (such as aa, aaa, aaaa....) is in L or not. </p>&#xA;&#xA;<p>In case 2, if another a appears after the first a, or if the input is empty, the machine goes to state S and loop forever. </p>&#xA;&#xA;<p>In case 3, if <code>a</code> is detected and only a single <code>a</code> exists, that <code>a</code> is replaced by <code>1</code> and the machine accepts. Otherwise, a <code>0</code> is replaced and the input is decided not in the language.</p>&#xA;&#xA;<p>Am I correct on all of these? However, in case 3, what if I give any input which contains other character rather than <code>a</code> (such as string <code>ab</code>, <code>bc</code>...)? Or is it said that TM decides only languages over a set of alphabet $\Sigma$ allowed by the Turing Machine?</p>&#xA;&#xA;<p>If a string which is longer than a single <code>a</code> (like <code>aa</code>, <code>aaa</code>,<code>ab</code>,<code>bc</code>...), the machine may loop forever (like in case 2) or halt without accepting (in other words, it is "crashed", where it does not have transition rules for a symbol in the input such as <code>b</code> in the case of above Turing Machines). Is this correct also?</p>&#xA;
computability turing machines
1
Turing machine and language decidability -- (computability turing machines) <p>The document I am reading is here: <a href="http://www.cs.odu.edu/~toida/nerzic/390teched/tm/definitions.html" rel="nofollow noreferrer">Turing Machines</a></p>&#xA;&#xA;<p>Before getting into the question, here is the notation used on the picture:</p>&#xA;&#xA;<blockquote>&#xA; <p>Here $\Delta$ denotes the blank and R, L and S denote move the head right, left&#xA; and do not move it, respectively. A transition diagram can also be&#xA; drawn for a Turing machine. The states are represented by vertices and&#xA; for a transition $\delta( q, X ) = ( r, Y, D )$ , where D represents R, L &#xA; or S , an arc from q to r is drawn with&#xA; label ( X/Y , D ) indicating that the state is changed from q to r,&#xA; the symbol X currently being read is changed to Y and the tape head is&#xA; moved as directed by D.</p>&#xA;</blockquote>&#xA;&#xA;<p>According to the document:</p>&#xA;&#xA;<blockquote>&#xA; <p>A Turing machine T is said to decide a language L if and only if T&#xA; writes "yes" and halts if a string is in L and T writes "no" and halts&#xA; if a string is not in L</p>&#xA;</blockquote>&#xA;&#xA;<p>Here is the three examples:</p>&#xA;&#xA;<ul>&#xA;<li>Case 1:</li>&#xA;</ul>&#xA;&#xA;<p><img src="https://i.stack.imgur.com/lGDWj.jpg" alt="Case 1"></p>&#xA;&#xA;<ul>&#xA;<li>Case 2:</li>&#xA;</ul>&#xA;&#xA;<p><img src="https://i.stack.imgur.com/SlYEj.jpg" alt="Case 2"></p>&#xA;&#xA;<ul>&#xA;<li>Case 3:</li>&#xA;</ul>&#xA;&#xA;<p><img src="https://i.stack.imgur.com/Eextt.jpg" alt="Case 3"></p>&#xA;&#xA;<p>I just want to verify my understanding. According to the definition, in case 1 and case 2, its turing machines cannot decide because the machines cannot tell whether invalid inputs rather than { a } (such as aa, aaa, aaaa....) is in L or not. </p>&#xA;&#xA;<p>In case 2, if another a appears after the first a, or if the input is empty, the machine goes to state S and loop forever. </p>&#xA;&#xA;<p>In case 3, if <code>a</code> is detected and only a single <code>a</code> exists, that <code>a</code> is replaced by <code>1</code> and the machine accepts. Otherwise, a <code>0</code> is replaced and the input is decided not in the language.</p>&#xA;&#xA;<p>Am I correct on all of these? However, in case 3, what if I give any input which contains other character rather than <code>a</code> (such as string <code>ab</code>, <code>bc</code>...)? Or is it said that TM decides only languages over a set of alphabet $\Sigma$ allowed by the Turing Machine?</p>&#xA;&#xA;<p>If a string which is longer than a single <code>a</code> (like <code>aa</code>, <code>aaa</code>,<code>ab</code>,<code>bc</code>...), the machine may loop forever (like in case 2) or halt without accepting (in other words, it is "crashed", where it does not have transition rules for a symbol in the input such as <code>b</code> in the case of above Turing Machines). Is this correct also?</p>&#xA;
habedi/stack-exchange-dataset
2,222
Are there complete problems for P and NP under other kinds of reductions?
<p>I know that the complexity class $\mathsf{P}$ has complete problems w.r.t. $\mathsf{NC}$ and $\mathsf{L}$ reductions.</p>&#xA;&#xA;<p>Are these two classes the only possible classes of reductions under which $\mathsf{P}$ has complete problems? </p>&#xA;&#xA;<p>Also, what classes of reduction can be used for $\mathsf{NP}$ beside polynomial-time reductions?</p>&#xA;
complexity theory reductions
1
Are there complete problems for P and NP under other kinds of reductions? -- (complexity theory reductions) <p>I know that the complexity class $\mathsf{P}$ has complete problems w.r.t. $\mathsf{NC}$ and $\mathsf{L}$ reductions.</p>&#xA;&#xA;<p>Are these two classes the only possible classes of reductions under which $\mathsf{P}$ has complete problems? </p>&#xA;&#xA;<p>Also, what classes of reduction can be used for $\mathsf{NP}$ beside polynomial-time reductions?</p>&#xA;
habedi/stack-exchange-dataset
2,225
Point Location Problem in Polygon in Repetitive Mode for a Simple Polygon
<p>I consider <a href="http://en.wikipedia.org/wiki/Point_in_polygon" rel="nofollow">Point Location Problem in Polygon</a> in repetitive mode in the case of simple polygon.</p>&#xA;&#xA;<p>In computational geometry,Point Location Problem in Polygon problem asks whether a given point in the plane lies inside, outside, or on the boundary of a polygon.</p>&#xA;&#xA;<p>There are few method that work in Single-Shot approach, where the input is a polygon $P$ and a single point $q$ (no preprocessing time). Ray casting algorithm is the famous algorithm for single-shot, it takes $O(n)$ to determine whether a point $q$ belongs to polygon $P$. </p>&#xA;&#xA;<p>In addition, there is a repetitive approach, where instead of single point $q$ we should check the sequence of points, therefore the preprocessing is required. Division wedge is a algorithm that works in repetitive mode. Query time of division wedge is $O(\log n)$ and preprocessing time is $O(n)$. Division wedge assumes that there is a central point in polygon, visible from every vertex of polygon (part of the kernel of the polygon). The problem is a central point can be easily determined in convex polygon as well as in star-shaped polygon, but what to do in the case of simple polygon.</p>&#xA;&#xA;<p>If division wedge is applied in the case of simple polygon how we can determine a central point in simple polygon? If division edge in not applied if there is the more efficient way to solve a problem in simple polygon than in arbitrary planar subdivision.</p>&#xA;
algorithms computational geometry
1
Point Location Problem in Polygon in Repetitive Mode for a Simple Polygon -- (algorithms computational geometry) <p>I consider <a href="http://en.wikipedia.org/wiki/Point_in_polygon" rel="nofollow">Point Location Problem in Polygon</a> in repetitive mode in the case of simple polygon.</p>&#xA;&#xA;<p>In computational geometry,Point Location Problem in Polygon problem asks whether a given point in the plane lies inside, outside, or on the boundary of a polygon.</p>&#xA;&#xA;<p>There are few method that work in Single-Shot approach, where the input is a polygon $P$ and a single point $q$ (no preprocessing time). Ray casting algorithm is the famous algorithm for single-shot, it takes $O(n)$ to determine whether a point $q$ belongs to polygon $P$. </p>&#xA;&#xA;<p>In addition, there is a repetitive approach, where instead of single point $q$ we should check the sequence of points, therefore the preprocessing is required. Division wedge is a algorithm that works in repetitive mode. Query time of division wedge is $O(\log n)$ and preprocessing time is $O(n)$. Division wedge assumes that there is a central point in polygon, visible from every vertex of polygon (part of the kernel of the polygon). The problem is a central point can be easily determined in convex polygon as well as in star-shaped polygon, but what to do in the case of simple polygon.</p>&#xA;&#xA;<p>If division wedge is applied in the case of simple polygon how we can determine a central point in simple polygon? If division edge in not applied if there is the more efficient way to solve a problem in simple polygon than in arbitrary planar subdivision.</p>&#xA;
habedi/stack-exchange-dataset
2,233
Automata that recognizes Kleene closure of permutations of three symbols
<p>This is an automata theory homework question.</p>&#xA;&#xA;<p>I need to create DFA that meets the following criteria: </p>&#xA;&#xA;<ul>&#xA;<li><p>Alphabet $\Sigma = \{ a, b, c \}$</p></li>&#xA;<li><p>Machine accepts empty string and strings of length that is a multiple of three, with every block of three containing one $a$, one $b$ and one $c$.</p></li>&#xA;</ul>&#xA;&#xA;<p>So far, I came up with this machine, it is obvious:</p>&#xA;&#xA;<p><img src="https://i.stack.imgur.com/r3rCz.jpg" alt="the machine"></p>&#xA;&#xA;<p>However, I can't get it to accept empty string. Does it mean there is a transition q0 → q3?</p>&#xA;&#xA;<p><strong>Update1:</strong> Following corrections by Dave Clarke I made some corrections.</p>&#xA;&#xA;<ol>&#xA;<li>A regular expression for this machine is $(www)^*$ where $w = \{abc,acb,…\}$. Therefore to represent multiple of three, I need to copy this (on the picture) machine 3 times. Final state should have arrows pointing to the first copy, for transitions marked 'a', 'b','c'. </li>&#xA;<li>As it was pointed out, since this is DFA, I need to add missing states. This can be accomplished by adding "dead" states. </li>&#xA;<li>Empty string should correspond to $\varepsilon$-transition from qStarting → qFinal.</li>&#xA;</ol>&#xA;&#xA;<p><strong>Update2:</strong> &#xA;As it was pointed out, my regular expression is wrong ! It should be $(w)^*$. Here is the final machine, that I think should be correct.(I didn't include "dead" state)<img src="https://i.stack.imgur.com/L3xZX.jpg" alt="enter image description here"></p>&#xA;
formal languages automata finite automata
1
Automata that recognizes Kleene closure of permutations of three symbols -- (formal languages automata finite automata) <p>This is an automata theory homework question.</p>&#xA;&#xA;<p>I need to create DFA that meets the following criteria: </p>&#xA;&#xA;<ul>&#xA;<li><p>Alphabet $\Sigma = \{ a, b, c \}$</p></li>&#xA;<li><p>Machine accepts empty string and strings of length that is a multiple of three, with every block of three containing one $a$, one $b$ and one $c$.</p></li>&#xA;</ul>&#xA;&#xA;<p>So far, I came up with this machine, it is obvious:</p>&#xA;&#xA;<p><img src="https://i.stack.imgur.com/r3rCz.jpg" alt="the machine"></p>&#xA;&#xA;<p>However, I can't get it to accept empty string. Does it mean there is a transition q0 → q3?</p>&#xA;&#xA;<p><strong>Update1:</strong> Following corrections by Dave Clarke I made some corrections.</p>&#xA;&#xA;<ol>&#xA;<li>A regular expression for this machine is $(www)^*$ where $w = \{abc,acb,…\}$. Therefore to represent multiple of three, I need to copy this (on the picture) machine 3 times. Final state should have arrows pointing to the first copy, for transitions marked 'a', 'b','c'. </li>&#xA;<li>As it was pointed out, since this is DFA, I need to add missing states. This can be accomplished by adding "dead" states. </li>&#xA;<li>Empty string should correspond to $\varepsilon$-transition from qStarting → qFinal.</li>&#xA;</ol>&#xA;&#xA;<p><strong>Update2:</strong> &#xA;As it was pointed out, my regular expression is wrong ! It should be $(w)^*$. Here is the final machine, that I think should be correct.(I didn't include "dead" state)<img src="https://i.stack.imgur.com/L3xZX.jpg" alt="enter image description here"></p>&#xA;
habedi/stack-exchange-dataset
2,235
Can joins be parallelized?
<p>Suppose we want to join two relations on a predicate. Is this in NC?</p>&#xA;&#xA;<p>I realize that a proof of it not being in NC would amount to a proof that $P\not=NC$, so I'd accept evidence of it being an open problem as an answer.</p>&#xA;&#xA;<p>I'm interested in the general case as well as specific cases (e.g. perhaps with some specific data structure it can be parallelized). </p>&#xA;&#xA;<p>EDIT: to bring some clarifications from the comments into this post:</p>&#xA;&#xA;<ul>&#xA;<li>We could consider an equijoin $A.x = B.y$. On a single processor, a hash-based algorithm runs in $O(|A|+|B|)$ and this is the best we can do since we have to read each set</li>&#xA;<li>If the predicate is a "black box" where we have to check each pair, there are $|A|\cdot|B|$ pairs, and each one could be in or not, so $2^{ab}$ possibilities. Checking each pair divides the possibilities in half, so the best we can do is $O(ab)$.</li>&#xA;</ul>&#xA;&#xA;<p>Could either of these (or some third type of join) be improved to $\log^k n$ on multiple processors?</p>&#xA;
complexity theory time complexity parallel computing database theory descriptive complexity
1
Can joins be parallelized? -- (complexity theory time complexity parallel computing database theory descriptive complexity) <p>Suppose we want to join two relations on a predicate. Is this in NC?</p>&#xA;&#xA;<p>I realize that a proof of it not being in NC would amount to a proof that $P\not=NC$, so I'd accept evidence of it being an open problem as an answer.</p>&#xA;&#xA;<p>I'm interested in the general case as well as specific cases (e.g. perhaps with some specific data structure it can be parallelized). </p>&#xA;&#xA;<p>EDIT: to bring some clarifications from the comments into this post:</p>&#xA;&#xA;<ul>&#xA;<li>We could consider an equijoin $A.x = B.y$. On a single processor, a hash-based algorithm runs in $O(|A|+|B|)$ and this is the best we can do since we have to read each set</li>&#xA;<li>If the predicate is a "black box" where we have to check each pair, there are $|A|\cdot|B|$ pairs, and each one could be in or not, so $2^{ab}$ possibilities. Checking each pair divides the possibilities in half, so the best we can do is $O(ab)$.</li>&#xA;</ul>&#xA;&#xA;<p>Could either of these (or some third type of join) be improved to $\log^k n$ on multiple processors?</p>&#xA;
habedi/stack-exchange-dataset
2,238
Turing Recognisable => enumerable
<p>I get the proof of going from an enumerator to a Turing Machine (keep running enumerator and see if it matches input) but I don't see how the other way works.</p>&#xA;&#xA;<p>According to my notes and the book (Intro to the Theory of Computation - Sipser), to get Turing enumerator from a Turing machine, we basically write all combinations of the alphabet. You then run the TM on this input, if it accepts print it out, replace with new string repeat ad infinitum.</p>&#xA;&#xA;<p>The problem I am having is surely this requires the language to be decidable. Otherwise it might get stuck on the third word in some infinite loop doomed never to accept or reject and certainly never print out the whole language. </p>&#xA;&#xA;<p>What am I missing?</p>&#xA;
computability turing machines intuition
1
Turing Recognisable => enumerable -- (computability turing machines intuition) <p>I get the proof of going from an enumerator to a Turing Machine (keep running enumerator and see if it matches input) but I don't see how the other way works.</p>&#xA;&#xA;<p>According to my notes and the book (Intro to the Theory of Computation - Sipser), to get Turing enumerator from a Turing machine, we basically write all combinations of the alphabet. You then run the TM on this input, if it accepts print it out, replace with new string repeat ad infinitum.</p>&#xA;&#xA;<p>The problem I am having is surely this requires the language to be decidable. Otherwise it might get stuck on the third word in some infinite loop doomed never to accept or reject and certainly never print out the whole language. </p>&#xA;&#xA;<p>What am I missing?</p>&#xA;
habedi/stack-exchange-dataset