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 |
|---|---|---|---|---|---|---|
88,582 | On the analysis of Christofides's algorithm | <p>Suppose you have even number of vertices, they form as a complete graph denote the graph by <span class="math-container">$G$</span>. Now, suppose we compute the minimum weight perfect matching denoted by <span class="math-container">$P$</span> (so <span class="math-container">$P$</span> has alternating edges, i.e. o... | algorithms algorithm analysis | 1 | On the analysis of Christofides's algorithm -- (algorithms algorithm analysis)
<p>Suppose you have even number of vertices, they form as a complete graph denote the graph by <span class="math-container">$G$</span>. Now, suppose we compute the minimum weight perfect matching denoted by <span class="math-container">$P$</... | habedi/stack-exchange-dataset |
88,584 | How to find the smallest $r$ such that $o_r(n) > \log^2(n)$ in polynomial time? | <p>Defining
$$
o_r(n) = \min \left\{ \hspace{1mm} k \in \mathbb{N} \hspace{2mm} | \hspace{2mm} n^k \equiv 1 \hspace{3mm} (\text{mod } r) \hspace{1mm} \right\}
$$
How can we show that finding the smallest $r$ such that $o_r(n) > \log^2(n)$ can be done in polynomial time?</p>
 | complexity theory time complexity | 1 | How to find the smallest $r$ such that $o_r(n) > \log^2(n)$ in polynomial time? -- (complexity theory time complexity)
<p>Defining
$$
o_r(n) = \min \left\{ \hspace{1mm} k \in \mathbb{N} \hspace{2mm} | \hspace{2mm} n^k \equiv 1 \hspace{3mm} (\text{mod } r) \hspace{1mm} \right\}
$$
How can we show that fi... | habedi/stack-exchange-dataset |
88,590 | Specify an upper bound of the size m of R with the big O notation | <p>I am trying to learn the Big O notation through the example below, can you help?</p>

<p>Let S be a set of n vertexes of a graph G and R be a set that the set of edges of G. Specify an upper bound of the size m of R with the big O notation. The bound shall be as tight as possible.</p>

<p>Are upper b... | asymptotics | 1 | Specify an upper bound of the size m of R with the big O notation -- (asymptotics)
<p>I am trying to learn the Big O notation through the example below, can you help?</p>

<p>Let S be a set of n vertexes of a graph G and R be a set that the set of edges of G. Specify an upper bound of the size m of R with the b... | habedi/stack-exchange-dataset |
88,591 | How is this lamda function beeing executed in an example for the Y combinator | <p>I have spent a few hours now trying to understand how the Y Combinator is working and how it allows us to construct recursive functions with higher order functions.</p>

<p>I have been going through this derivation <a href="http://mvanier.livejournal.com/2897.html" rel="nofollow noreferrer">http://mvanier.li... | lambda calculus functional programming | 1 | How is this lamda function beeing executed in an example for the Y combinator -- (lambda calculus functional programming)
<p>I have spent a few hours now trying to understand how the Y Combinator is working and how it allows us to construct recursive functions with higher order functions.</p>

<p>I have been go... | habedi/stack-exchange-dataset |
88,599 | If A is mapping reducible to B and A is recognizable, then is B recognizable too? | <p>I learned the proof for the theorem:<br>
If A $\leq_m$ B and B is recognizable, then A is recognizable<br>
and was provided with the theorem:<br>
If A $\leq_m$ B and A is unrecognizable, then B is unrecognizable </p>

<p>So does this work both ways? i.e. does this also hold?</p>

<p>If A... | turing machines reductions | 1 | If A is mapping reducible to B and A is recognizable, then is B recognizable too? -- (turing machines reductions)
<p>I learned the proof for the theorem:<br>
If A $\leq_m$ B and B is recognizable, then A is recognizable<br>
and was provided with the theorem:<br>
If A $\leq_m$ B and A is unrecognizable, then... | habedi/stack-exchange-dataset |
88,601 | How does this reduction to prove undecidability account for epsilon? | <p>I have the following proof that the Empty String problem:<br>
 ES = {M | M accepts $\epsilon$}<br>
 is undecidable:</p>

<p>$f<M,w>$ = Construct a new machine $M_2$ such that:<br>
$M_2$ = given input x erase x from the tape and run M on w:<br>
if M accepts w $\longrightarrow$ accept<b... | turing machines reductions decision problem mapreduce | 1 | How does this reduction to prove undecidability account for epsilon? -- (turing machines reductions decision problem mapreduce)
<p>I have the following proof that the Empty String problem:<br>
 ES = {M | M accepts $\epsilon$}<br>
 is undecidable:</p>

<p>$f<M,w>$ = Construct a new machine $M_2$ ... | habedi/stack-exchange-dataset |
88,612 | Solve every problem with recursion | <p>Is it possible to solve every problem (solvable with turing machine) with only recursion ?
If yes, which principles or theories assure this ?
Thanks</p>
 | turing machines computability computation models recursion | 1 | Solve every problem with recursion -- (turing machines computability computation models recursion)
<p>Is it possible to solve every problem (solvable with turing machine) with only recursion ?
If yes, which principles or theories assure this ?
Thanks</p>
 | habedi/stack-exchange-dataset |
88,616 | How to reduce language is finite to language is regular? | <p>I'm trying to reduce $FIN \leq REGU$, where:</p>

<p>$$FIN = \{ \langle M \rangle \vert T(M) < \infty \} \\ REGU = \{\langle M \rangle \vert T(M) \in REG\}$$</p>

<p>Now one thing I have done so far is this: </p>

<p>$ w \in FIN \implies | T(M_w) < \infty \implies \exists n \in N: L(M_... | formal languages reductions decision problem | 1 | How to reduce language is finite to language is regular? -- (formal languages reductions decision problem)
<p>I'm trying to reduce $FIN \leq REGU$, where:</p>

<p>$$FIN = \{ \langle M \rangle \vert T(M) < \infty \} \\ REGU = \{\langle M \rangle \vert T(M) \in REG\}$$</p>

<p>Now one thing I have don... | habedi/stack-exchange-dataset |
88,618 | SAT solver optimizations of DPLL for unsatisfiable formulas | <p>I am implementing a SAT solver based on DPLL algorithm, and it works fine on small formulas and larger satisfiable problems. My case split is based on a tree like structure, where every branch is tried one by one until solution for the problem is found or until every branch is tried. </p>

<p>So my problem n... | algorithms logic satisfiability sat solvers | 1 | SAT solver optimizations of DPLL for unsatisfiable formulas -- (algorithms logic satisfiability sat solvers)
<p>I am implementing a SAT solver based on DPLL algorithm, and it works fine on small formulas and larger satisfiable problems. My case split is based on a tree like structure, where every branch is tried one by... | habedi/stack-exchange-dataset |
88,629 | Filling a string with wildcards with minimum cost | <p>You are given a string with wildcards, e.g. X***Y*Z. Your goal is to print an input string filling all the wildcards in the given string.</p>

<p>You are allowed to write data to the string in blocks of fixed size: character-by-character, you can write contiguous blocks of identical characters of length 2, 3... | algorithms optimization strings discrete mathematics | 1 | Filling a string with wildcards with minimum cost -- (algorithms optimization strings discrete mathematics)
<p>You are given a string with wildcards, e.g. X***Y*Z. Your goal is to print an input string filling all the wildcards in the given string.</p>

<p>You are allowed to write data to the string in blocks o... | habedi/stack-exchange-dataset |
88,630 | $\lambda$-calculus, is there encoding of for or while? | <p>In $\lambda$-calculus, we can encode arithmetic, numbers, booleans, and even compute factorials of numbers, as shown <a href="https://en.wikipedia.org/wiki/Church_encoding" rel="noreferrer">here</a>.</p>

<p>Is there encoding of "for" or "while"?</p>
 | lambda calculus computation models | 1 | $\lambda$-calculus, is there encoding of for or while? -- (lambda calculus computation models)
<p>In $\lambda$-calculus, we can encode arithmetic, numbers, booleans, and even compute factorials of numbers, as shown <a href="https://en.wikipedia.org/wiki/Church_encoding" rel="noreferrer">here</a>.</p>

<p>Is the... | habedi/stack-exchange-dataset |
88,643 | Constructing an FSA, where Ratio of number of states of FSA to its Minimal DFA Equivalent < 0.5 | <p>I need to choose a language, design a finite automaton M such that L = L(M). Construct a minimum-state DFA M′ equivalent to M in such a way that the ratio of the number of states in M to the number of states in M′ is less than 0.5.</p>

<p>I have zero idea as to how I should approach this. I've tried conside... | formal languages finite automata nondeterminism | 1 | Constructing an FSA, where Ratio of number of states of FSA to its Minimal DFA Equivalent < 0.5 -- (formal languages finite automata nondeterminism)
<p>I need to choose a language, design a finite automaton M such that L = L(M). Construct a minimum-state DFA M′ equivalent to M in such a way that the ratio of the number... | habedi/stack-exchange-dataset |
88,646 | How to prove/disprove distribution of division over union | <p>How can I prove distribution of division over union in relational algebra, i.e. the following:</p>

<p>$$(R \cup S) / X \overset{?}{=} (R / X) \cup (S / X)$$</p>
 | relational algebra | 1 | How to prove/disprove distribution of division over union -- (relational algebra)
<p>How can I prove distribution of division over union in relational algebra, i.e. the following:</p>

<p>$$(R \cup S) / X \overset{?}{=} (R / X) \cup (S / X)$$</p>
 | habedi/stack-exchange-dataset |
88,654 | A question about the definition of PRFs | <p>Let <span class="math-container">$\mathcal{F} = \{ f_{s} \}_{s \in \{\, 0,1 \,\}^{*}}$</span> be a family of computable functions, where <span class="math-container">$f_{s} \colon \{\, 0,1 \,\}^{|s|} \rightarrow \{\, 0,1 \,\}^{|s|}$</span>.</p>

<p>We define a family of functions <span class="math-container"... | pseudo random generators | 1 | A question about the definition of PRFs -- (pseudo random generators)
<p>Let <span class="math-container">$\mathcal{F} = \{ f_{s} \}_{s \in \{\, 0,1 \,\}^{*}}$</span> be a family of computable functions, where <span class="math-container">$f_{s} \colon \{\, 0,1 \,\}^{|s|} \rightarrow \{\, 0,1 \,\}^{|s|}$</span>.</p>&#x... | habedi/stack-exchange-dataset |
88,675 | Proving an algorithm must have the lowest time complexity for sorting in the worst case | <p>I'm curious if anything like this has been proved, or is even possible to prove a statement like:
<strong>"Out of all sorting algorithms, this one has the lowest time complexity for the worst-case."</strong></p>

<p>Or stated more specifically, the statement could look like:
<strong>"Quicksort has th... | time complexity sorting | 1 | Proving an algorithm must have the lowest time complexity for sorting in the worst case -- (time complexity sorting)
<p>I'm curious if anything like this has been proved, or is even possible to prove a statement like:
<strong>"Out of all sorting algorithms, this one has the lowest time complexity for the worst-case... | habedi/stack-exchange-dataset |
88,707 | If $f(n)$ is $O(g(n))$ is it also $O(g(n-d))$? | <p>When trying to prove that a recurrence $g(n)$ satisfies $g(n) = O(f(n))$, we sometimes are not able to find a valid $C$ to show the upper bound, so we try to prove it is $O(f(n-d))$ for some constant $d$ instead. </p>

<p>If we are able to prove that $g(n) = O(f(n-d)$, does this mean that it is also $O(f(n))... | asymptotics | 1 | If $f(n)$ is $O(g(n))$ is it also $O(g(n-d))$? -- (asymptotics)
<p>When trying to prove that a recurrence $g(n)$ satisfies $g(n) = O(f(n))$, we sometimes are not able to find a valid $C$ to show the upper bound, so we try to prove it is $O(f(n-d))$ for some constant $d$ instead. </p>

<p>If we are able to prove... | habedi/stack-exchange-dataset |
88,712 | Algorithm to find exactly two sets of numbers that have the same sum | <p>I am searching for the most efficent implementation of a specific algorithm:</p>

<p>Assume you have a set of positive integers, for example:</p>

<p>X = [1,1,2,3,3,6,8]</p>

<p>The aim is to find exactly two sets (containing together all elements of X), so that the sum of all elements of the... | algorithms | 1 | Algorithm to find exactly two sets of numbers that have the same sum -- (algorithms)
<p>I am searching for the most efficent implementation of a specific algorithm:</p>

<p>Assume you have a set of positive integers, for example:</p>

<p>X = [1,1,2,3,3,6,8]</p>

<p>The aim is to find exactly two... | habedi/stack-exchange-dataset |
88,716 | Can two different complexity classes be equal relative to an oracle? Example request | <p>Is there a known example of two complexity classes, $A$ and $B$, such that:</p>

<ol>
<li><p>$A \neq B$;</p></li>
<li><p>there is an oracle $O$ for which $A^O = B^O$?</p></li>
</ol>

<p>I strongly believe that there are such examples, as otherwise $P = PSPACE$ (note that $P^{PSPACE} = PSP... | complexity theory reference request relativization | 1 | Can two different complexity classes be equal relative to an oracle? Example request -- (complexity theory reference request relativization)
<p>Is there a known example of two complexity classes, $A$ and $B$, such that:</p>

<ol>
<li><p>$A \neq B$;</p></li>
<li><p>there is an oracle $O$ for which $A^O =... | habedi/stack-exchange-dataset |
88,732 | Can someone give a generic definition of any Definite Language in set builder notation? | <p>What I have come across as a definition is - a language $L ⊆ Σ^*$ is said to be definite if and only if $L = E ∪ Σ^*Η$, for some finite languages $E,H ⊆ Σ^*$</p>

<p>Using these questions - <a href="https://cs.stackexchange.com/questions/71374/show-that-every-definite-language-is-accepted-by-a-finite-automat... | formal languages regular languages automata finite automata | 1 | Can someone give a generic definition of any Definite Language in set builder notation? -- (formal languages regular languages automata finite automata)
<p>What I have come across as a definition is - a language $L ⊆ Σ^*$ is said to be definite if and only if $L = E ∪ Σ^*Η$, for some finite languages $E,H ⊆ Σ^*$</p>&#x... | habedi/stack-exchange-dataset |
88,736 | Proving that $xy=yx$ iff $x^2y^2=z^2$ | <p>I was given the following problem as homework: </p>

<blockquote>
 <p>Let $x$, $y$ be words over an alphabet $Σ$. Prove that $xy = yx$ iff there exists a word
 $z$ such that $x^2y^2 = z^2$.</p>
</blockquote>

<p>I was hinted that I am supposed to approach this problem using structural i... | word combinatorics | 1 | Proving that $xy=yx$ iff $x^2y^2=z^2$ -- (word combinatorics)
<p>I was given the following problem as homework: </p>

<blockquote>
 <p>Let $x$, $y$ be words over an alphabet $Σ$. Prove that $xy = yx$ iff there exists a word
 $z$ such that $x^2y^2 = z^2$.</p>
</blockquote>

<p>I was hinted ... | habedi/stack-exchange-dataset |
88,754 | Finding the regular expression equivalent for the given finite automaton | <p><a href="https://i.stack.imgur.com/26oaq.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/26oaq.png" alt="enter image description here"></a></p>

<p>This is another homework problem I'm stuck with. For the given finite automata, I am asked to find out the equivalent regular expression. </p>... | regular languages automata finite automata regular expressions | 1 | Finding the regular expression equivalent for the given finite automaton -- (regular languages automata finite automata regular expressions)
<p><a href="https://i.stack.imgur.com/26oaq.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/26oaq.png" alt="enter image description here"></a></p>

<p>T... | habedi/stack-exchange-dataset |
88,759 | Prefix Sums in Mutable 2D Array | <p>Suppose I have a 2D array <code>M[n][n]</code> of integers (in fact, binary is fine, but I doubt it matters). I am interested in repeated queries of the form: given a coordinate pair $k,l$, what is
$$
\sum_{i = 0}^{k-1} \sum_{j = 0}^{l-1} M[i][j]?
$$
Of course, all these values can be computed in $\m... | complexity theory data structures trees | 1 | Prefix Sums in Mutable 2D Array -- (complexity theory data structures trees)
<p>Suppose I have a 2D array <code>M[n][n]</code> of integers (in fact, binary is fine, but I doubt it matters). I am interested in repeated queries of the form: given a coordinate pair $k,l$, what is
$$
\sum_{i = 0}^{k-1} \sum_{j = 0}... | habedi/stack-exchange-dataset |
88,763 | Solving complexity using summation | <p>I have the following algorithm:</p>

<pre><code>func()
{
 for(i=1; i<n; i=i*2)
 print("aa");
}
</code></pre>

<p>How can I find Big-Oh using summation? </p>
 | algorithm analysis runtime analysis loops | 1 | Solving complexity using summation -- (algorithm analysis runtime analysis loops)
<p>I have the following algorithm:</p>

<pre><code>func()
{
 for(i=1; i<n; i=i*2)
 print("aa");
}
</code></pre>

<p>How can I find Big-Oh using summation? </p>
 | habedi/stack-exchange-dataset |
88,773 | A doubt regarding the acceptance of $\epsilon$ by an automaton testing divisibility of numbers | <p>As we know, $\epsilon$ is the empty string, with length 0. It is not part of any any alphabet by default, unless specifically defined so. However, it is a string over any alphabet.</p>

<p>For example, Given that I need to design a Deterministic or Nondeterministic finite state automaton (without $\epsilon$ ... | formal languages automata finite automata | 1 | A doubt regarding the acceptance of $\epsilon$ by an automaton testing divisibility of numbers -- (formal languages automata finite automata)
<p>As we know, $\epsilon$ is the empty string, with length 0. It is not part of any any alphabet by default, unless specifically defined so. However, it is a string over any alph... | habedi/stack-exchange-dataset |
88,786 | Shortest Non-Subsequence String With Constant-Size Alphabet | <p>Let $S[1..n] \in \Sigma^*$ be a string of $n$ symbols over the alphabet $\Sigma$ where $|\Sigma| \in \mathcal{O}(1)$. Determine a shortest string which cannot be obtained from $S$ by deleting some (possibly no) symbols.</p>

<p>For instance, we are given $\Sigma = \{ A, C, G, T \}$ and $S = ACGTACGT$. In thi... | algorithms dynamic programming strings subsequences | 1 | Shortest Non-Subsequence String With Constant-Size Alphabet -- (algorithms dynamic programming strings subsequences)
<p>Let $S[1..n] \in \Sigma^*$ be a string of $n$ symbols over the alphabet $\Sigma$ where $|\Sigma| \in \mathcal{O}(1)$. Determine a shortest string which cannot be obtained from $S$ by deleting some (po... | habedi/stack-exchange-dataset |
88,799 | ILP runtime seems to be linear? | <p>I have a variation the <a href="https://en.wikipedia.org/wiki/Shortest_path_problem#Linear_programming_formulation" rel="nofollow noreferrer" title="shortest path problem">shortest path problem</a>, formulated as an ILP. 
The system model is as follows:</p>

<ul>
<li><p>There is a connected digraph c... | time complexity optimization np hard integer programming | 1 | ILP runtime seems to be linear? -- (time complexity optimization np hard integer programming)
<p>I have a variation the <a href="https://en.wikipedia.org/wiki/Shortest_path_problem#Linear_programming_formulation" rel="nofollow noreferrer" title="shortest path problem">shortest path problem</a>, formulated as an ILP. &#... | habedi/stack-exchange-dataset |
88,803 | XOR of two NP-Complete languages | <p>Given two NP-Complete languages A and B, show that the language:</p>

<p>$L = A\bigoplus B =\{a\bigoplus b \mid a \in A, b \in B, |a|=|b|\}$</p>

<p>is not necessarily NP-Complete. </p>

<p>Remember $a\bigoplus b$ when $|a|=|b|$ gives 0 when they have the same digit and 1 otherwise.</p>
&... | complexity theory time complexity np complete closure properties | 1 | XOR of two NP-Complete languages -- (complexity theory time complexity np complete closure properties)
<p>Given two NP-Complete languages A and B, show that the language:</p>

<p>$L = A\bigoplus B =\{a\bigoplus b \mid a \in A, b \in B, |a|=|b|\}$</p>

<p>is not necessarily NP-Complete. </p>

<p>... | habedi/stack-exchange-dataset |
88,814 | Determining the complexity of calculating n-th root of an integer, and performing modulo arithmetic? | <p>For a while now, I have been struggling to find a source explaining the complexity of the following 2 elementary operations</p>

<ol>
<li>Calculating the $n^\text{th}$ root of an integer $x$,
$$
\sqrt[\leftroot{-3}\uproot{3}n]{x}
$$</li>
<li>Checking whether
$$
a \equiv b \mod r&#... | complexity theory time complexity asymptotics | 1 | Determining the complexity of calculating n-th root of an integer, and performing modulo arithmetic? -- (complexity theory time complexity asymptotics)
<p>For a while now, I have been struggling to find a source explaining the complexity of the following 2 elementary operations</p>

<ol>
<li>Calculating the... | habedi/stack-exchange-dataset |
88,818 | Which algorithm for game matchmaking in tournament | <p>I organize amateur tournaments every week with random players.
Every week, players sign up, and I get a list with:</p>

<ul>
<li>Name</li>
<li>Rank (1, 2 or 3)</li>
<li>Role (s) (DPS, TANK and HEALER)</li>
</ul>

<p>I need to get balanced teams of 6.
Ideally, there are 2 DPS, ... | algorithms matching computer games | 1 | Which algorithm for game matchmaking in tournament -- (algorithms matching computer games)
<p>I organize amateur tournaments every week with random players.
Every week, players sign up, and I get a list with:</p>

<ul>
<li>Name</li>
<li>Rank (1, 2 or 3)</li>
<li>Role (s) (DPS, TANK and HEALER)</... | habedi/stack-exchange-dataset |
88,821 | Calculate the Time complexity | <p>$T(n)=\sqrt{2T(n-1)}$
what will be the time complexity if $T(n)$ is given as this?
I tried substitution but no result was reached.</p>
 | asymptotics recurrence relation | 1 | Calculate the Time complexity -- (asymptotics recurrence relation)
<p>$T(n)=\sqrt{2T(n-1)}$
what will be the time complexity if $T(n)$ is given as this?
I tried substitution but no result was reached.</p>
 | habedi/stack-exchange-dataset |
88,824 | How to verify the solution to n queens problem | <p>I have made an algorithm by which I recently finished counting solutions to 28 queens problem and I have the number. How do I verify that it is correct?</p>

<p>I have heard that it can be done in quadratic time. That is, given a solution to an nqueen problem it can be verified in polynomial time. I would li... | time complexity | 1 | How to verify the solution to n queens problem -- (time complexity)
<p>I have made an algorithm by which I recently finished counting solutions to 28 queens problem and I have the number. How do I verify that it is correct?</p>

<p>I have heard that it can be done in quadratic time. That is, given a solution to... | habedi/stack-exchange-dataset |
88,825 | Big-O notation analysis | <p>Can I get help to give an analysis of the running time Big-O? I'm not sure if all my answers are correct.</p>

<p>I got for a) $ O(n)$, b) $O(n^3)$, c) $O(n^{1/2})$ and d) $O(log(n))$</p>

<pre><code>(a) 
 sum=0;
 for ( i =0; i<n ; i +=10) 
 ... | time complexity asymptotics runtime analysis performance | 1 | Big-O notation analysis -- (time complexity asymptotics runtime analysis performance)
<p>Can I get help to give an analysis of the running time Big-O? I'm not sure if all my answers are correct.</p>

<p>I got for a) $ O(n)$, b) $O(n^3)$, c) $O(n^{1/2})$ and d) $O(log(n))$</p>

<pre><code>(a) ... | habedi/stack-exchange-dataset |
88,838 | How to define whitespace for certain rules but else ignore it | <p>I am trying to make a programming language for the first time and wonder how it handles whitespace. I can see CFG by default seem to just ignore whitespaces, but what if I want it to use it sometimes? Like when you declare an int people usually write "int b", and the whitespace separate these two items, but if I wri... | context free programming languages parsers | 1 | How to define whitespace for certain rules but else ignore it -- (context free programming languages parsers)
<p>I am trying to make a programming language for the first time and wonder how it handles whitespace. I can see CFG by default seem to just ignore whitespaces, but what if I want it to use it sometimes? Like w... | habedi/stack-exchange-dataset |
88,844 | The Number of Paths in a Directed Graph | <p>Suppose I have a directed graph $G = (V,E)$. Suppose that $v_1$ and $v_2$ are two nodes in the graph. Am I correct the number of simple paths (that is, it has no cycles) from $v_1$ to $v_2$ is $O(E)$? Is it true for the special case of directed acyclic graphs?</p>

<p>Bob</p>
 | algorithms graphs | 1 | The Number of Paths in a Directed Graph -- (algorithms graphs)
<p>Suppose I have a directed graph $G = (V,E)$. Suppose that $v_1$ and $v_2$ are two nodes in the graph. Am I correct the number of simple paths (that is, it has no cycles) from $v_1$ to $v_2$ is $O(E)$? Is it true for the special case of directed acyclic g... | habedi/stack-exchange-dataset |
88,847 | Is set of all regular languages on a specific alphabet a regular language? | <p>so i know that the set of all strings over any finite alphabet is countable, but this question is different</p>

<p>so if our language is set of all regular languages(or set of all regular expressions) on a specific and finite alphabet, then is this set regular? if not then what is it? CFL?</p>

<p>i... | regular languages automata context free | 1 | Is set of all regular languages on a specific alphabet a regular language? -- (regular languages automata context free)
<p>so i know that the set of all strings over any finite alphabet is countable, but this question is different</p>

<p>so if our language is set of all regular languages(or set of all regular ... | habedi/stack-exchange-dataset |
88,850 | How to embed Pearson distance into Euclidean space | <p>I have a lot of numerical vectors, each of dimension 1000. I would like to compare them according to their <a href="https://en.wikipedia.org/wiki/Pearson_correlation_coefficient#Pearson's_distance" rel="nofollow noreferrer">Pearson distance</a>. This works fine but comparing all vectors to each other is quadrati... | nearest neighbour euclidean distance | 1 | How to embed Pearson distance into Euclidean space -- (nearest neighbour euclidean distance)
<p>I have a lot of numerical vectors, each of dimension 1000. I would like to compare them according to their <a href="https://en.wikipedia.org/wiki/Pearson_correlation_coefficient#Pearson's_distance" rel="nofollow noreferr... | habedi/stack-exchange-dataset |
88,861 | Moving an edge in a weighted tree to maximize longest path length | <p>Let $G$ be a undirected edge-weighted tree, where all edge weights are positive. A <em>move</em> of an edge $\{u,v\} \in E(G)$ is the operation of deletion of $\{u,v\}$ and the addition of a new edge $\{x,y\}$, where $x,y \in V(G)$. Intuitively, we can think of the move meaning the deletion of an edge, and the re-in... | graphs optimization discrete mathematics | 1 | Moving an edge in a weighted tree to maximize longest path length -- (graphs optimization discrete mathematics)
<p>Let $G$ be a undirected edge-weighted tree, where all edge weights are positive. A <em>move</em> of an edge $\{u,v\} \in E(G)$ is the operation of deletion of $\{u,v\}$ and the addition of a new edge $\{x,... | habedi/stack-exchange-dataset |
88,866 | Prove that the language represented having equal number of $0$'s and $1$'s and starting with a $0$ is not regular | <p>We have to prove that the language represented having equal number of $0$'s and $1$'s and starting with a $0$ is not regular.</p>

<p>Attempt: We assume that the language is regular. Thus it would satisfy the pumping lemma. Assume the pumping length to be $p$. Let us take the string would be length $p+1$ as ... | regular languages pumping lemma | 1 | Prove that the language represented having equal number of $0$'s and $1$'s and starting with a $0$ is not regular -- (regular languages pumping lemma)
<p>We have to prove that the language represented having equal number of $0$'s and $1$'s and starting with a $0$ is not regular.</p>

<p>Attempt: We assume that ... | habedi/stack-exchange-dataset |
88,867 | Turing machine that accepts L = {#a != #b} | <p>Trying to figure out how to make a deterministic single-tape Turing machine for the language of words comprising as many $a$'s as $b$'s.</p>

<p>I am very confused, because I can't figure out how I would keep track of how many $a$'s and $b$'s there would be. The method for finding $a^nb^n$ goes right and bac... | formal languages turing machines automata | 1 | Turing machine that accepts L = {#a != #b} -- (formal languages turing machines automata)
<p>Trying to figure out how to make a deterministic single-tape Turing machine for the language of words comprising as many $a$'s as $b$'s.</p>

<p>I am very confused, because I can't figure out how I would keep track of h... | habedi/stack-exchange-dataset |
88,874 | What is the name for the comparison used in C's memcmp? | <p>The C <code>memcmp</code> function (and <code>strcmp</code>) does a comparison similar to the function below for comparing integers:</p>

<pre><code>int compare(const int a, const int b) {
 if (a > b) return 1;
 if (b > a) return -1;
 return 0;
}
</code></pre>

<... | terminology comparison | 1 | What is the name for the comparison used in C's memcmp? -- (terminology comparison)
<p>The C <code>memcmp</code> function (and <code>strcmp</code>) does a comparison similar to the function below for comparing integers:</p>

<pre><code>int compare(const int a, const int b) {
 if (a > b) return 1;
... | habedi/stack-exchange-dataset |
88,877 | Time complexity of euler totient function | <p>Code for finding $\phi$(n) is </p>

<pre><code>int phi(int n)
 { 
 int result = n; // Initialize result as n

 // Consider all prime factors of n and subtract their
 // multiples from result
 for (int p=2; p*p<=n; ++p)
 {
 ... | algorithm analysis runtime analysis loops | 1 | Time complexity of euler totient function -- (algorithm analysis runtime analysis loops)
<p>Code for finding $\phi$(n) is </p>

<pre><code>int phi(int n)
 { 
 int result = n; // Initialize result as n

 // Consider all prime factors of n and subtract their
 // mu... | habedi/stack-exchange-dataset |
88,880 | Which definition of PRFs is correct? | <p>Assume the $\mathcal{F} = \{\, f_{s} \,\}_{s \in \{\, 0,1 \,\}^{*}}$ be a family of computable functions, where $f_{s} \colon \{\, 0,1 \,\}^{|s|} \rightarrow \{\, 0,1 \,\}^{|s|}$.</p>

<p>Let $F_{n}$ be a distribution of functions $f_s$ where $s$ is uniformly distributed over $\{\, 0,1 \,\}^{n}$, and let $RF... | pseudo random generators | 1 | Which definition of PRFs is correct? -- (pseudo random generators)
<p>Assume the $\mathcal{F} = \{\, f_{s} \,\}_{s \in \{\, 0,1 \,\}^{*}}$ be a family of computable functions, where $f_{s} \colon \{\, 0,1 \,\}^{|s|} \rightarrow \{\, 0,1 \,\}^{|s|}$.</p>

<p>Let $F_{n}$ be a distribution of functions $f_s$ where... | habedi/stack-exchange-dataset |
88,883 | Loop invariant condition IsPrime program | <p>I'm new to the concept of loop invariant and I'm trying to figure out the loop invariant for a program that returns if an integer is prime and, if not, one possible factorization.
My intuition is that as a loop invariant condition we need i in the range [2,floor(sqrt(n))] and then n mod i !=0 implies n is prime<... | correctness proof loop invariants | 1 | Loop invariant condition IsPrime program -- (correctness proof loop invariants)
<p>I'm new to the concept of loop invariant and I'm trying to figure out the loop invariant for a program that returns if an integer is prime and, if not, one possible factorization.
My intuition is that as a loop invariant condition we... | habedi/stack-exchange-dataset |
88,890 | Greedy Heuristic for the Traveling Salesperson Problem | <p>We're studying Heuristic in my Theoretical CS class, more specifically Greedy-Algorithms for the Traveling Salesperson Problem. The first one is the "next neighbor heuristic", where you start at any given point and connect it with the nearest point and then connect that to the next nearest one until all points are c... | algorithms graphs computational geometry greedy algorithms heuristics | 1 | Greedy Heuristic for the Traveling Salesperson Problem -- (algorithms graphs computational geometry greedy algorithms heuristics)
<p>We're studying Heuristic in my Theoretical CS class, more specifically Greedy-Algorithms for the Traveling Salesperson Problem. The first one is the "next neighbor heuristic", where you s... | habedi/stack-exchange-dataset |
88,891 | Do all the cells in a recurrent neural network share learned parameters? | <p>Most descriptions of modern RNNs present a "folded" characterisation, that is to say, a single cell with a loop back to itself transmitting the hidden state from one step to the next. However, in implementations the RNN is computed "unfolded", so a new cell is created for every step of the sequence up to some maximu... | machine learning neural networks | 1 | Do all the cells in a recurrent neural network share learned parameters? -- (machine learning neural networks)
<p>Most descriptions of modern RNNs present a "folded" characterisation, that is to say, a single cell with a loop back to itself transmitting the hidden state from one step to the next. However, in implementa... | habedi/stack-exchange-dataset |
88,895 | Minimal DFA with more states than its equivalent NFA | <p>I understand that using a bad case for subset construction as provided through an example in the book - Introduction to Automata Theory, Languages and Computation, we can definitely have an NFA with $n+1$ states, and get a corresponding minimal DFA with $2^n$ states due to the power set logic.</p>

<p>But, ... | automata finite automata nondeterminism simulation | 1 | Minimal DFA with more states than its equivalent NFA -- (automata finite automata nondeterminism simulation)
<p>I understand that using a bad case for subset construction as provided through an example in the book - Introduction to Automata Theory, Languages and Computation, we can definitely have an NFA with $n+1$ st... | habedi/stack-exchange-dataset |
88,898 | Determine if a line going through n rectangles exists | <p>I guess this is kinda like asking if 3 (or more) rectangles are collinear.</p>

<p>The question is, given n rectangles on the 2D plane (given as the rectangle's top-left corner coordinates and it's width/height), does there exist a line that goes through all of them?</p>

<p>Notes:</p>

<ul>&... | algorithms computational geometry | 1 | Determine if a line going through n rectangles exists -- (algorithms computational geometry)
<p>I guess this is kinda like asking if 3 (or more) rectangles are collinear.</p>

<p>The question is, given n rectangles on the 2D plane (given as the rectangle's top-left corner coordinates and it's width/height), doe... | habedi/stack-exchange-dataset |
88,899 | A Question about a Question related to Graph Theory and Maximum Flow | <p>The following question is from the book "Introduction to Algorithms" By Cormen and three other authors.</p>

<p>$26.2-10$<br>
Show how to find a maximum flow in a network $G = (V,E)$ by a sequence of at
most $|E|$ augmenting paths. (Hint: Determine the paths after finding the maximum
flow.)</p>&#... | graphs | 1 | A Question about a Question related to Graph Theory and Maximum Flow -- (graphs)
<p>The following question is from the book "Introduction to Algorithms" By Cormen and three other authors.</p>

<p>$26.2-10$<br>
Show how to find a maximum flow in a network $G = (V,E)$ by a sequence of at
most $|E|$ augmen... | habedi/stack-exchange-dataset |
88,903 | Understanding Applicative Evaluation Order with the Z-Combinator | <p>I am trying to understand how the Z-combinator (Y-combinator for applicative order languages) definition came about. As Python is applicative I am using Python for this.</p>

<p>So I know Python's evaluation order is applicative. But I seem to be overlooking something in how applicative order works. To compe... | computability lambda calculus computation models python evaluation strategies | 1 | Understanding Applicative Evaluation Order with the Z-Combinator -- (computability lambda calculus computation models python evaluation strategies)
<p>I am trying to understand how the Z-combinator (Y-combinator for applicative order languages) definition came about. As Python is applicative I am using Python for this.... | habedi/stack-exchange-dataset |
88,911 | Process address space separation in L1 cache of Intel hyperthreaded CPUs | <p>Since a processing core with hyperthreading enabled is presented as two or more cores to the operating system, it can run completely different processes with different, isolated virtual memory spaces. There must be a mechanism that guarantees process address space isolation. How is it done in Intel hyperthreaded CPU... | computer architecture cpu virtual memory | 1 | Process address space separation in L1 cache of Intel hyperthreaded CPUs -- (computer architecture cpu virtual memory)
<p>Since a processing core with hyperthreading enabled is presented as two or more cores to the operating system, it can run completely different processes with different, isolated virtual memory space... | habedi/stack-exchange-dataset |
88,926 | Time complexity to check if there is an edge between two nodes in an adjacency list | <p>I know that the time required to check if there exists an edge between two nodes in an adjacency matrix is $O(1)$ because we can access it directly (i.e: $M[i][j]$). However, I didn't really get why time complexity in an adjacency list to check would be $O(|V|)$, where $V$ represents the vertices. Shouldn't it be $O... | graphs algorithm analysis data structures runtime analysis lists | 1 | Time complexity to check if there is an edge between two nodes in an adjacency list -- (graphs algorithm analysis data structures runtime analysis lists)
<p>I know that the time required to check if there exists an edge between two nodes in an adjacency matrix is $O(1)$ because we can access it directly (i.e: $M[i][j]$... | habedi/stack-exchange-dataset |
88,932 | In two sets, identify set of pairs with maximal sum of connections | <p>Given two sets of items</p>

<p>$A = { a_1, .., a_N }, B = { b_1, .., b_M },$</p>

<p>and assuming a connection weight $w{_i}_j \ge 0$ between any possible pair $(a_i, b_j)$ that contains one item of each set, how can I identify the set of pairs $S$ that maximizes the sum of all involved weights: $\s... | algorithms optimization sorting sets | 1 | In two sets, identify set of pairs with maximal sum of connections -- (algorithms optimization sorting sets)
<p>Given two sets of items</p>

<p>$A = { a_1, .., a_N }, B = { b_1, .., b_M },$</p>

<p>and assuming a connection weight $w{_i}_j \ge 0$ between any possible pair $(a_i, b_j)$ that contains one ... | habedi/stack-exchange-dataset |
88,933 | How does the nearest insertion heuristic for TSP work? | <p>In my theoretical computer science class and we were covering "Heuristics". In it we covered "Greedy Heuristics" for the "Vertex Cover Problem", "Interval Scheduling" and the "Traveling Salesperson Problem". </p>

<p>In it we covered the "Nearest Neighbor", "Closest Pair" and "Insertion" heuristics approach ... | algorithms graphs greedy algorithms heuristics | 1 | How does the nearest insertion heuristic for TSP work? -- (algorithms graphs greedy algorithms heuristics)
<p>In my theoretical computer science class and we were covering "Heuristics". In it we covered "Greedy Heuristics" for the "Vertex Cover Problem", "Interval Scheduling" and the "Traveling Salesperson Problem". </... | habedi/stack-exchange-dataset |
88,936 | deadlock caused by a cyle of locks ? unprobable event causing it or just a false intuition | <p>Thanks a lot for your help.</p>

<p>I want to understand what really causes what I suppose to be a deadlock:</p>

<p>I have standards objects, let's call it 'Words' that contains 3 letters and a key; (it doesn t really matter for my problem)</p>

<p>I have a container (list) of Couples, where... | graphs parallel computing deadlocks | 1 | deadlock caused by a cyle of locks ? unprobable event causing it or just a false intuition -- (graphs parallel computing deadlocks)
<p>Thanks a lot for your help.</p>

<p>I want to understand what really causes what I suppose to be a deadlock:</p>

<p>I have standards objects, let's call it 'Words' that... | habedi/stack-exchange-dataset |
88,938 | Cartesian product of regular expressions? | <p>My textbook has a problem to find the regular expression that describes the set of all strings of <code>0</code>'s and <code>1</code>'s whose number of <code>0</code>'s is divisible by <code>5</code> and whose number of <code>1</code>'s is even.</p>

<p>I can write a regular expression for each condition </p... | finite automata regular expressions | 1 | Cartesian product of regular expressions? -- (finite automata regular expressions)
<p>My textbook has a problem to find the regular expression that describes the set of all strings of <code>0</code>'s and <code>1</code>'s whose number of <code>0</code>'s is divisible by <code>5</code> and whose number of <code>1</code>... | habedi/stack-exchange-dataset |
88,939 | What are some examples of types that can't be derived set theoretically? | <p>I'm hoping for examples that aren't too abstract or useless in day-to-day programming, though not with a lot of hope, since in Bartosz Milewski's book, it is stated that generally speaking, the category <strong>Set</strong> is good enough, but <a href="https://bartoszmilewski.com/2014/11/24/types-and-functions/" rel... | type theory category theory | 1 | What are some examples of types that can't be derived set theoretically? -- (type theory category theory)
<p>I'm hoping for examples that aren't too abstract or useless in day-to-day programming, though not with a lot of hope, since in Bartosz Milewski's book, it is stated that generally speaking, the category <strong>... | habedi/stack-exchange-dataset |
88,942 | Minimum edge cover with a constraint | <p>An edge cover of a graph is a set of edges such that every vertex of the graph is incident to at least one edge of the set. I am interested in finding the minimum edge cover of a tree such that each vertex is incident to an odd number of edges. Is anything similar studied in Computer Science? </p>
 | graphs trees | 1 | Minimum edge cover with a constraint -- (graphs trees)
<p>An edge cover of a graph is a set of edges such that every vertex of the graph is incident to at least one edge of the set. I am interested in finding the minimum edge cover of a tree such that each vertex is incident to an odd number of edges. Is anything simil... | habedi/stack-exchange-dataset |
88,945 | Surprisingly high collision rates when hashing a short list with few buckets | <p>I'm trying to help my daughter with her CS assignment on hashing. She has an input list of about 4000 English words, each 5 letters long. The prof has limited her to 4000 output buckets (digests? -- it's been a long time since I did this stuff). And the output from the hashing function is an int modulo 4000.</p>
... | hash | 1 | Surprisingly high collision rates when hashing a short list with few buckets -- (hash)
<p>I'm trying to help my daughter with her CS assignment on hashing. She has an input list of about 4000 English words, each 5 letters long. The prof has limited her to 4000 output buckets (digests? -- it's been a long time since I d... | habedi/stack-exchange-dataset |
88,956 | is L = {<M> | M is a tm such that t(n) = O(n^2) } in R? RE? CO-RE? CO-RE / RE? | <p>L is the language of all turing machines that its computing time on all inputs is O(n^2).
my thoughts is that the language is in CO-RE / RE. the language cannot be accepted because in order to make sure that there is no word W such that M halts on it after n^2 steps, you need to scan all words in the universe - ... | turing machines computability | 1 | is L = {<M> | M is a tm such that t(n) = O(n^2) } in R? RE? CO-RE? CO-RE / RE? -- (turing machines computability)
<p>L is the language of all turing machines that its computing time on all inputs is O(n^2).
my thoughts is that the language is in CO-RE / RE. the language cannot be accepted because in order to make s... | habedi/stack-exchange-dataset |
88,969 | Find the longest contigous subsequence where each pair's difference is at most p | <blockquote>
 <p>Given input sequence $x_1,...,x_n$, find the longest contigous subsequence $x_i,... x_l$ where each pair $(x_j,x_k)$ satisfies that $|x_j - x_k| \le p$.</p>
</blockquote>

<p>I have come up with simple $\mathcal{O}(n^2)$ solution.</p>

<p><img src="https://image.ibb.co/dxOdJS/s... | algorithms subsequences | 1 | Find the longest contigous subsequence where each pair's difference is at most p -- (algorithms subsequences)
<blockquote>
 <p>Given input sequence $x_1,...,x_n$, find the longest contigous subsequence $x_i,... x_l$ where each pair $(x_j,x_k)$ satisfies that $|x_j - x_k| \le p$.</p>
</blockquote>

<p>I... | habedi/stack-exchange-dataset |
88,970 | How to read off the set represented by a van-Emde-Boas tree? | <p>I'm reviewing my background in Algorithms and DS design. Specifically I never went through the van Emde Boas Tree. Though I can undestand the <em>proto-vEB</em> with related picture. I'm struggling to understand the actual data structure. I have no clue how the "min" and "max" members are actually used, I'm not talk... | data structures trees sets integers van emde boas trees | 1 | How to read off the set represented by a van-Emde-Boas tree? -- (data structures trees sets integers van emde boas trees)
<p>I'm reviewing my background in Algorithms and DS design. Specifically I never went through the van Emde Boas Tree. Though I can undestand the <em>proto-vEB</em> with related picture. I'm struggli... | habedi/stack-exchange-dataset |
88,971 | Turing Machine that halts iff the tape contains at least two '1's | <blockquote>
 <p>Contruct a Turing Machine that halts if and only if the tape it is on contains at least two '1's.</p>
</blockquote>

<p>My attempt:</p>

<p>The gist of this turing machine is that it has to check all of the cells, and since it is infinite in both directions, one way of indexing... | turing machines | 1 | Turing Machine that halts iff the tape contains at least two '1's -- (turing machines)
<blockquote>
 <p>Contruct a Turing Machine that halts if and only if the tape it is on contains at least two '1's.</p>
</blockquote>

<p>My attempt:</p>

<p>The gist of this turing machine is that it has to c... | habedi/stack-exchange-dataset |
88,990 | How to extract a set $C$ that contains $N$ subsets of a set $B$, covers all elements of an external set $A$, but $N$ is minimal? | <p>Let $A$ denote a set that contains a relatively large number of different strings. Let $S_i$ denote these strings. </p>

<p>Let $B$ denote a set of sets such that each subset contains a (relatively small, usually not greater than 100) number of different strings. Let $B_i$ denote these subsets. </p>
&#... | algorithms optimization time complexity sets | 1 | How to extract a set $C$ that contains $N$ subsets of a set $B$, covers all elements of an external set $A$, but $N$ is minimal? -- (algorithms optimization time complexity sets)
<p>Let $A$ denote a set that contains a relatively large number of different strings. Let $S_i$ denote these strings. </p>

<p>Let $... | habedi/stack-exchange-dataset |
88,991 | Placing small circles randomly inside a larger circle, where no two small circles intersect | <p>Sorry if this is the wrong place to ask, was unsure...let me know if it belongs some where else.</p>

<p>So i am trying to work out a way to write an algorithm to place a series of small circles of a set radius (all the small circles have the same radius), inside a larger circle.</p>

<p>The small ci... | algorithms computational geometry discrete mathematics randomness | 1 | Placing small circles randomly inside a larger circle, where no two small circles intersect -- (algorithms computational geometry discrete mathematics randomness)
<p>Sorry if this is the wrong place to ask, was unsure...let me know if it belongs some where else.</p>

<p>So i am trying to work out a way to write... | habedi/stack-exchange-dataset |
88,997 | Calculating $\sum_{i=1}^a \lfloor a/i \rfloor i^2$ | <p>I have a sum:<br>
$$S = \sum_{i=1}^n{\lfloor a/i \rfloor i^2},$$<br>
where $a$ is a constant. 
Is there a way to speed this up? That is, can we avoid iterating overl all $i$s, possibly calculating it in logarithmic or better time, something manageable when $a$ is big, <code>n = a/2</code>? I tried lots w... | algorithms number theory iteration | 1 | Calculating $\sum_{i=1}^a \lfloor a/i \rfloor i^2$ -- (algorithms number theory iteration)
<p>I have a sum:<br>
$$S = \sum_{i=1}^n{\lfloor a/i \rfloor i^2},$$<br>
where $a$ is a constant. 
Is there a way to speed this up? That is, can we avoid iterating overl all $i$s, possibly calculating it in logarithmic... | habedi/stack-exchange-dataset |
89,001 | No of Actions in if statement | <p>i am new to analysis of algorithm . i am having an if condition.</p>

<pre><code>If (I !=j AND A[i]==A[j])
</code></pre>

<p>i am counting the operations as </p>

<pre><code>i) accessing element from Array A[] 
ii)compairing i!=j 

iii) compairing a[i]==a[j]
</code></pre>&... | algorithms | 1 | No of Actions in if statement -- (algorithms)
<p>i am new to analysis of algorithm . i am having an if condition.</p>

<pre><code>If (I !=j AND A[i]==A[j])
</code></pre>

<p>i am counting the operations as </p>

<pre><code>i) accessing element from Array A[] 
ii)compairing i!=j 

... | habedi/stack-exchange-dataset |
89,004 | L = {<M> | M is a TM and halts on every input after 5 steps exactly } - is L decidable? | <p>in order for M to belong to L, it must halts on all inputs after 5 steps exactly. is the problem not decidable ? how can it be proved ? I could not succeed in doing a reduction from Htm as the attempt to count M(w) steps failed.</p>

<p>update:
apparently the language is in R. can anyone provide a proof?... | turing machines | 1 | L = {<M> | M is a TM and halts on every input after 5 steps exactly } - is L decidable? -- (turing machines)
<p>in order for M to belong to L, it must halts on all inputs after 5 steps exactly. is the problem not decidable ? how can it be proved ? I could not succeed in doing a reduction from Htm as the attempt to coun... | habedi/stack-exchange-dataset |
89,008 | Data-structure for dynamic disjoint-sets | <p>I have a collection of objects, with certain properties (let say 3 - zone, type, owner) only having a small predetermined possible set of values (like enum).</p>

<p>This is just a simple (javascript) array of gaming cards (think "magic the gathering"), that could be in different zones (deck, hand, grave, pl... | data structures sets database theory searching | 1 | Data-structure for dynamic disjoint-sets -- (data structures sets database theory searching)
<p>I have a collection of objects, with certain properties (let say 3 - zone, type, owner) only having a small predetermined possible set of values (like enum).</p>

<p>This is just a simple (javascript) array of gaming... | habedi/stack-exchange-dataset |
89,016 | Structural induction proof | <p>I need to prove the following:</p>

<pre><code>reverse(append(zs, z)) = Cons(z, reverse(zs))
</code></pre>

<p>Where:</p>

<pre><code>sealed abstract class IntList
case object Nil extends IntList
case class Cons(x: Int, xs: IntList) extends IntList

def append(xs: IntList,... | programming languages | 1 | Structural induction proof -- (programming languages)
<p>I need to prove the following:</p>

<pre><code>reverse(append(zs, z)) = Cons(z, reverse(zs))
</code></pre>

<p>Where:</p>

<pre><code>sealed abstract class IntList
case object Nil extends IntList
case class Cons(x: Int, xs: Int... | habedi/stack-exchange-dataset |
89,018 | What is the difference between exactness and optimality of an algorithm? | <p>I'm studying some papers related to graph partitioning (GP). It is well-known that the GP problem is NP-Complete. Based on my understanding, it means that there is no polynomial time solution to solve this problem, or there is no optimal solution for that. 
The following paper mentioned this fact in its introduc... | algorithms | 1 | What is the difference between exactness and optimality of an algorithm? -- (algorithms)
<p>I'm studying some papers related to graph partitioning (GP). It is well-known that the GP problem is NP-Complete. Based on my understanding, it means that there is no polynomial time solution to solve this problem, or there is n... | habedi/stack-exchange-dataset |
89,021 | Is halting problem computable for particular inputs/assumptions | <p>From my understanding of the proof that halting problem is not computable, this problem is not computable because if we have a program P(x) which computes if the program x halts or not, we got a paradox when giving P as an input to the same P, having: P(P), trying to decide if P halts or not using P itself.</p>
... | halting problem | 1 | Is halting problem computable for particular inputs/assumptions -- (halting problem)
<p>From my understanding of the proof that halting problem is not computable, this problem is not computable because if we have a program P(x) which computes if the program x halts or not, we got a paradox when giving P as an input to ... | habedi/stack-exchange-dataset |
89,024 | Do all Regular Expressions describe Regular Languages? | <p>I understand that for every regular language, there exists an equivalent regular expression. However, can that be used in the opposite direction? Does every regular expression have an equivalent regular language? Or is the set of regular languages a subset of regular expressions?</p>

<p>If this is not the c... | regular languages automata regular expressions | 1 | Do all Regular Expressions describe Regular Languages? -- (regular languages automata regular expressions)
<p>I understand that for every regular language, there exists an equivalent regular expression. However, can that be used in the opposite direction? Does every regular expression have an equivalent regular languag... | habedi/stack-exchange-dataset |
89,028 | Notation for expressing function call count during a program run | <p>Which notation can be used for expressing how many times that function or subroutine called during a run of a program?</p>

<p>Example program pseudocode:</p>

<p>$
a \gets 0 \\
\textbf{While } a \neq 5 \textbf{ do} \\
\quad \textit{function1()} \\
\quad a \gets a + 1 \\
\textbf{e... | notation | 1 | Notation for expressing function call count during a program run -- (notation)
<p>Which notation can be used for expressing how many times that function or subroutine called during a run of a program?</p>

<p>Example program pseudocode:</p>

<p>$
a \gets 0 \\
\textbf{While } a \neq 5 \textbf{ do... | habedi/stack-exchange-dataset |
89,029 | Counting restricted partitions | <p>Given positive intgers $N$ and $S$ i need to count in how many ways $N$ can be decomposed as sum of $S$ positive integers not greater than $\frac{N}{2}$:
$$ N = x_1 + \dots + x_S, ~~~~ 0 \leq x_i \leq \frac{N}{2} $$</p>

<p>Two partitions are considered distinct if any of the summands has distinct values... | combinatorics dynamic programming efficiency | 1 | Counting restricted partitions -- (combinatorics dynamic programming efficiency)
<p>Given positive intgers $N$ and $S$ i need to count in how many ways $N$ can be decomposed as sum of $S$ positive integers not greater than $\frac{N}{2}$:
$$ N = x_1 + \dots + x_S, ~~~~ 0 \leq x_i \leq \frac{N}{2} $$</p>

<p>... | habedi/stack-exchange-dataset |
89,031 | What is the origin of dot notation? | <p>In object-oriented programming, dot notation is used when accessing the properties or methods of a class:</p>

<pre><code>Dog dog
print dog.name
>> "Fido"
dog.walk()
>> Walking the dog now...
</code></pre>

<p>What is the origin of that syntax and why the <code>.</code... | programming languages history object oriented | 1 | What is the origin of dot notation? -- (programming languages history object oriented)
<p>In object-oriented programming, dot notation is used when accessing the properties or methods of a class:</p>

<pre><code>Dog dog
print dog.name
>> "Fido"
dog.walk()
>> Walking the dog now...&#x... | habedi/stack-exchange-dataset |
89,039 | Dynamic Programming on bracketed sequences | <p>I am currently working on the following problem that involves developing a dynamic programming algorithm for finding the length of the shortest <em>fully bracketed expression</em> (FBE), $y$ that contains a given string $x = x_1x_2...x_n$. An FBE is defined as a string over the characters (,),[, and ] that is either... | algorithms dynamic programming | 1 | Dynamic Programming on bracketed sequences -- (algorithms dynamic programming)
<p>I am currently working on the following problem that involves developing a dynamic programming algorithm for finding the length of the shortest <em>fully bracketed expression</em> (FBE), $y$ that contains a given string $x = x_1x_2...x_n$... | habedi/stack-exchange-dataset |
89,044 | Efficiently generating a prime polynomial of a given degree | <p>I'm playing around with finite field arithmetic and implementing it in a little library. I'd like to be able to handle arbitrary finite fields given their size and characteristic. I don't want to write down a prime polynomial for every given possible finite field though. How can I generate a prime polynomial of a gi... | algorithms | 1 | Efficiently generating a prime polynomial of a given degree -- (algorithms)
<p>I'm playing around with finite field arithmetic and implementing it in a little library. I'd like to be able to handle arbitrary finite fields given their size and characteristic. I don't want to write down a prime polynomial for every given... | habedi/stack-exchange-dataset |
89,061 | Developing invariants for comparing two strings | <p>The following algorithm is supposed to compare two strings $S_1$ and $S_2$ ("/\" for empty string):</p>

<pre><code>X = S1 
Y = S2

E = true 
// (1)
while X != /\ and Y != /\ and E == true 
 if head(X) == head(Y) 
 X = tail(X)
 Y = tail(Y)
 e... | logic loop invariants hoare logic | 1 | Developing invariants for comparing two strings -- (logic loop invariants hoare logic)
<p>The following algorithm is supposed to compare two strings $S_1$ and $S_2$ ("/\" for empty string):</p>

<pre><code>X = S1 
Y = S2

E = true 
// (1)
while X != /\ and Y != /\ and E == true ... | habedi/stack-exchange-dataset |
89,064 | Write algorithm for biased toss of a coin | <p>Given a biased coin whose probability for Heads is 0.67 and Tails is 0.33, write an algorithm which will print the Heads and Tails with this probability.</p>

<p>I am not able to proceed with the problem. What should be my approach ?</p>
 | algorithms | 1 | Write algorithm for biased toss of a coin -- (algorithms)
<p>Given a biased coin whose probability for Heads is 0.67 and Tails is 0.33, write an algorithm which will print the Heads and Tails with this probability.</p>

<p>I am not able to proceed with the problem. What should be my approach ?</p>
 | habedi/stack-exchange-dataset |
89,074 | How to efficiently sort and filter a large iterator | <p>Given an huge iterator (millions of random elements) and asked to obtain the top 10 elements in descending/ascending order. 
What is an efficient way or algorithm to do this?</p>

<p><strong>NOTE</strong>: The iterator size is to huge and cannot be all loaded into memory and in-place sorting done. (I nee... | algorithms sorting | 1 | How to efficiently sort and filter a large iterator -- (algorithms sorting)
<p>Given an huge iterator (millions of random elements) and asked to obtain the top 10 elements in descending/ascending order. 
What is an efficient way or algorithm to do this?</p>

<p><strong>NOTE</strong>: The iterator size is to... | habedi/stack-exchange-dataset |
89,081 | Are consensus (and atomic broadcast) protocols limited by single node's resources? | <p>The main question is the following:<br>
<strong>When designing a system supporting atomic broadcast, can it be proved theoretically that the performance & scalability dimensions (i.e. latency, throughput, dataset size) of the system are limited by the performance of a single node?</strong></p>

<p>To... | algorithms distributed systems consensus | 1 | Are consensus (and atomic broadcast) protocols limited by single node's resources? -- (algorithms distributed systems consensus)
<p>The main question is the following:<br>
<strong>When designing a system supporting atomic broadcast, can it be proved theoretically that the performance & scalability dimensions (i... | habedi/stack-exchange-dataset |
89,082 | Can the regular image of a context-free language be undecidable? | <p>I just need to know the truth or falsity of a simple statement.</p>

<p>Let $L_1$ be a context-free language over an alphabet which contains some number of characters $\Sigma$, as well as a single, special metacharacter “|”. Suppose that every string in $L_1$ contains exactly one metacharacter. L... | formal languages regular languages context free closure properties | 1 | Can the regular image of a context-free language be undecidable? -- (formal languages regular languages context free closure properties)
<p>I just need to know the truth or falsity of a simple statement.</p>

<p>Let $L_1$ be a context-free language over an alphabet which contains some number of characters $\Sig... | habedi/stack-exchange-dataset |
89,095 | Activity Selection and Matroid Theory | <p>Many people on different articles suggests that if an optimization problem has a greedy solution, the underlying structure must have matroid property.</p>

<p>I was trying to understand this. So far, I was able to prove that for, </p>

<ol>
<li>Maximum sum of m integers among n integer. </li>&#... | greedy algorithms matroids | 1 | Activity Selection and Matroid Theory -- (greedy algorithms matroids)
<p>Many people on different articles suggests that if an optimization problem has a greedy solution, the underlying structure must have matroid property.</p>

<p>I was trying to understand this. So far, I was able to prove that for, </p>
... | habedi/stack-exchange-dataset |
89,106 | ResNet output dimensions | <p>So I am currently going over the <a href="https://www.cv-foundation.org/openaccess/content_cvpr_2016/papers/He_Deep_Residual_Learning_CVPR_2016_paper.pdf" rel="nofollow noreferrer" title="ResNet">ResNet</a> paper and trying to understand the output dimensions of each of the layer, and it seems that I am already stuc... | neural networks | 1 | ResNet output dimensions -- (neural networks)
<p>So I am currently going over the <a href="https://www.cv-foundation.org/openaccess/content_cvpr_2016/papers/He_Deep_Residual_Learning_CVPR_2016_paper.pdf" rel="nofollow noreferrer" title="ResNet">ResNet</a> paper and trying to understand the output dimensions of each of ... | habedi/stack-exchange-dataset |
89,109 | Question about proving that Rado's function is non-computable | <p>I am currently following the proof, found <a href="http://www.win.tue.nl/~wijers/shallit.pdf" rel="nofollow noreferrer">here</a>, that Rado's function
$$
\Sigma (n) = \max \{ \text{# of 1's that may be written to a tape by an n-state turing machine} \}
$$
is non-computable. Within this proof, they sa... | turing machines computability check my answer | 1 | Question about proving that Rado's function is non-computable -- (turing machines computability check my answer)
<p>I am currently following the proof, found <a href="http://www.win.tue.nl/~wijers/shallit.pdf" rel="nofollow noreferrer">here</a>, that Rado's function
$$
\Sigma (n) = \max \{ \text{# of 1's that m... | habedi/stack-exchange-dataset |
89,115 | Does it make sense to talk about the complexity of non-computable functions (such as the Halting problem)? | <p>I have seen numerous proofs (such as <a href="https://stackoverflow.com/questions/6990683/proof-that-the-halting-problem-is-np-hard">this</a>) that the Halting problem is in the class of NP. However, the Halting problem is non-computable.</p>

<p>Does it make sense to discuss the complexity of computing a fu... | complexity theory computability halting problem | 1 | Does it make sense to talk about the complexity of non-computable functions (such as the Halting problem)? -- (complexity theory computability halting problem)
<p>I have seen numerous proofs (such as <a href="https://stackoverflow.com/questions/6990683/proof-that-the-halting-problem-is-np-hard">this</a>) that the Halti... | habedi/stack-exchange-dataset |
89,126 | Thompson Regular Expression Search Algorithm 3rd Stage | <p>My professor assigned us to read Thompson' <a href="https://www.fing.edu.uy/inco/cursos/intropln/material/p419-thompson.pdf" rel="nofollow noreferrer">Regular Expression Search Algorithm paper</a>. I am struggling to understand the third stage of the compiler. The first two stages are as follows:</p>

<ol>&#... | formal languages regular expressions search algorithms compilers | 1 | Thompson Regular Expression Search Algorithm 3rd Stage -- (formal languages regular expressions search algorithms compilers)
<p>My professor assigned us to read Thompson' <a href="https://www.fing.edu.uy/inco/cursos/intropln/material/p419-thompson.pdf" rel="nofollow noreferrer">Regular Expression Search Algorithm paper... | habedi/stack-exchange-dataset |
89,129 | shortest cycle passing through vertices a and b with changeable edge weights | <p>given a weighted undirected graph with $N$ vertices $(N \leqslant 500)$ we start from vertex $S$ and wo go to $M$ and then we go to $T$ and then we return to $S$.</p>

<p>each edge in graph has weight $a_i$ at the beginning but after the first time we pass any edge that edge weight will become $b_i$. ($b_i ... | graphs shortest path | 1 | shortest cycle passing through vertices a and b with changeable edge weights -- (graphs shortest path)
<p>given a weighted undirected graph with $N$ vertices $(N \leqslant 500)$ we start from vertex $S$ and wo go to $M$ and then we go to $T$ and then we return to $S$.</p>

<p>each edge in graph has weight $a_i... | habedi/stack-exchange-dataset |
89,132 | Given three languages L1 L2 L3 that do not intirsect could one be TR and the other TD and the third neither | <p>where $L_{1} \cup L_{2} \cup L_{3} = \sum^{*}$ and </p>

<p>$L_{1} \cap L_{2} = \emptyset$ and $L_{2} \cap L_{3} = \emptyset$ and $L_{1} \cap L_{3} = \emptyset$</p>

<p>is it possible that $L_{1}$ is decidable, $L_{2}$ is recognizable but not decidable</p>

<p>and $L_{3}$ is not recognizable?... | complexity theory np complete undecidability | 1 | Given three languages L1 L2 L3 that do not intirsect could one be TR and the other TD and the third neither -- (complexity theory np complete undecidability)
<p>where $L_{1} \cup L_{2} \cup L_{3} = \sum^{*}$ and </p>

<p>$L_{1} \cap L_{2} = \emptyset$ and $L_{2} \cap L_{3} = \emptyset$ and $L_{1} \cap L_{3} = \... | habedi/stack-exchange-dataset |
89,134 | find an element in array that appeared at least 51% times | <p>Given an array with n rational numbers, element in is array called popular if it have appeared at least in 51% of the indices.</p>

<p>I have to design an algorithm that finds such element in O(n) worst case complexity time, that if there is one.</p>

<p>The only ideas I have is to use hash tables bu... | algorithms | 1 | find an element in array that appeared at least 51% times -- (algorithms)
<p>Given an array with n rational numbers, element in is array called popular if it have appeared at least in 51% of the indices.</p>

<p>I have to design an algorithm that finds such element in O(n) worst case complexity time, that if th... | habedi/stack-exchange-dataset |
89,136 | Coalescing by register allocation | <p>I have a rough idea of what coalescing in terms of memory access by threads is, but now, when learning about compilers, the term coalescing also appears when talking about register allocation.</p>

<p>In my book, it is just briefly mentioned, that coalescing for register allocation is just merging nodes from... | compilers memory management | 1 | Coalescing by register allocation -- (compilers memory management)
<p>I have a rough idea of what coalescing in terms of memory access by threads is, but now, when learning about compilers, the term coalescing also appears when talking about register allocation.</p>

<p>In my book, it is just briefly mentioned,... | habedi/stack-exchange-dataset |
89,140 | How to check if a specific ILP problem can be solved in polynomial time or not? | <p>How can we know that a specific ILP problem is solvable in polynomial time or not given the constraints?</p>
 | discrete mathematics linear programming integer programming | 1 | How to check if a specific ILP problem can be solved in polynomial time or not? -- (discrete mathematics linear programming integer programming)
<p>How can we know that a specific ILP problem is solvable in polynomial time or not given the constraints?</p>
 | habedi/stack-exchange-dataset |
89,146 | extend ECMAScript by adding new keywords and syntax | <p>I would like to extend ECMAScript by adding new keywords and syntax to it, for example:</p>

<p>|variableName| stipulates a special kind of variable which I would like to be able to include in a normal ECMAScript line of code, for example:</p>

<pre><code>|variable1| = 1 + 1
|variable1| = |variab... | programming languages parsers language design | 1 | extend ECMAScript by adding new keywords and syntax -- (programming languages parsers language design)
<p>I would like to extend ECMAScript by adding new keywords and syntax to it, for example:</p>

<p>|variableName| stipulates a special kind of variable which I would like to be able to include in a normal ECMA... | habedi/stack-exchange-dataset |
89,148 | Classical set theory and the existence of at least one set | <p>As a student of mathematics I used to accept the argument that the existence of the empty set followed from the axiom schema of comprehension, so long as we could prove the existence of at least one set: if <code>a</code> is any set, then we can derive the existence of <code>{x:a | bot }</code>. I would then argue u... | logic first order logic | 1 | Classical set theory and the existence of at least one set -- (logic first order logic)
<p>As a student of mathematics I used to accept the argument that the existence of the empty set followed from the axiom schema of comprehension, so long as we could prove the existence of at least one set: if <code>a</code> is any ... | habedi/stack-exchange-dataset |
89,151 | Show that the collection of Turing-recognizable languages is closed under homomorphism | <p>I have seen this question here,
<a href="https://cs.stackexchange.com/questions/87475/closure-of-turing-recognizable-languages-under-homomorphism">Closure of Turing-recognizable languages under homomorphism</a>
But actually this question answers the question of "What is the relation between homomorphism and ... | formal languages turing machines closure properties | 1 | Show that the collection of Turing-recognizable languages is closed under homomorphism -- (formal languages turing machines closure properties)
<p>I have seen this question here,
<a href="https://cs.stackexchange.com/questions/87475/closure-of-turing-recognizable-languages-under-homomorphism">Closure of Turing-reco... | habedi/stack-exchange-dataset |
89,159 | Updation in log n | <p>I am working on a problem where I need to binary search on a given array and there can be updates for a given index. As the updates can occur frequently, I need to do it as efficiently as possible.
Could you please suggest an appropriate data structure which would update the element in O(log n) and allow me to p... | data structures | 1 | Updation in log n -- (data structures)
<p>I am working on a problem where I need to binary search on a given array and there can be updates for a given index. As the updates can occur frequently, I need to do it as efficiently as possible.
Could you please suggest an appropriate data structure which would update th... | habedi/stack-exchange-dataset |
89,165 | Training a neural net without labels in Reinforcement Learning | <p>I am trying to dig further into machine learning and I am making a program to play a game as a start. I have created a game that is based on the mobile game <em>Flappy Bird</em> and can be generalized to the following:</p>

<ul>
<li>Actions $A = \{\text{no action}, \text{tap}\}$ </li>
<li>States $S \... | machine learning artificial intelligence neural networks | 1 | Training a neural net without labels in Reinforcement Learning -- (machine learning artificial intelligence neural networks)
<p>I am trying to dig further into machine learning and I am making a program to play a game as a start. I have created a game that is based on the mobile game <em>Flappy Bird</em> and can be gen... | habedi/stack-exchange-dataset |
89,181 | Regular expression for string with substring 010 and ending with 01 | <p>How can one design a regular expression for given string in title ?</p>

<p>Also how can we draw DFA of that regular expression?</p>

<p>I've tried many expressions but couldn't succeed, please help.</p>
 | regular languages finite automata regular expressions | 1 | Regular expression for string with substring 010 and ending with 01 -- (regular languages finite automata regular expressions)
<p>How can one design a regular expression for given string in title ?</p>

<p>Also how can we draw DFA of that regular expression?</p>

<p>I've tried many expressions but could... | habedi/stack-exchange-dataset |
89,189 | Is there any mechanism where the kernel portion of an OS in memory may also be swapped? | <p>I'm recently learning the part of <em>I/O buffering</em> of operating system and according to the book I use, </p>

<blockquote>
 <p>When a user process issues an I/O request, the OS assigns a buffer in the system portion of main memory to the operation.</p>
</blockquote>

<p>I understand ho... | operating systems memory management | 1 | Is there any mechanism where the kernel portion of an OS in memory may also be swapped? -- (operating systems memory management)
<p>I'm recently learning the part of <em>I/O buffering</em> of operating system and according to the book I use, </p>

<blockquote>
 <p>When a user process issues an I/O request,... | habedi/stack-exchange-dataset |
89,194 | Is subset sum problem with multiplicities NP-complete? | <p>To be specific, the problem is formalized as follows.</p>

<p>Given a set of integers $\{a_1,\ldots,a_n\}$, determine whether there exist non-negative integers $x_1,\ldots,x_n$ such that $a_1x_1+\cdots+a_nx_n=0$ and at least one of $x_1,\ldots,x_n$ is positive. </p>

<p>Note this is not a duplicate o... | complexity theory np complete subset sum | 1 | Is subset sum problem with multiplicities NP-complete? -- (complexity theory np complete subset sum)
<p>To be specific, the problem is formalized as follows.</p>

<p>Given a set of integers $\{a_1,\ldots,a_n\}$, determine whether there exist non-negative integers $x_1,\ldots,x_n$ such that $a_1x_1+\cdots+a_nx_n... | habedi/stack-exchange-dataset |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.