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 |
|---|---|---|---|---|---|---|
84,026 | What algorithm to use for this kind of routing optimization? | <p>Let's imagine a situation in order to fully understand the problem : let's say a lone human is walking back home at a very late time. He needs to find the safest path home. He naturally use the GPS with a start point A and a destination point B. Now the data I have may be GPS locations with an information stating th... | algorithms graphs optimization traveling salesman | 1 | What algorithm to use for this kind of routing optimization? -- (algorithms graphs optimization traveling salesman)
<p>Let's imagine a situation in order to fully understand the problem : let's say a lone human is walking back home at a very late time. He needs to find the safest path home. He naturally use the GPS wit... | habedi/stack-exchange-dataset |
84,031 | Clarification on class $SPP$? | <p>A language $L$ is in $SPP$ if there is a $GapP$ function $f$ such that</p>

<p>$x\in L\implies f(x)=1$ and $x\not\in L\implies f(x)=0$.</p>

<p>By $x\not\in L$ I think we mean $x\not\in SPP$ correct? </p>

<p>I would have thought $x\not\in L$ if there is no such $f$. Why is it not defined thi... | complexity theory complexity classes | 1 | Clarification on class $SPP$? -- (complexity theory complexity classes)
<p>A language $L$ is in $SPP$ if there is a $GapP$ function $f$ such that</p>

<p>$x\in L\implies f(x)=1$ and $x\not\in L\implies f(x)=0$.</p>

<p>By $x\not\in L$ I think we mean $x\not\in SPP$ correct? </p>

<p>I would have... | habedi/stack-exchange-dataset |
84,035 | Is the set of languages recognized by a Turing machine with an oracle countable? | <p>I am currently taking a class in complexity theory and I am struggling with this question. </p>

<p>We define a TM with Oracle per. Sipser 6.18 as: </p>

<p>"An oracle for language $B$ is an external device that is capable of reporting whether any string $w$ is a member of $B$. An oracle Turing machi... | complexity theory turing machines oracle machines | 1 | Is the set of languages recognized by a Turing machine with an oracle countable? -- (complexity theory turing machines oracle machines)
<p>I am currently taking a class in complexity theory and I am struggling with this question. </p>

<p>We define a TM with Oracle per. Sipser 6.18 as: </p>

<p>"An orac... | habedi/stack-exchange-dataset |
84,037 | Decidability of CFG that accepts at least one odd length string | <blockquote>
 <p>Let $L$ be the language$\{\langle G \rangle : G\text{ is a CFG and L(G) accepts at least one odd-length strings}\}$.</p>
 
 <p>Prove that $L$ is decidable or undecidable.</p>
</blockquote>

<p>Here is my attempt:</p>

<p>$L$ = On input $\langle G \rangle$, where $\lan... | computability turing machines context free | 1 | Decidability of CFG that accepts at least one odd length string -- (computability turing machines context free)
<blockquote>
 <p>Let $L$ be the language$\{\langle G \rangle : G\text{ is a CFG and L(G) accepts at least one odd-length strings}\}$.</p>
 
 <p>Prove that $L$ is decidable or undecidable.</p>&#... | habedi/stack-exchange-dataset |
84,039 | Computing Hamming Distance Between Binary Vectors | <p>Consider the following problem: </p>

<p><strong>Input:</strong> We are given a set $S$ of $n$ binary vectors. A binary vector is of the form $(b_0, b_1, ... b_n)$, where $b_i \in \{0, 1\}$. Therefore, there are $n$ vectors of size $n$. </p>

<p><strong>Output:</strong> For each vector in $S$, we wou... | algorithms hamming code binary | 1 | Computing Hamming Distance Between Binary Vectors -- (algorithms hamming code binary)
<p>Consider the following problem: </p>

<p><strong>Input:</strong> We are given a set $S$ of $n$ binary vectors. A binary vector is of the form $(b_0, b_1, ... b_n)$, where $b_i \in \{0, 1\}$. Therefore, there are $n$ vectors... | habedi/stack-exchange-dataset |
84,043 | Longest path among subset of given points | <p>I am looking for an efficient algorithm to solve the following problem:</p>

<p>Given $n$ points in 2D Cartesian space $p_1,\dots,p_n \in \mathbb{R}^2$ and an integer $m$, we want to find $s_1,\dots,s_m$ such that $1 \le s_1 < s_2 < \cdots < s_m \le n$ and that maximizes</p>

<p>$$\sum_{i=1}... | algorithms optimization time complexity computational geometry | 1 | Longest path among subset of given points -- (algorithms optimization time complexity computational geometry)
<p>I am looking for an efficient algorithm to solve the following problem:</p>

<p>Given $n$ points in 2D Cartesian space $p_1,\dots,p_n \in \mathbb{R}^2$ and an integer $m$, we want to find $s_1,\dots,... | habedi/stack-exchange-dataset |
84,048 | Infinite sequence of graphs | <p><a href="http://jgaa.info/accepted/2011/HasheminezhadMcKayReeves2011.15.3.pdf" rel="nofollow noreferrer">http://jgaa.info/accepted/2011/HasheminezhadMcKayReeves2011.15.3.pdf</a>
<br> Hello I stumbled upon this paper. On page $4/20$ the figure shows an infinite sequence of $5-$regular, connected planar graphs. Bu... | graphs planar graphs | 1 | Infinite sequence of graphs -- (graphs planar graphs)
<p><a href="http://jgaa.info/accepted/2011/HasheminezhadMcKayReeves2011.15.3.pdf" rel="nofollow noreferrer">http://jgaa.info/accepted/2011/HasheminezhadMcKayReeves2011.15.3.pdf</a>
<br> Hello I stumbled upon this paper. On page $4/20$ the figure shows an infinit... | habedi/stack-exchange-dataset |
84,054 | Are empty-set languages recursively enumerable? | <p>Are languages whose sets are empty recursively enumerable or recursive? For example, consider the language $L$ $\subseteq$ {0,1}*:</p>

<blockquote>
 <p>$L$ = { $w$ | $w$ consists of only 0's} $\cap$ { $w$ | $w$ consists of only 1's }</p>
</blockquote>

<p>I believe this language creates an ... | formal languages turing machines | 1 | Are empty-set languages recursively enumerable? -- (formal languages turing machines)
<p>Are languages whose sets are empty recursively enumerable or recursive? For example, consider the language $L$ $\subseteq$ {0,1}*:</p>

<blockquote>
 <p>$L$ = { $w$ | $w$ consists of only 0's} $\cap$ { $w$ | $w$ consis... | habedi/stack-exchange-dataset |
84,056 | Proof of existence of prefix in NFA | <p>Let $$A= (Q,Σ,δ,s,F)$$ be a NFA. Prove the following statement:</p>

<p>$∀q ∈ Q: (∃ w_2 ∈ Σ^* :δ (q, w_2) ∩ F \ne ∅ ⇒ ∃w_1 ∈ Σ^*:w_1w_2 ∈ L(A))$</p>

<p>I figured out that it means that if all the states have a path to the final state, that the <strong>word</strong> describing their path is a suffix... | regular languages finite automata | 1 | Proof of existence of prefix in NFA -- (regular languages finite automata)
<p>Let $$A= (Q,Σ,δ,s,F)$$ be a NFA. Prove the following statement:</p>

<p>$∀q ∈ Q: (∃ w_2 ∈ Σ^* :δ (q, w_2) ∩ F \ne ∅ ⇒ ∃w_1 ∈ Σ^*:w_1w_2 ∈ L(A))$</p>

<p>I figured out that it means that if all the states have a path to the fi... | habedi/stack-exchange-dataset |
84,070 | Lower bounding DFA | <p>If the regular language $L$ is defined as $\{ w \in \Sigma^* \mid |w| \leq 140 \}$. Why does any DFA for it must have at least 142 states? Why not only 140 states? </p>
 | finite automata | 1 | Lower bounding DFA -- (finite automata)
<p>If the regular language $L$ is defined as $\{ w \in \Sigma^* \mid |w| \leq 140 \}$. Why does any DFA for it must have at least 142 states? Why not only 140 states? </p>
 | habedi/stack-exchange-dataset |
84,076 | If a problem is Cook-NP hard, and this problem is in NP, does it prove that the problem is Karp-NP-complete? | <p>I got recently confused when I noticed that there exists 2 types of polytime reductions, which lead to 2 different concepts of NP-hardness.</p>

<p>This is well explained in the answer to this question:
<a href="https://cs.stackexchange.com/questions/11120/">Can one show NP-hardness by Turing reductions?... | complexity theory np complete np hard | 1 | If a problem is Cook-NP hard, and this problem is in NP, does it prove that the problem is Karp-NP-complete? -- (complexity theory np complete np hard)
<p>I got recently confused when I noticed that there exists 2 types of polytime reductions, which lead to 2 different concepts of NP-hardness.</p>

<p>This is w... | habedi/stack-exchange-dataset |
84,079 | Looping through random integers - will it halt with probability 1? | <p>Say I have a simple program that has the pseudocode like this:</p>

<pre><code>min = 1
max = 100
c = 5
random = randomInt(min,max)
while(c != random):
 random = randomInt(min,max);
</code></pre>

<p>Theoretically, from what I understand, I cannot guarantee this will halt. H... | halting problem randomness pseudo random generators | 1 | Looping through random integers - will it halt with probability 1? -- (halting problem randomness pseudo random generators)
<p>Say I have a simple program that has the pseudocode like this:</p>

<pre><code>min = 1
max = 100
c = 5
random = randomInt(min,max)
while(c != random):
 random = r... | habedi/stack-exchange-dataset |
84,081 | 3 blocks CBC-MAC | <p>Let $M=(m_1, m_2)$, $M'= (m_0', m_1')$ be two two-block messages. </p>

<p>In other words, $|m_1|=|m_2|=|m_1'|=|m_2'|=n$.</p>

<p>We say that $M, M'$ <strong>collide</strong> for key $k$ if</p>

<p>$$E_k(E_k(m_1)⊕m_2) = E_k(E_k(m_1')⊕m_2').$$</p>

<p>How many two-block messages should... | cryptography | 1 | 3 blocks CBC-MAC -- (cryptography)
<p>Let $M=(m_1, m_2)$, $M'= (m_0', m_1')$ be two two-block messages. </p>

<p>In other words, $|m_1|=|m_2|=|m_1'|=|m_2'|=n$.</p>

<p>We say that $M, M'$ <strong>collide</strong> for key $k$ if</p>

<p>$$E_k(E_k(m_1)⊕m_2) = E_k(E_k(m_1')⊕m_2').$$</p>

<p... | habedi/stack-exchange-dataset |
84,082 | Equivalence classes of regular languages | <p>One used equivalence relation in regular languages is that for a language $L$ over alphabet $\Sigma$, $(x\sim^Ly)\Leftrightarrow (\forall w\in \Sigma^* xw\in L \Leftrightarrow yw\in L)$.</p>

<p>That means, if two words $x,y$ are not in the same class, there exists $w\in \Sigma^*$ such that $xw\in L$ but $yw... | formal languages regular languages | 1 | Equivalence classes of regular languages -- (formal languages regular languages)
<p>One used equivalence relation in regular languages is that for a language $L$ over alphabet $\Sigma$, $(x\sim^Ly)\Leftrightarrow (\forall w\in \Sigma^* xw\in L \Leftrightarrow yw\in L)$.</p>

<p>That means, if two words $x,y$ ar... | habedi/stack-exchange-dataset |
84,097 | Increasing every starting edge by a constant, then the shortest path tree remains the same? | <blockquote>
 <p>Consider a directed graph <code>G = (V,E)</code> with non-negative costs on each edge.
 With <code>s</code> being a starting vertex. Prove that by adding a constant <code>k</code> to each edge 
 <code>(s,u) ∈ E</code> such as <code>u ∈ V</code>, the shortest path tree starting from <code... | graphs trees shortest path | 1 | Increasing every starting edge by a constant, then the shortest path tree remains the same? -- (graphs trees shortest path)
<blockquote>
 <p>Consider a directed graph <code>G = (V,E)</code> with non-negative costs on each edge.
 With <code>s</code> being a starting vertex. Prove that by adding a constant <cod... | habedi/stack-exchange-dataset |
84,117 | How can I find the center character of a two-tape Turing Machine in n transitions? | <p>The problem I have been given is to find a two-tape ND Turing Machine over {a,b,c} that only accepts odd length strings with a c in the middle position. The problem with this is that the question specifies that it must be done in n+2 transitions.</p>

<p>I can figure out how to do it in 1.5 * n transitions, ... | formal languages turing machines | 1 | How can I find the center character of a two-tape Turing Machine in n transitions? -- (formal languages turing machines)
<p>The problem I have been given is to find a two-tape ND Turing Machine over {a,b,c} that only accepts odd length strings with a c in the middle position. The problem with this is that the question ... | habedi/stack-exchange-dataset |
84,120 | How to eliminate context-free grammar's ambiguity | <p>I want to write a CFG that generates the words over {a,b} with the same number of ocurrences of a's and b's.</p>

<p>I have come up with a couple of possibilties so far. I think they're correct but they're all ambiguous, and I want the grammar to be non-ambiguous, this is one option:</p>

<pre><code>... | context free formal grammars ambiguity | 1 | How to eliminate context-free grammar's ambiguity -- (context free formal grammars ambiguity)
<p>I want to write a CFG that generates the words over {a,b} with the same number of ocurrences of a's and b's.</p>

<p>I have come up with a couple of possibilties so far. I think they're correct but they're all ambig... | habedi/stack-exchange-dataset |
84,127 | Maximum value of LOOP-Program turing-computable | <p>Lets consider the class of "simple" LOOP-Programs.</p>

<p>A LOOP-Program P is inducively defined as:</p>

<p>$P_1: x_i = x_j$ and $P_2:x_i = x_i +1$ are LOOP-Programs. We also define a length property $l(P)$ where $l(P_1) = l(P_2) = 1$</p>

<p>P: $P_1;P_2$ is also LOOP. (sequential executio... | computability loops check my answer | 1 | Maximum value of LOOP-Program turing-computable -- (computability loops check my answer)
<p>Lets consider the class of "simple" LOOP-Programs.</p>

<p>A LOOP-Program P is inducively defined as:</p>

<p>$P_1: x_i = x_j$ and $P_2:x_i = x_i +1$ are LOOP-Programs. We also define a length property $l(P)$ wh... | habedi/stack-exchange-dataset |
84,133 | Flows with Negative Values? | <p>Define a "non-standard" flow to be a flow where the quantity flowing through an edge may be negative.</p>

<blockquote>
 <p>Formally, given a directed graph $G$, and two designated and distinct
 vertices $s$ and $t$ (such that no edges are leaving $t$, and no edges
 are entering $s$), a non-st... | network flow | 1 | Flows with Negative Values? -- (network flow)
<p>Define a "non-standard" flow to be a flow where the quantity flowing through an edge may be negative.</p>

<blockquote>
 <p>Formally, given a directed graph $G$, and two designated and distinct
 vertices $s$ and $t$ (such that no edges are leaving $t$, ... | habedi/stack-exchange-dataset |
84,135 | Vertex deletion to perfect matching | <p>You are given a Graph G and an integer k.</p>

<p>The question is: Does G contain a vertex set X of size at most k such that deleting X results in a graph of degree at most 1?</p>

<p>Design an FPT (or a kernelization) algorithm for this problem and argue why it is correct.</p>

<p>Hint: Obse... | graphs kernel functions | 1 | Vertex deletion to perfect matching -- (graphs kernel functions)
<p>You are given a Graph G and an integer k.</p>

<p>The question is: Does G contain a vertex set X of size at most k such that deleting X results in a graph of degree at most 1?</p>

<p>Design an FPT (or a kernelization) algorithm for thi... | habedi/stack-exchange-dataset |
84,146 | If a CNF contains only Horn and Xor clauses, then what is the complexity of determining Satisfiability? | <p>If a CNF contains only Horn and Xor clauses, and does not contain clauses of other types, then can its Satisfiability be determined in polynomial time?</p>
 | complexity theory time complexity satisfiability sat solvers | 1 | If a CNF contains only Horn and Xor clauses, then what is the complexity of determining Satisfiability? -- (complexity theory time complexity satisfiability sat solvers)
<p>If a CNF contains only Horn and Xor clauses, and does not contain clauses of other types, then can its Satisfiability be determined in polynomial t... | habedi/stack-exchange-dataset |
84,154 | Why is log(n) a space-constructible function? | <p>According to <a href="https://en.wikipedia.org/wiki/Constructible_function" rel="nofollow noreferrer">"Constructible function"</a>, Wikipedia:</p>

<blockquote>
 <p>In <a href="https://en.wikipedia.org/wiki/Computational_complexity_theory" rel="nofollow noreferrer">complexity theory</a>, a time-construc... | time complexity | 1 | Why is log(n) a space-constructible function? -- (time complexity)
<p>According to <a href="https://en.wikipedia.org/wiki/Constructible_function" rel="nofollow noreferrer">"Constructible function"</a>, Wikipedia:</p>

<blockquote>
 <p>In <a href="https://en.wikipedia.org/wiki/Computational_complexity_theor... | habedi/stack-exchange-dataset |
84,157 | Given a Turing Machine M, are there infinitely many Turing machines that recognize L(M)? | <p>I want to show this problem is decidable by describing a TM that answers the question.<br>
I originally thought this was quite simple, and that the answer would just be a TM that outputs "yes" for any valid input of a TM <em>M</em>. My reasoning was that given any TM <em>M</em>, we can just add a new unreachable... | turing machines | 1 | Given a Turing Machine M, are there infinitely many Turing machines that recognize L(M)? -- (turing machines)
<p>I want to show this problem is decidable by describing a TM that answers the question.<br>
I originally thought this was quite simple, and that the answer would just be a TM that outputs "yes" for any va... | habedi/stack-exchange-dataset |
84,159 | Do Kruskal's and Prim's algorithms yield the same minimum spanning tree? | <p>Assuming the edges are undirected, have unique weight, and no negative paths, do these algorithms produce the same Minimum Spanning Trees?</p>
 | graphs trees minimum spanning tree | 1 | Do Kruskal's and Prim's algorithms yield the same minimum spanning tree? -- (graphs trees minimum spanning tree)
<p>Assuming the edges are undirected, have unique weight, and no negative paths, do these algorithms produce the same Minimum Spanning Trees?</p>
 | habedi/stack-exchange-dataset |
84,161 | Does approximation ratio depend on the input size $n$? | <p>I have started study of approximation algorithms and have confusion about the definition of <em>approximation algorithm</em>. I have two textbooks: by Cormen and the second one by Williamson.</p>

<p>Cormen's textbook says</p>

<blockquote>
 <p>If an algorithm achieves an approximation ratio of ... | algorithms approximation | 1 | Does approximation ratio depend on the input size $n$? -- (algorithms approximation)
<p>I have started study of approximation algorithms and have confusion about the definition of <em>approximation algorithm</em>. I have two textbooks: by Cormen and the second one by Williamson.</p>

<p>Cormen's textbook says</... | habedi/stack-exchange-dataset |
84,187 | How to restore a broken minimal spanning tree? | <blockquote>
 <p>We're given $T$ a minimal spanning tree (MST) of a non-directed, connected graph $G=(V,E)$ with non-negative weights for each edge $e \in E$. Let $e^* \in T$ be an edge in $T$ and let $G'=(V,E')$ be the graph which we get after removing $e^*$ ($E'=E\setminus \{e^*\}$). $G'$ is also connected. </p>... | algorithms graphs weighted graphs minimum spanning tree | 1 | How to restore a broken minimal spanning tree? -- (algorithms graphs weighted graphs minimum spanning tree)
<blockquote>
 <p>We're given $T$ a minimal spanning tree (MST) of a non-directed, connected graph $G=(V,E)$ with non-negative weights for each edge $e \in E$. Let $e^* \in T$ be an edge in $T$ and let $G'=(V... | habedi/stack-exchange-dataset |
84,189 | How to get the optimized quicksort algorithm's time complexity | <p>I learned in my data structures class that QuickSort can be optimized by calling the InsertionSort method when the length of the subarray is less than a certain threshold. However, when it comes to the actual time complexity calculation of the optimized version of QuickSort, I'm having trouble finding the result. Th... | algorithms algorithm analysis optimization time complexity quicksort | 1 | How to get the optimized quicksort algorithm's time complexity -- (algorithms algorithm analysis optimization time complexity quicksort)
<p>I learned in my data structures class that QuickSort can be optimized by calling the InsertionSort method when the length of the subarray is less than a certain threshold. However,... | habedi/stack-exchange-dataset |
84,193 | How to prove that for a full binary tree $T$ there's a series of frequencies such that Huffman alg. will produce $T$? | <blockquote>
 <p>How to prove that for a full (each node that's not a leaf has 2 nodes) binary tree $T$ of $n$ leaves there's a series of frequencies $f_1,f_2,...,f_n$ such that if we use Huffman algorithm on the series we'll get $T$?</p>
</blockquote>

<p>First in order to get frequencies from $T$ we ... | algorithms graphs trees huffman coding | 1 | How to prove that for a full binary tree $T$ there's a series of frequencies such that Huffman alg. will produce $T$? -- (algorithms graphs trees huffman coding)
<blockquote>
 <p>How to prove that for a full (each node that's not a leaf has 2 nodes) binary tree $T$ of $n$ leaves there's a series of frequencies $f_... | habedi/stack-exchange-dataset |
84,206 | Why are programs executed in main memory? | <p>Why are programs kept in main memory for execution? As per my understanding, we need a memory management scheme to manage several processes in the main memory. These things can be done in secondary memory as well (I think). Just to improve performance, we need main memory or there is something more to it?</p>
 | operating systems memory management | 1 | Why are programs executed in main memory? -- (operating systems memory management)
<p>Why are programs kept in main memory for execution? As per my understanding, we need a memory management scheme to manage several processes in the main memory. These things can be done in secondary memory as well (I think). Just to im... | habedi/stack-exchange-dataset |
84,211 | Finding a string with some specified hamming distances from other strings | <p>I'm searching the space of length $n$ strings (a-z lowercase), which I suppose we could represent as a large graph of strings and hamming distances between the strings.</p>

<p>I'm given some pairs of strings and distances $v_i, d_i$ . I need to find a string which has distance $d_i$ from each each string $v... | complexity theory graphs strings | 1 | Finding a string with some specified hamming distances from other strings -- (complexity theory graphs strings)
<p>I'm searching the space of length $n$ strings (a-z lowercase), which I suppose we could represent as a large graph of strings and hamming distances between the strings.</p>

<p>I'm given some pairs... | habedi/stack-exchange-dataset |
84,214 | Short quiz about Myhill-Nerode theorem | <p>Given is DFA M: </p>

<p><a href="https://i.stack.imgur.com/rrOFZ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/rrOFZ.png" alt="enter image description here"></a></p>

<p><a href="https://i.stack.imgur.com/y9S28.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/y... | formal languages regular languages automata finite automata | 1 | Short quiz about Myhill-Nerode theorem -- (formal languages regular languages automata finite automata)
<p>Given is DFA M: </p>

<p><a href="https://i.stack.imgur.com/rrOFZ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/rrOFZ.png" alt="enter image description here"></a></p>

<p><a hr... | habedi/stack-exchange-dataset |
84,234 | Showing the predicate $n \leq \sqrt2 < n+1$ is primitive recursive | <p>Let h(x) be the integer n such that $n \leq \sqrt2 < n+1$ Show that h(x) is primitive recursive.</p>

<p>I know how primitive recursive functions are defined, but showing an integer is primitive recursive is throwing me off. I need some help starting the proof.</p>
 | computability primitive recursion | 1 | Showing the predicate $n \leq \sqrt2 < n+1$ is primitive recursive -- (computability primitive recursion)
<p>Let h(x) be the integer n such that $n \leq \sqrt2 < n+1$ Show that h(x) is primitive recursive.</p>

<p>I know how primitive recursive functions are defined, but showing an integer is primitive recur... | habedi/stack-exchange-dataset |
84,242 | How can you define the notion of "state" using only a type theory language? | <p>The notion of state I'm referring to is the one described in this wikipedia page : <a href="https://en.m.wikipedia.org/wiki/State_(computer_science)" rel="nofollow noreferrer">https://en.m.wikipedia.org/wiki/State_(computer_science)</a></p>

<p>Which defines it in this way: 
 "a program is described as s... | formal languages | 1 | How can you define the notion of "state" using only a type theory language? -- (formal languages)
<p>The notion of state I'm referring to is the one described in this wikipedia page : <a href="https://en.m.wikipedia.org/wiki/State_(computer_science)" rel="nofollow noreferrer">https://en.m.wikipedia.org/wiki/State_(comp... | habedi/stack-exchange-dataset |
84,248 | What will be T(n) after second step in a Recurrence Relation | <p>T(n) = 2T(n-1) + n </p>

<p>Using back Substitution at first step we get </p>

<p>T(n) = 4 T(n-2) + 2(n-1) +n </p>

<p>If i go further one more step then what i am getting is </p>

<p>T(n) = 16 T(n-4) + 8(n-3) +4(n-2) + 2(n-1) +n</p>
 | algorithms algorithm analysis | 1 | What will be T(n) after second step in a Recurrence Relation -- (algorithms algorithm analysis)
<p>T(n) = 2T(n-1) + n </p>

<p>Using back Substitution at first step we get </p>

<p>T(n) = 4 T(n-2) + 2(n-1) +n </p>

<p>If i go further one more step then what i am getting is </p>

<p>T(n) ... | habedi/stack-exchange-dataset |
84,262 | Show $USELESS_{TM}=\{ M | M$ is a Turing machine with at least one useless state$\}$ is recursively enumerable? | <p>I know $USELESS_{TM}$ is undecidable, but am having trouble showing that it is recursively enumerable. I wanted to reduce $USELESS_{TM}$ to the halting problem, which would show that $USELESS_{TM}$ is recursively enumerable but don't see a way to go about doing this. (I think I would need to check every possible inp... | computability turing machines undecidability | 1 | Show $USELESS_{TM}=\{ M | M$ is a Turing machine with at least one useless state$\}$ is recursively enumerable? -- (computability turing machines undecidability)
<p>I know $USELESS_{TM}$ is undecidable, but am having trouble showing that it is recursively enumerable. I wanted to reduce $USELESS_{TM}$ to the halting pro... | habedi/stack-exchange-dataset |
84,269 | How to find the equivalence classes of a regular language | <p>Given a language $L=\{ 0^m1^n | m \neq n \}$ over $\Sigma = \{ 0,1 \}$, how would one go about characterizing the equivalence classes of this language?<br>
I know there isn't a formal algorithm for that, but still, can some steps always be taken?</p>
 | regular languages | 1 | How to find the equivalence classes of a regular language -- (regular languages)
<p>Given a language $L=\{ 0^m1^n | m \neq n \}$ over $\Sigma = \{ 0,1 \}$, how would one go about characterizing the equivalence classes of this language?<br>
I know there isn't a formal algorithm for that, but still, can some steps al... | habedi/stack-exchange-dataset |
84,280 | Algorithms : most lightweight circle in directed graph that goes through specific vertex | <p>I have directed Graph G(V,E) with weight function w. so that weight of each (u,v) is a positive value.
I need to find the most lightweight circle in the graph that vertex k' is part of it.</p>

<p>I've also given an algorithm i can use which can find the most lightweight path for a graph with positives w... | algorithms weighted graphs | 1 | Algorithms : most lightweight circle in directed graph that goes through specific vertex -- (algorithms weighted graphs)
<p>I have directed Graph G(V,E) with weight function w. so that weight of each (u,v) is a positive value.
I need to find the most lightweight circle in the graph that vertex k' is part of it.</p>... | habedi/stack-exchange-dataset |
84,283 | How do I do a biased shuffling of a deck of cards? | <p><a href="https://i.stack.imgur.com/ZhXIp.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ZhXIp.jpg" alt="enter image description here"></a></p>

<p>I currently have a deck of cards (in fact this deck is an array of sorted elements in descending order as indicated by the picture above), tha... | probability theory randomized algorithms | 1 | How do I do a biased shuffling of a deck of cards? -- (probability theory randomized algorithms)
<p><a href="https://i.stack.imgur.com/ZhXIp.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ZhXIp.jpg" alt="enter image description here"></a></p>

<p>I currently have a deck of cards (in fact thi... | habedi/stack-exchange-dataset |
84,291 | VC dimensions: Let ${x_1, \ldots, x_N}$ be $N$ labelled points on $\mathbb{R}$, then there exists a sinusoid that separates these points | <p>(<a href="https://cs.nyu.edu/%7Emohri/mls/ml_learning_with_infinite_hypothesis_sets.pdf" rel="noreferrer">Proposition</a>, pg 26): Let <span class="math-container">${x_1, \ldots, x_N}$</span> be <span class="math-container">$N$</span> points on <span class="math-container">$\mathbb{R}$</span>, <span class="math-cont... | machine learning learning theory vc dimension | 1 | VC dimensions: Let ${x_1, \ldots, x_N}$ be $N$ labelled points on $\mathbb{R}$, then there exists a sinusoid that separates these points -- (machine learning learning theory vc dimension)
<p>(<a href="https://cs.nyu.edu/%7Emohri/mls/ml_learning_with_infinite_hypothesis_sets.pdf" rel="noreferrer">Proposition</a>, pg 26)... | habedi/stack-exchange-dataset |
84,297 | Determining time complexity of this function in python | <p>I would like to determine the time complexity of this function, in $\mathcal{O}$-Notation.</p>

<pre class="lang-py prettyprint-override"><code>def g(x):
 if x == 0:
 return 1
 elif x == 1:
 return 2
 else:
 x_div = x//2 # // is integer division
 ... | time complexity runtime analysis python | 1 | Determining time complexity of this function in python -- (time complexity runtime analysis python)
<p>I would like to determine the time complexity of this function, in $\mathcal{O}$-Notation.</p>

<pre class="lang-py prettyprint-override"><code>def g(x):
 if x == 0:
 return 1
 elif x == 1... | habedi/stack-exchange-dataset |
84,307 | What are the rules for positive recursive types in dependent type theory? | <p>I've recently started independently learning type theory, using a combination of papers found online and ncatlab.org (but have not worked with category theory), and am about to start reading TAPL.</p>

<p>I'm interested in understanding how recursive types can be substituted for inductive types in dependent ... | reference request type theory dependent types | 1 | What are the rules for positive recursive types in dependent type theory? -- (reference request type theory dependent types)
<p>I've recently started independently learning type theory, using a combination of papers found online and ncatlab.org (but have not worked with category theory), and am about to start reading T... | habedi/stack-exchange-dataset |
84,327 | Polynomial Computation of the probability of a number of independent events | <p>Suppose to have $n$ independent events $E_1, E_2,..., E_n$, where the probability of occurrence of event $E_i$ is $p_i$ (i.e., each event has its own probability of occurrence). We can easily define new events of type $N_k\equiv$"exactly $k$ events occur". </p>

<p>The probability of event $N_k$ can be compu... | algorithms time complexity combinatorics probability theory | 1 | Polynomial Computation of the probability of a number of independent events -- (algorithms time complexity combinatorics probability theory)
<p>Suppose to have $n$ independent events $E_1, E_2,..., E_n$, where the probability of occurrence of event $E_i$ is $p_i$ (i.e., each event has its own probability of occurrence)... | habedi/stack-exchange-dataset |
84,328 | Construct a TM for $L = \{ M | M$ is a Turing machine with no useless states} | <p>I'm trying to construct a recursively enumerable TM for this language. (Useless state: one that is never entered during a computation on any input). </p>

<p>The TM L:
Write out all of M's states, generate input in lexicographical order one at a time, and after one is generated, simulate M on the input a... | computability turing machines undecidability | 1 | Construct a TM for $L = \{ M | M$ is a Turing machine with no useless states} -- (computability turing machines undecidability)
<p>I'm trying to construct a recursively enumerable TM for this language. (Useless state: one that is never entered during a computation on any input). </p>

<p>The TM L:
Write out... | habedi/stack-exchange-dataset |
84,336 | Can non-recursively enumerable languages be solved with dovetailing? | <p>I'm a bit confused about the dovetailing concept. It seems too powerful. Could it solve non-recursively enumerable languages?</p>
 | computability undecidability | 1 | Can non-recursively enumerable languages be solved with dovetailing? -- (computability undecidability)
<p>I'm a bit confused about the dovetailing concept. It seems too powerful. Could it solve non-recursively enumerable languages?</p>
 | habedi/stack-exchange-dataset |
84,343 | Simplex Algorithm: Why must the optimal value of the LP lie on the face or vertex of a polyhedron? | <blockquote>
 <p>The feasible region of a Linear Program (LP) is $\{x \in {\bf R}^n: Ax \le b, x\ge 0 \}$. This is an intersection of halfspaces, a polyhedron. If the LP is bounded and feasible, its optimal value will be attained on some face of the polyhedron, typically a vertex. A vertex is a point determined by... | linear programming polygons | 1 | Simplex Algorithm: Why must the optimal value of the LP lie on the face or vertex of a polyhedron? -- (linear programming polygons)
<blockquote>
 <p>The feasible region of a Linear Program (LP) is $\{x \in {\bf R}^n: Ax \le b, x\ge 0 \}$. This is an intersection of halfspaces, a polyhedron. If the LP is bounded an... | habedi/stack-exchange-dataset |
84,351 | Why can't we sort an Array in O(n) using Fibonacci Heap? | <p><b>If we can insert to a Fibonacci Heap in O(1), and increase-key and find-min in the same W.C time complexity, then why can't we sort an array in time complexity O(n)?</b></p>

<p>Given an array with n elements:</p>

<ol>
<li><p>Find the maximum of the array (largest key) in O(n). </p></li>
... | sorting heaps | 1 | Why can't we sort an Array in O(n) using Fibonacci Heap? -- (sorting heaps)
<p><b>If we can insert to a Fibonacci Heap in O(1), and increase-key and find-min in the same W.C time complexity, then why can't we sort an array in time complexity O(n)?</b></p>

<p>Given an array with n elements:</p>

<ol>&#x... | habedi/stack-exchange-dataset |
84,361 | Proving there exists an infinite number of Turing machines is a decidable problem | <p>I have a Turing machine M and I have to answer the question are there infinitely many Turing machines that recognize L(M)? I also need to describe a Turing machine that solves this problem. My idea is to say that we can simply increase the number of states by adding a new unreachable state. Each time I add a new sta... | computability turing machines | 1 | Proving there exists an infinite number of Turing machines is a decidable problem -- (computability turing machines)
<p>I have a Turing machine M and I have to answer the question are there infinitely many Turing machines that recognize L(M)? I also need to describe a Turing machine that solves this problem. My idea is... | habedi/stack-exchange-dataset |
84,364 | Compute visible vertices of a polygon | <p>Given a simple polygon $P$ and a point $p$ within the polygon, I want to compute the vertices of $P$ visible from point $p$. A point $q$ is visible from point $p$, if the line segment $\overline{qp}$ is completely in the polygon $P$.</p>

<p>One can use the accepted answer <a href="https://cs.stackexchange.c... | algorithms computational geometry polygons | 1 | Compute visible vertices of a polygon -- (algorithms computational geometry polygons)
<p>Given a simple polygon $P$ and a point $p$ within the polygon, I want to compute the vertices of $P$ visible from point $p$. A point $q$ is visible from point $p$, if the line segment $\overline{qp}$ is completely in the polygon $P... | habedi/stack-exchange-dataset |
84,371 | Extending ordered tree edit distance to DAGs | <p>Computing edit distance (shortest sequence of edit operations) on ordered trees is a well studied problem with many known algorithms (e.g. <a href="http://www.grantjenks.com/wiki/_media/ideas:simple_fast_algorithms_for_the_editing_distance_between_tree_and_related_problems.pdf" rel="noreferrer">Zhang & Shasha</a... | graphs edit distance | 1 | Extending ordered tree edit distance to DAGs -- (graphs edit distance)
<p>Computing edit distance (shortest sequence of edit operations) on ordered trees is a well studied problem with many known algorithms (e.g. <a href="http://www.grantjenks.com/wiki/_media/ideas:simple_fast_algorithms_for_the_editing_distance_betwee... | habedi/stack-exchange-dataset |
84,373 | How do I solve this graph with Dijkstra's Algorithm? | <p>I just drew this graph completely random:</p>

<p><a href="https://i.stack.imgur.com/uMTS3.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/uMTS3.jpg" alt="Graph"></a></p>

<p>I found the shortest path (marked in red) by simply checking everything. But the reason was to use Dijkstra... | graphs | 1 | How do I solve this graph with Dijkstra's Algorithm? -- (graphs)
<p>I just drew this graph completely random:</p>

<p><a href="https://i.stack.imgur.com/uMTS3.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/uMTS3.jpg" alt="Graph"></a></p>

<p>I found the shortest path (marked in red) ... | habedi/stack-exchange-dataset |
84,383 | Post Correspondence problem provable instance | <p>Let the Post Correspondence problem with input</p>

<p>$$K = ((x_1, y_1), . . . ,(x_n, y_n)), x_i, y_i ∈ \Sigma^*$$</p>

<p>for $$ i = 1, . . . , n $$</p>

<p>Find a concrete solution for the input </p>

<p>$$K = ((001,0), (01, 011),(01, 101),(10, 001))$$ </p>

<p>The Post Cor... | undecidability decision problem | 1 | Post Correspondence problem provable instance -- (undecidability decision problem)
<p>Let the Post Correspondence problem with input</p>

<p>$$K = ((x_1, y_1), . . . ,(x_n, y_n)), x_i, y_i ∈ \Sigma^*$$</p>

<p>for $$ i = 1, . . . , n $$</p>

<p>Find a concrete solution for the input </p>
&#x... | habedi/stack-exchange-dataset |
84,384 | Draw a function by only using two input NOR gates | <p>T = (BD + A'BC'+A'CD)</p>

<p>How can i draw this by only using NOR-Gates? This is what i have done so far:
<a href="https://imgur.com/a/JG2eU" rel="nofollow noreferrer">https://imgur.com/a/JG2eU</a></p>

<p>Have I understood this right?</p>
 | logic | 1 | Draw a function by only using two input NOR gates -- (logic)
<p>T = (BD + A'BC'+A'CD)</p>

<p>How can i draw this by only using NOR-Gates? This is what i have done so far:
<a href="https://imgur.com/a/JG2eU" rel="nofollow noreferrer">https://imgur.com/a/JG2eU</a></p>

<p>Have I understood this right... | habedi/stack-exchange-dataset |
84,395 | How does maths consistency impacts on computer science? | <p>Lot of mathematicians have made several efforts to answer the question : are mathematics consistent ? Although we haven't yet had a proof of consistency, and surely we will never (Gödel second theorem), does this question has an impact on computer science ? I mean, does the work of those mathematicians, like Gödel's... | logic mathematical foundations | 1 | How does maths consistency impacts on computer science? -- (logic mathematical foundations)
<p>Lot of mathematicians have made several efforts to answer the question : are mathematics consistent ? Although we haven't yet had a proof of consistency, and surely we will never (Gödel second theorem), does this question has... | habedi/stack-exchange-dataset |
84,400 | If the difference between two oracles is negligible, is the difference between a PPT algorithm with these two oracles also negligible? | <p>We say a negligible function is a function $\epsilon(n):\mathbb{N}\rightarrow \mathbb{R}$ such that for every positive integer $c$ there exists an integer $N_c$ such that for all $n > N_c$, 
$$\epsilon(n)<\frac{1}{n^c}$$
(From wikipedia)</p>

<p>Assume that two probabilistic polynomial-time alg... | polynomial time probabilistic algorithms oracle machines | 1 | If the difference between two oracles is negligible, is the difference between a PPT algorithm with these two oracles also negligible? -- (polynomial time probabilistic algorithms oracle machines)
<p>We say a negligible function is a function $\epsilon(n):\mathbb{N}\rightarrow \mathbb{R}$ such that for every positive i... | habedi/stack-exchange-dataset |
84,401 | Prove that a DFA will transition to the same state after $\gcd(i,j)$ steps where $i$ and $j$ steps can be taken to reach that state | <p>Suppose $M=(Q,\Sigma,\delta,q_0,F)$ is a deterministic finite automaton, and suppose there exists a state $q \in Q$, a string $z \in \Sigma$, and integers $i,j>0$ such that $\delta(q,z^i)=\delta(q,z^j)=q$. Prove that $\delta(q,z^{gcd(i,j)})=q$</p>

<p>I can intuitively say that starting from a state $q$ i... | finite automata | 1 | Prove that a DFA will transition to the same state after $\gcd(i,j)$ steps where $i$ and $j$ steps can be taken to reach that state -- (finite automata)
<p>Suppose $M=(Q,\Sigma,\delta,q_0,F)$ is a deterministic finite automaton, and suppose there exists a state $q \in Q$, a string $z \in \Sigma$, and integers $i,j>0... | habedi/stack-exchange-dataset |
84,402 | Comparing the closed behaviors corresponding to finite state automata | <p>Let $G$ be a finite state automaton (FSA) with transfer function $\delta(\cdot,\cdot)$ and initial state $q_0$. Suppose also $\Sigma_{G}$ represents its alphabet. Assume that its <strong>closed behavior</strong> is a set of strings defined as:</p>

<p>$L(G) := \{s \in \Sigma_{G}|\delta(q_0,s) \text{ is defin... | regular languages finite automata | 1 | Comparing the closed behaviors corresponding to finite state automata -- (regular languages finite automata)
<p>Let $G$ be a finite state automaton (FSA) with transfer function $\delta(\cdot,\cdot)$ and initial state $q_0$. Suppose also $\Sigma_{G}$ represents its alphabet. Assume that its <strong>closed behavior</stro... | habedi/stack-exchange-dataset |
84,405 | $ACC^{0}$ vs Poly-size circuits of bounded degree | <p>We know that NEXP $\not\subset ACC^0$ <strong>(Ryan Williams'10 Result)</strong>. Also, We know that even $\Sigma_{2}^{P}$ cannot have polynomial circuits of bounded degree i.e. $SIZE(n^k)$ for some $k \in N$ <strong>(Kannan's Result)</strong>. Does this give a hint towards $ACC^0$ is far more powerful than polynomi... | complexity theory time complexity complexity classes circuits | 1 | $ACC^{0}$ vs Poly-size circuits of bounded degree -- (complexity theory time complexity complexity classes circuits)
<p>We know that NEXP $\not\subset ACC^0$ <strong>(Ryan Williams'10 Result)</strong>. Also, We know that even $\Sigma_{2}^{P}$ cannot have polynomial circuits of bounded degree i.e. $SIZE(n^k)$ for some $... | habedi/stack-exchange-dataset |
84,408 | Dijkstra algorithm step in Introduction to Algorithms | <p>In the introduction to algorithms proof of Dijkstra, I don't understand why the statement "both y and u were in V-S when u was chosen". We add x before y, and so we relax d[y] with the the edge $$\omega(<x,y>) + \delta(s,x)$$, d[u] can't be smaller than delta[u], so shouldn't y be in S when we add x to S? than... | algorithms graphs shortest path weighted graphs | 1 | Dijkstra algorithm step in Introduction to Algorithms -- (algorithms graphs shortest path weighted graphs)
<p>In the introduction to algorithms proof of Dijkstra, I don't understand why the statement "both y and u were in V-S when u was chosen". We add x before y, and so we relax d[y] with the the edge $$\omega(<x,y... | habedi/stack-exchange-dataset |
84,418 | Complexity class NP and MA | <p>Is there any example of any natural problem which is known to be in MA, but not yet to known to be in NP? </p>

<p>I am aware that Graph Nonisomorphism (GNI) is known to be in AM which is considered a superset of MA. Can we construct a language (which may be non-natural) which is in MA, but not in NP? </p>&#... | complexity theory time complexity complexity classes | 1 | Complexity class NP and MA -- (complexity theory time complexity complexity classes)
<p>Is there any example of any natural problem which is known to be in MA, but not yet to known to be in NP? </p>

<p>I am aware that Graph Nonisomorphism (GNI) is known to be in AM which is considered a superset of MA. Can we ... | habedi/stack-exchange-dataset |
84,428 | Proving that the set of deciders is not Turing-recognizable | <p>Let $A$ be the language consisting of descriptions of Turing machines $\{M_1, M_2, \dots \}$, where each $M_i$ is a decider. Prove that $A$ is not Turing-recognizable.</p>

<p>Then suppose $A$ is Turing-recognizable and suppose $s = \{s_1, s_2, \dots \}$ is a set of all possible binary strings. Then I constr... | turing machines undecidability | 1 | Proving that the set of deciders is not Turing-recognizable -- (turing machines undecidability)
<p>Let $A$ be the language consisting of descriptions of Turing machines $\{M_1, M_2, \dots \}$, where each $M_i$ is a decider. Prove that $A$ is not Turing-recognizable.</p>

<p>Then suppose $A$ is Turing-recognizab... | habedi/stack-exchange-dataset |
84,433 | What is decider? | <p><a href="https://en.wikipedia.org/wiki/Machine_that_always_halts" rel="nofollow noreferrer">According to Wikipedia</a></p>
<blockquote>
<p>In computability theory, a machine that always halts—also called a decider (Sipser, 1996) or a total Turing machine (Kozen, 1997)—is a Turing machine that halts for every... | computability turing machines | 1 | What is decider? -- (computability turing machines)
<p><a href="https://en.wikipedia.org/wiki/Machine_that_always_halts" rel="nofollow noreferrer">According to Wikipedia</a></p>
<blockquote>
<p>In computability theory, a machine that always halts—also called a decider (Sipser, 1996) or a total Turing machine (K... | habedi/stack-exchange-dataset |
84,435 | Unrecognizability of HALT | <p>I am currently stuck on a question from Sipser's book of automata. The question goes like this:</p>

<blockquote>
 <p>Consider the following language: V = {w|w = 0a for some a which is an
 element of HALT} U {w|w=1b for some b which is an element of
 complement of HALT }</p>
 
 <p>Pr... | turing machines automata | 1 | Unrecognizability of HALT -- (turing machines automata)
<p>I am currently stuck on a question from Sipser's book of automata. The question goes like this:</p>

<blockquote>
 <p>Consider the following language: V = {w|w = 0a for some a which is an
 element of HALT} U {w|w=1b for some b which is an elem... | habedi/stack-exchange-dataset |
84,438 | Could a modification of Krom's proof system be used to solve 3-SAT in polynomial time? | <p>A literal is a nonzero integer, and we define $\sim x = -x$.<br>
A clause is a nonempty set of literals.<br>
A CNF is a set of clauses.<br>
A K-rule is a pair $(F,C)$ where $F$ is a CNF and $C$ is a clause.<br>
A Krom-style proof system (KPS) is a set of K-rules.<br>
If $S$ is a KPS, then an $S$-... | complexity theory p vs np 3 sat | 1 | Could a modification of Krom's proof system be used to solve 3-SAT in polynomial time? -- (complexity theory p vs np 3 sat)
<p>A literal is a nonzero integer, and we define $\sim x = -x$.<br>
A clause is a nonempty set of literals.<br>
A CNF is a set of clauses.<br>
A K-rule is a pair $(F,C)$ where $F$ is a... | habedi/stack-exchange-dataset |
84,448 | Using reduction to prove that a given language is not recursively enumerable | <p>Let the language $L$ be as follow ; </p>

<p>$$L=\{\langle M_1 \rangle \langle M_2 \rangle \mid L(M_1) \cap L(M_2)=\emptyset \}$$</p>

<p>$\langle M_1 \rangle$ and $\langle M_2 \rangle$ are the encoding of the Turing machine $M_1$ and $ M_2$.</p>

<p>Using Reduction, I have to prove that... | computability turing machines enumeration | 1 | Using reduction to prove that a given language is not recursively enumerable -- (computability turing machines enumeration)
<p>Let the language $L$ be as follow ; </p>

<p>$$L=\{\langle M_1 \rangle \langle M_2 \rangle \mid L(M_1) \cap L(M_2)=\emptyset \}$$</p>

<p>$\langle M_1 \rangle$ and $\langle ... | habedi/stack-exchange-dataset |
84,456 | Objective function and constraint satisfaction over a set of multi-attributes elements | <p>I'm looking for an approach to solve a problem consisting of maximizing an objective function over a set of discrete elements, while respecting a set of constraints.</p>

<p>To illustrate my point, I'll try to come up with an example.</p>

<p>A bag contains several items with the following attributes... | linear programming constraint satisfaction smt solvers | 1 | Objective function and constraint satisfaction over a set of multi-attributes elements -- (linear programming constraint satisfaction smt solvers)
<p>I'm looking for an approach to solve a problem consisting of maximizing an objective function over a set of discrete elements, while respecting a set of constraints.</p>&... | habedi/stack-exchange-dataset |
84,460 | Sorting an array of length $n$ in $O(m+n)$ time | <p>I need to find a method to sort an array in <span class="math-container">$O(m+n)$</span> time complexity.
I understand it should be a variation on Radix sort, however I am not familiar with it or its implementation...</p>
<blockquote>
<p><em>Input</em>: an array <span class="math-container">$A$</span> of... | time complexity sorting arrays radix sort | 1 | Sorting an array of length $n$ in $O(m+n)$ time -- (time complexity sorting arrays radix sort)
<p>I need to find a method to sort an array in <span class="math-container">$O(m+n)$</span> time complexity.
I understand it should be a variation on Radix sort, however I am not familiar with it or its implementation...<... | habedi/stack-exchange-dataset |
84,466 | Sorting an array in linear time | <p>I need to find a method to sort an array in <span class="math-container">$O(n)$</span> time complexity.
I saw <a href="http://www.geeksforgeeks.org/sort-n-numbers-range-0-n2-1-linear-time/" rel="nofollow noreferrer">this link</a>,
however I'm not sure how to apply it to the elements I need.</p>
<blockquo... | time complexity sorting counting radix sort | 1 | Sorting an array in linear time -- (time complexity sorting counting radix sort)
<p>I need to find a method to sort an array in <span class="math-container">$O(n)$</span> time complexity.
I saw <a href="http://www.geeksforgeeks.org/sort-n-numbers-range-0-n2-1-linear-time/" rel="nofollow noreferrer">this link</a>,&#... | habedi/stack-exchange-dataset |
84,468 | Proving that vertex labeling is NP-complete | <p>Given a graph $G=(V,E)$, all the vertices $v \epsilon V$ are labeled with values from $\{1,2,...\ldots n\}$ where $|V| = n$ such that for all edges $(x,y) \epsilon E$ such that $|label(x) - label(y)| \ge 2$. We have to determine whether such a labeling is possible for a graph.</p>

<p>Now I have to prove tha... | graphs np complete | 1 | Proving that vertex labeling is NP-complete -- (graphs np complete)
<p>Given a graph $G=(V,E)$, all the vertices $v \epsilon V$ are labeled with values from $\{1,2,...\ldots n\}$ where $|V| = n$ such that for all edges $(x,y) \epsilon E$ such that $|label(x) - label(y)| \ge 2$. We have to determine whether such a label... | habedi/stack-exchange-dataset |
84,471 | Symbol table usage | <p>In which phases of the compiler, is symbol table used and updated ?</p>

<hr>

<p>According to me,</p>

<p>In lexical analysis, new entry for each variable is created in symbol table so symbol table is only <strong>updated</strong></p>

<p>In syntax and semantic analysis, symbol table... | compilers | 1 | Symbol table usage -- (compilers)
<p>In which phases of the compiler, is symbol table used and updated ?</p>

<hr>

<p>According to me,</p>

<p>In lexical analysis, new entry for each variable is created in symbol table so symbol table is only <strong>updated</strong></p>

<p>In syntax a... | habedi/stack-exchange-dataset |
84,475 | How to check for ambiguous grammar if you don't know the string | <p>Let's say I have a CFG grammar $G$ which describes some rules for language generation. How can you tell that grammar can generate ambiguous results for a string if you don't know that string? I know how to check for ambiguity when you're given a particular string but what about the cases when it's not? Is there any ... | context free formal grammars ambiguity | 1 | How to check for ambiguous grammar if you don't know the string -- (context free formal grammars ambiguity)
<p>Let's say I have a CFG grammar $G$ which describes some rules for language generation. How can you tell that grammar can generate ambiguous results for a string if you don't know that string? I know how to che... | habedi/stack-exchange-dataset |
84,477 | Growing multiples of variable combinations | <p>I need to find growing combinations of variables a, b, c etc. I don't know names of math things in English well, so my description of the problem will be in pseudocode. This is for a programming problem, but I want to understand the underlying mathematics. I would highly appreciate proper names of techniques used so... | algorithms combinatorics | 1 | Growing multiples of variable combinations -- (algorithms combinatorics)
<p>I need to find growing combinations of variables a, b, c etc. I don't know names of math things in English well, so my description of the problem will be in pseudocode. This is for a programming problem, but I want to understand the underlying ... | habedi/stack-exchange-dataset |
84,478 | Size of neighborhood in local search for symmetric TSP | <p>I read about local search / neighborhood search methods for the symmetric TSP and I'm not quite sure about a few things. 
The given example said:</p>

<blockquote>
 <p>Suppose we have an instance of the symmetric TSP with n nodes and the neighborhood $N^k$.
 Here $N^k$ is the $k$-change-neighbo... | optimization traveling salesman | 1 | Size of neighborhood in local search for symmetric TSP -- (optimization traveling salesman)
<p>I read about local search / neighborhood search methods for the symmetric TSP and I'm not quite sure about a few things. 
The given example said:</p>

<blockquote>
 <p>Suppose we have an instance of the symme... | habedi/stack-exchange-dataset |
84,486 | How was Idris' `rewrite` implemented? | <p>I know in Agda, <code>rewrite</code> is a syntax sugar that desugars to a <code>with</code> abstraction.<br>
For example, if we have (I'm using the <code>Data.Vec</code> from the standard library):</p>

<p>$$
\DeclareMathOperator{Set}{Set}
\DeclareMathOperator{xs}{xs}
\DeclareMathOperator{whe... | formal languages term rewriting | 1 | How was Idris' `rewrite` implemented? -- (formal languages term rewriting)
<p>I know in Agda, <code>rewrite</code> is a syntax sugar that desugars to a <code>with</code> abstraction.<br>
For example, if we have (I'm using the <code>Data.Vec</code> from the standard library):</p>

<p>$$
\DeclareMathOpera... | habedi/stack-exchange-dataset |
84,487 | What happens when an internet connection is faster than the storage write speed? | <p>If one attempted to download a file at a speed of 800 Mb/s (100 MB/s) onto a hard drive with a write speed of 500 Mb/s (62.5 MB/s), what would happen? Would the system cap the download speed?</p>
 | computer networks | 1 | What happens when an internet connection is faster than the storage write speed? -- (computer networks)
<p>If one attempted to download a file at a speed of 800 Mb/s (100 MB/s) onto a hard drive with a write speed of 500 Mb/s (62.5 MB/s), what would happen? Would the system cap the download speed?</p>
 | habedi/stack-exchange-dataset |
84,489 | What's the difference between subtyping and inheritance? | <p>In object-oriented programming, I have learned the concept of <code>subtyping</code> and <code>inheritance</code>.<br>
I thought they're the same thing, in the beginning. But I was told that they're totally different.</p>

<p>So what's there difference? What's there relationship?</p>
 | object oriented | 1 | What's the difference between subtyping and inheritance? -- (object oriented)
<p>In object-oriented programming, I have learned the concept of <code>subtyping</code> and <code>inheritance</code>.<br>
I thought they're the same thing, in the beginning. But I was told that they're totally different.</p>

<p>S... | habedi/stack-exchange-dataset |
84,491 | Average case complexity of bubble sort vs insertion sort | <p>This site already has some questions on this topic but I am confused after reading some of the answers.</p>

<p><a href="https://cs.stackexchange.com/questions/20/evaluating-the-average-time-complexity-of-a-given-bubblesort-algorithm">Evaluating the average time complexity of a given bubblesort algorithm.</a... | algorithms algorithm analysis sorting | 1 | Average case complexity of bubble sort vs insertion sort -- (algorithms algorithm analysis sorting)
<p>This site already has some questions on this topic but I am confused after reading some of the answers.</p>

<p><a href="https://cs.stackexchange.com/questions/20/evaluating-the-average-time-complexity-of-a-gi... | habedi/stack-exchange-dataset |
84,492 | Difference between fixed-to-variable length codes and variable-to-fixed length codes? | <p>I am a bit confused by the difference between the two. Can someone clarify the difference between the two?</p>
 | coding theory | 1 | Difference between fixed-to-variable length codes and variable-to-fixed length codes? -- (coding theory)
<p>I am a bit confused by the difference between the two. Can someone clarify the difference between the two?</p>
 | habedi/stack-exchange-dataset |
84,496 | Arithmetic network to compute floor of binary logarithm | <p>I wonder how to build efficient arithmetic network (using logical gates only) to compute floor of binary logarithm of the given input number. I have read some articles on <a href="http://stackoverflow.com">stackoverflow.com</a> about this problem, respectively its implementation in C/C++ using bitwise operations onl... | arithmetic | 1 | Arithmetic network to compute floor of binary logarithm -- (arithmetic)
<p>I wonder how to build efficient arithmetic network (using logical gates only) to compute floor of binary logarithm of the given input number. I have read some articles on <a href="http://stackoverflow.com">stackoverflow.com</a> about this proble... | habedi/stack-exchange-dataset |
84,503 | Continuation-passing style: what is meant by "CPS'ing"? | <p>I'm reading <a href="https://arxiv.org/abs/1608.06499" rel="nofollow noreferrer">Dijkstra Monads for Free</a> for a presentation I'll be doing and it's pretty meaty. One of the things that I keep running into is the term "CPS'ing". I've read a little bit on continuation-passing style (i.e., I've read throu... | software verification hoare logic continuations | 1 | Continuation-passing style: what is meant by "CPS'ing"? -- (software verification hoare logic continuations)
<p>I'm reading <a href="https://arxiv.org/abs/1608.06499" rel="nofollow noreferrer">Dijkstra Monads for Free</a> for a presentation I'll be doing and it's pretty meaty. One of the things that I keep running into... | habedi/stack-exchange-dataset |
84,507 | Prove longest path shares two points | <p>If there are two longest paths in a connected graph with path lengths of 79 (going through 80 vertices each). How can I prove that they share more than 1 vertex. </p>
 | graphs | 1 | Prove longest path shares two points -- (graphs)
<p>If there are two longest paths in a connected graph with path lengths of 79 (going through 80 vertices each). How can I prove that they share more than 1 vertex. </p>
 | habedi/stack-exchange-dataset |
84,514 | Show that 0^n1^n is decidable | <p>I would like to know how would one go about and answer this question. I know that a language is decidable if a turing machine exists that accepts the strings in that language, and rejects otherwise. Would I need to create a turing machine to show this or is it enough to create a PDA and claim a TM can be created fro... | computability turing machines undecidability pushdown automata | 1 | Show that 0^n1^n is decidable -- (computability turing machines undecidability pushdown automata)
<p>I would like to know how would one go about and answer this question. I know that a language is decidable if a turing machine exists that accepts the strings in that language, and rejects otherwise. Would I need to crea... | habedi/stack-exchange-dataset |
84,517 | Is $Ω(n\log n)$ the lower-bound for *all* sorting algorithms or *just comparison-based* sorting algorithms? | <p>Is $Ω(n\log n)$ the lower-bound for <em>all</em> sorting algorithms or <em>just comparison-based</em> sorting algorithms?</p>

<p>If the latter, is it possible for there to be general-purpose sorting algorithms which perform better than $Ω(n\log n)$?</p>

<p>General-purpose, for example, means you ar... | algorithms complexity theory sorting lower bounds | 1 | Is $Ω(n\log n)$ the lower-bound for *all* sorting algorithms or *just comparison-based* sorting algorithms? -- (algorithms complexity theory sorting lower bounds)
<p>Is $Ω(n\log n)$ the lower-bound for <em>all</em> sorting algorithms or <em>just comparison-based</em> sorting algorithms?</p>

<p>If the latter, ... | habedi/stack-exchange-dataset |
84,527 | Why postfix arithmetic expression is not ambiguous? | <p>A binary tree can be written as an expression, no matter prefix, postfix or infix.<br>
But why an infix expression needs brackets, while the others don't?</p>

<p>Say, why postfix, prefix produce only one binary tree, while infix can produce many (and become ambiguous)?</p>

<p>I'm looking for a ... | binary trees ambiguity syntax | 1 | Why postfix arithmetic expression is not ambiguous? -- (binary trees ambiguity syntax)
<p>A binary tree can be written as an expression, no matter prefix, postfix or infix.<br>
But why an infix expression needs brackets, while the others don't?</p>

<p>Say, why postfix, prefix produce only one binary tree, ... | habedi/stack-exchange-dataset |
84,529 | How do proof assistants nowadays avoid floatpoint error? | <p>I heard that Coq is using "Dedekind cut", but how's that related to floatpoint errors?</p>

<p>Can we just use something like</p>

<pre><code>data Q : Type where
 div : N -> N -> Bool -> Q
</code></pre>

<p>To replace all usages of floatpoint numbers?</p>
 | floating point | 1 | How do proof assistants nowadays avoid floatpoint error? -- (floating point)
<p>I heard that Coq is using "Dedekind cut", but how's that related to floatpoint errors?</p>

<p>Can we just use something like</p>

<pre><code>data Q : Type where
 div : N -> N -> Bool -> Q
</code></pre>
... | habedi/stack-exchange-dataset |
84,533 | Why is the target function minimized at (0,0) if I can get to a negative number? | <p>I just started learning LP and I saw this Q in my textbook:</p>

<p>$$
min : -x -y \\
S.T. : x + 2y \le 3, 2x +y \le 3, x \ge 0, y \ge 0
$$</p>

<p>It is easy to see that the polygon created from these constraints can't have a negative coordinate. In my textbook it says the answer is $(0... | linear programming | 1 | Why is the target function minimized at (0,0) if I can get to a negative number? -- (linear programming)
<p>I just started learning LP and I saw this Q in my textbook:</p>

<p>$$
min : -x -y \\
S.T. : x + 2y \le 3, 2x +y \le 3, x \ge 0, y \ge 0
$$</p>

<p>It is easy to see that the polygon ... | habedi/stack-exchange-dataset |
84,542 | Rooted Binary Tree - Chain Nodes Algorithm | <p>The question is that I have to give a recursive algorithm in pseudocode, that counts the number of chain node in a rooted binary tree. Chain node is defined as a node that has only one child and that child is not a leaf.
I am stuck any help would be appreciated, so far I have done this:</p>

<pre><code>A... | algorithms binary trees binary search trees | 1 | Rooted Binary Tree - Chain Nodes Algorithm -- (algorithms binary trees binary search trees)
<p>The question is that I have to give a recursive algorithm in pseudocode, that counts the number of chain node in a rooted binary tree. Chain node is defined as a node that has only one child and that child is not a leaf.
... | habedi/stack-exchange-dataset |
84,543 | Terminology for property of recursion definitions | <p>I have a question about generally accepted terminology (and whether it exists at all).</p>

<p>Some recursive algorithms on hierarchical data structures (trees) have the property that they are expressed as a function which does a single recursive function call on each of its children, and that this call take... | algorithms terminology | 1 | Terminology for property of recursion definitions -- (algorithms terminology)
<p>I have a question about generally accepted terminology (and whether it exists at all).</p>

<p>Some recursive algorithms on hierarchical data structures (trees) have the property that they are expressed as a function which does a s... | habedi/stack-exchange-dataset |
84,544 | Why the number of adresses stored on RAM is equal to $2^x$ when has "x" adress lines? | <p>I know that a RAM when has 20 adress lines can store up to 2^20 data. I don't know the reason. What is that for and how?
<a href="https://i.stack.imgur.com/2N8xg.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/2N8xg.jpg" alt="image is here" /></a></p>
<p>On the image, where and what is the... | computer architecture | 1 | Why the number of adresses stored on RAM is equal to $2^x$ when has "x" adress lines? -- (computer architecture)
<p>I know that a RAM when has 20 adress lines can store up to 2^20 data. I don't know the reason. What is that for and how?
<a href="https://i.stack.imgur.com/2N8xg.jpg" rel="nofollow noreferrer"><img sr... | habedi/stack-exchange-dataset |
84,556 | Approximate value iteration for continuous state space MDPs | <p>I have a continuous state space MDP as a generative model. I input the state and action and it outputs the reward and the next state. Assume that I sampled $n$ state-reward-states. I wonder how I can implement value iteration using a function approximator. I couldn't find any implementation example online. Can you p... | dynamic programming reinforcement learning | 1 | Approximate value iteration for continuous state space MDPs -- (dynamic programming reinforcement learning)
<p>I have a continuous state space MDP as a generative model. I input the state and action and it outputs the reward and the next state. Assume that I sampled $n$ state-reward-states. I wonder how I can implement... | habedi/stack-exchange-dataset |
84,560 | Do we need regular expression first or finite state automata in lexical anlysing? | <p>I'm a bit confused about the concept of finite state automata (FSA) and regular expression (RE) in lexical analysis. I have reading some books about compiler construction. At the part of tokenization, all the books I read talk about the regular expression first to recognize the tokens. For example, the regex below ... | finite automata regular expressions compilers lexical analysis | 1 | Do we need regular expression first or finite state automata in lexical anlysing? -- (finite automata regular expressions compilers lexical analysis)
<p>I'm a bit confused about the concept of finite state automata (FSA) and regular expression (RE) in lexical analysis. I have reading some books about compiler construct... | habedi/stack-exchange-dataset |
84,563 | Minimum pumping length of regular language | <p>I know the method to the find the minimum pumping length of regular language by constructing minimal DFA and finding the number of states but I am not able to quite understand why is it working.</p>

<p>For example, $L = (10)^*$.
Here minimum pumping length is 1 by constructing DFA.
But by pumping le... | regular languages pumping lemma | 1 | Minimum pumping length of regular language -- (regular languages pumping lemma)
<p>I know the method to the find the minimum pumping length of regular language by constructing minimal DFA and finding the number of states but I am not able to quite understand why is it working.</p>

<p>For example, $L = (10)^*$.... | habedi/stack-exchange-dataset |
84,572 | How to convert 2 or gates (x1 V x2 V x3) to NAND | <p><strong>How can I convert a clause of size 3 that is made of 2 OR gates</strong> </p>

<p>example: </p>

<pre><code>(x1 OR x2 OR x3 )
</code></pre>

<p><strong>to one or more clauses of size 4 made only of NAND gates and not gates?</strong> So without parentheses inside th... | np complete logic | 1 | How to convert 2 or gates (x1 V x2 V x3) to NAND -- (np complete logic)
<p><strong>How can I convert a clause of size 3 that is made of 2 OR gates</strong> </p>

<p>example: </p>

<pre><code>(x1 OR x2 OR x3 )
</code></pre>

<p><strong>to one or more clauses of size 4 made onl... | habedi/stack-exchange-dataset |
84,578 | Can we add dependent type into an existing imperative programming language? | <p>As we know, dependent type allows programmers to write bugless programs.<br>
But as I know there's only very few languages support dependent type, like Haskell with extensions, Idris, Agda, F*, etc.</p>

<p>Since these are all functional languages, is there any possibility to add dependent type into an i... | dependent types imperative programming | 1 | Can we add dependent type into an existing imperative programming language? -- (dependent types imperative programming)
<p>As we know, dependent type allows programmers to write bugless programs.<br>
But as I know there's only very few languages support dependent type, like Haskell with extensions, Idris, Agda, F*,... | habedi/stack-exchange-dataset |
84,580 | Dynamic programming tree algorithm | <blockquote>
 <p>We have a network of sensors organized in tree form, where the sensors
 occupy the nodes. Most of the time the sensors are turned off, until
 the root sensor wakes up the rest of the sensors. This process of
 awakening the nodes requires a certain amount of time since, in a
 un... | algorithms trees dynamic programming | 1 | Dynamic programming tree algorithm -- (algorithms trees dynamic programming)
<blockquote>
 <p>We have a network of sensors organized in tree form, where the sensors
 occupy the nodes. Most of the time the sensors are turned off, until
 the root sensor wakes up the rest of the sensors. This process of
... | habedi/stack-exchange-dataset |
84,581 | Why the restriction on the length of the proof in a $(r,q)$-verifier in PCP is inconsequential? | <p>In the textbook by Arora-Barak, they define PCP verifier as</p>

<p><a href="https://i.stack.imgur.com/2hBZC.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/2hBZC.png" alt="enter image description here"></a> </p>

<p>While in the definition they put a restriction of $q2^r$on the le... | complexity theory | 1 | Why the restriction on the length of the proof in a $(r,q)$-verifier in PCP is inconsequential? -- (complexity theory)
<p>In the textbook by Arora-Barak, they define PCP verifier as</p>

<p><a href="https://i.stack.imgur.com/2hBZC.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/2hBZC.png" alt... | habedi/stack-exchange-dataset |
84,591 | Triangulating a simple polygon via its trapezoidal map | <p>Given a trapezoidal map of a simple polygon $P$, is it possible to compute the triangulation of $P$ in $\mathcal{O}(n)$ time?</p>
 | algorithms computational geometry polygons | 1 | Triangulating a simple polygon via its trapezoidal map -- (algorithms computational geometry polygons)
<p>Given a trapezoidal map of a simple polygon $P$, is it possible to compute the triangulation of $P$ in $\mathcal{O}(n)$ time?</p>
 | habedi/stack-exchange-dataset |
84,606 | When are edges adjacent? | <p>What conditions must be fulfilled for two edges of a graph to be called adjacent?</p>

<p>I found a lot about adjacent nodes, but our CS course script refers to adjacent edges, with no explanation.</p>
 | graphs terminology | 1 | When are edges adjacent? -- (graphs terminology)
<p>What conditions must be fulfilled for two edges of a graph to be called adjacent?</p>

<p>I found a lot about adjacent nodes, but our CS course script refers to adjacent edges, with no explanation.</p>
 | habedi/stack-exchange-dataset |
84,622 | Complexity of 1-in-3 SAT variant with restrictions on "unique" variables per clause | <p>I'm interested in the complexity of a particular variant of 1-in-3 SAT. Assume, as is usual, that clauses are allowed to be of length 1, 2, or 3. Then add the restriction that for any clause of length 3, at least one variable must be "unique," meaning it must appear in no other clause.</p>

<p>Another way to... | complexity theory np complete logic satisfiability | 1 | Complexity of 1-in-3 SAT variant with restrictions on "unique" variables per clause -- (complexity theory np complete logic satisfiability)
<p>I'm interested in the complexity of a particular variant of 1-in-3 SAT. Assume, as is usual, that clauses are allowed to be of length 1, 2, or 3. Then add the restriction that f... | habedi/stack-exchange-dataset |
84,624 | Calculating Tag Bits in a Direct-Mapped Cache | <p>The following comes from Patterson & Hennessy <em>Computer Org. and Design</em> (5th ed., p. 390):</p>

<blockquote>
 <p>How many total bits are required for a direct-mapped cache with 16 KiB
 of data and 4-word blocks, assuming a 32-bit address?</p>
</blockquote>

<p>My question is... | cpu cache caching | 1 | Calculating Tag Bits in a Direct-Mapped Cache -- (cpu cache caching)
<p>The following comes from Patterson & Hennessy <em>Computer Org. and Design</em> (5th ed., p. 390):</p>

<blockquote>
 <p>How many total bits are required for a direct-mapped cache with 16 KiB
 of data and 4-word blocks, assumi... | habedi/stack-exchange-dataset |
84,625 | Access a tree by level without traversing | <p>I need a tree structure that works roughly like the following</p>

<ul>
<li><p>for each new child I need to match it (with some criteria) with a parent from the previous level only</p></li>
<li><p>when the tree is completely initialized, for each leaf I need to find the first <s>parent</s> <em>ancest... | algorithms data structures | 1 | Access a tree by level without traversing -- (algorithms data structures)
<p>I need a tree structure that works roughly like the following</p>

<ul>
<li><p>for each new child I need to match it (with some criteria) with a parent from the previous level only</p></li>
<li><p>when the tree is completely in... | habedi/stack-exchange-dataset |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.