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 |
|---|---|---|---|---|---|---|
77,913 | What is the time and space complexity of the algorithm to either prove or refute that given expression is equals to (A+B)^n for any natural number n | <p><strong>Note</strong> that this is <strong>not</strong> duplicate of my previous question: how to simplify algebraic expressions, though it is similar, but still this is different, this is <strong>not</strong> the same.</p>

<p>I need an algorithm that either proves or refutes that:</p>

<p>∀X... | complexity theory time complexity space complexity | 1 | What is the time and space complexity of the algorithm to either prove or refute that given expression is equals to (A+B)^n for any natural number n -- (complexity theory time complexity space complexity)
<p><strong>Note</strong> that this is <strong>not</strong> duplicate of my previous question: how to simplify algeb... | habedi/stack-exchange-dataset |
77,924 | Reason for finding partial order of a graph | <p>In a recent algorithms course we had to form a condensation graph and compute its reflexive-transitive closure to get a partial order. But it was never really explained why we would want to do that in a graph. I understand the gist of a condensation graph in that it highlights the strongly connected components, but ... | algorithms graphs | 1 | Reason for finding partial order of a graph -- (algorithms graphs)
<p>In a recent algorithms course we had to form a condensation graph and compute its reflexive-transitive closure to get a partial order. But it was never really explained why we would want to do that in a graph. I understand the gist of a condensation ... | habedi/stack-exchange-dataset |
77,925 | How to generate regular expression for language of regular expressions? | <p>Alphabets = $\{0, 1, \epsilon, \emptyset, [, ], \cup, \circ, \star\}$
where $\circ$ stands for concatenation, $\star$ is kleene star, $\epsilon$ is empty string, $[$ and $]$ are brackets to be used for language to be generated.
Only those Regular Expressions to be considered which don't have nested brackets ... | formal languages regular languages finite automata regular expressions | 1 | How to generate regular expression for language of regular expressions? -- (formal languages regular languages finite automata regular expressions)
<p>Alphabets = $\{0, 1, \epsilon, \emptyset, [, ], \cup, \circ, \star\}$
where $\circ$ stands for concatenation, $\star$ is kleene star, $\epsilon$ is empty string, $[$... | habedi/stack-exchange-dataset |
77,956 | Solving a system of recurrences | <p>If the time complexity $T(n)$ of two functions $x(n)$ and $y(n)$ are mutually recursive, as in <a href="https://cs.stackexchange.com/questions/12742/time-complexity-of-mutually-recursive-functions">Time complexity of mutually recursive functions</a>, this gives $T(n)=O(2^n)$. But how do you measure an algorithm wit... | asymptotics recurrence relation | 1 | Solving a system of recurrences -- (asymptotics recurrence relation)
<p>If the time complexity $T(n)$ of two functions $x(n)$ and $y(n)$ are mutually recursive, as in <a href="https://cs.stackexchange.com/questions/12742/time-complexity-of-mutually-recursive-functions">Time complexity of mutually recursive functions</a... | habedi/stack-exchange-dataset |
77,958 | Example of Random Binary Tree? | <p>I'm trying to understand what a random binary tree is. According to <a href="https://en.wikipedia.org/wiki/Random_binary_tree" rel="nofollow noreferrer">Wikipedia</a>:</p>

<blockquote>
 <p>Two different distributions are commonly used: binary trees formed by
 inserting nodes one at a time accordin... | trees | 1 | Example of Random Binary Tree? -- (trees)
<p>I'm trying to understand what a random binary tree is. According to <a href="https://en.wikipedia.org/wiki/Random_binary_tree" rel="nofollow noreferrer">Wikipedia</a>:</p>

<blockquote>
 <p>Two different distributions are commonly used: binary trees formed by&#x... | habedi/stack-exchange-dataset |
77,962 | How to use a logistic regression classifier to estimate the confidence of a rule? | <p>The following is an excerpt from the Estimating LAT Confidence section of <a href="http://brenocon.com/watson_special_issue/02%20question%20analysis.pdf" rel="nofollow noreferrer">this</a> paper:</p>

<blockquote>
 <p>... Since some LAT detection rules are more reliable than others, we
 would like ... | machine learning natural language processing | 1 | How to use a logistic regression classifier to estimate the confidence of a rule? -- (machine learning natural language processing)
<p>The following is an excerpt from the Estimating LAT Confidence section of <a href="http://brenocon.com/watson_special_issue/02%20question%20analysis.pdf" rel="nofollow noreferrer">this<... | habedi/stack-exchange-dataset |
77,968 | Consensus anomaly about read-write registers and test&set | <p>I read this answer below and got into another question.</p>

<p><a href="https://cs.stackexchange.com/questions/33031/why-is-the-consensus-number-for-test-and-set-2">Why is the consensus number for test-and-set, 2?</a></p>

<p>I also read that read/write registers have consensus number 1.</p>
&#x... | distributed systems consensus | 1 | Consensus anomaly about read-write registers and test&set -- (distributed systems consensus)
<p>I read this answer below and got into another question.</p>

<p><a href="https://cs.stackexchange.com/questions/33031/why-is-the-consensus-number-for-test-and-set-2">Why is the consensus number for test-and-set, 2?</... | habedi/stack-exchange-dataset |
77,971 | Why is the halting problem semi-decidable? | <p>This is what is known about the halting problem and semi-decidability :-</p>

<p>The halting problem says that for a given input x and a machine H, we can't say whether the machine H halts or not on input x.</p>

<p>A language is said to be Semi-decidable if there exists a Turing machine which halts ... | computability turing machines halting problem semi decidability | 1 | Why is the halting problem semi-decidable? -- (computability turing machines halting problem semi decidability)
<p>This is what is known about the halting problem and semi-decidability :-</p>

<p>The halting problem says that for a given input x and a machine H, we can't say whether the machine H halts or not o... | habedi/stack-exchange-dataset |
77,985 | 3-SAT and Systems of Nonlinear Modular Equations | <p><strong>How is the 3-SAT problem reduced to solving for a system of nonlinear modular equations?</strong></p>

<p>I have read <a href="https://stackoverflow.com/questions/4294270/how-to-prove-that-a-problem-is-np-complete">https://stackoverflow.com/questions/4294270/how-to-prove-that-a-problem-is-np-complet... | complexity theory satisfiability modular arithmetic | 1 | 3-SAT and Systems of Nonlinear Modular Equations -- (complexity theory satisfiability modular arithmetic)
<p><strong>How is the 3-SAT problem reduced to solving for a system of nonlinear modular equations?</strong></p>

<p>I have read <a href="https://stackoverflow.com/questions/4294270/how-to-prove-that-a-pro... | habedi/stack-exchange-dataset |
77,989 | Is Python a context-free language? | <p>From <a href="https://en.wikipedia.org/wiki/Off-side_rule#Implementation" rel="noreferrer">Wikipedia: Off-side_rule#Implementation</a>, there is a statement:</p>

<blockquote>
 <p>...This requires that the lexer hold state, namely the current
 indentation level, and thus can detect changes in inden... | formal languages regular languages context free programming languages | 1 | Is Python a context-free language? -- (formal languages regular languages context free programming languages)
<p>From <a href="https://en.wikipedia.org/wiki/Off-side_rule#Implementation" rel="noreferrer">Wikipedia: Off-side_rule#Implementation</a>, there is a statement:</p>

<blockquote>
 <p>...This requir... | habedi/stack-exchange-dataset |
77,993 | Finite subsets of the Halting problem are decidable. Can I prove the correctness of Turing machines computing these subsets? | <p>I am trying to wrap my hand around the undecidability proof of the Halting problem, and to me it really seems to be more of a proof about representation than decidability. Namely, the proof that some languages are undecidable by Turing machines seems to simply state that I cannot find finite representations for arbi... | computability turing machines undecidability decision problem halting problem | 1 | Finite subsets of the Halting problem are decidable. Can I prove the correctness of Turing machines computing these subsets? -- (computability turing machines undecidability decision problem halting problem)
<p>I am trying to wrap my hand around the undecidability proof of the Halting problem, and to me it really seems... | habedi/stack-exchange-dataset |
77,995 | Build max heap in which all the nodes at certain level are less than all the nodes at the level before them | <p>Max-heap is called a "<strong>strong</strong>" max-heap if <strong>all the nodes at certain level are less than all the nodes at the level before them</strong>. What is the most efficient way to build such a heap from a given array? </p>

<p>I was thinking about something similar to the regular build heap al... | data structures heaps | 1 | Build max heap in which all the nodes at certain level are less than all the nodes at the level before them -- (data structures heaps)
<p>Max-heap is called a "<strong>strong</strong>" max-heap if <strong>all the nodes at certain level are less than all the nodes at the level before them</strong>. What is the most effi... | habedi/stack-exchange-dataset |
78,005 | The read tape in the definition of L and NL (logarithmic space) (DLOGSPACE, NLOGSPACE) (sublinear space) | <p>By the definition of <strong>L=DLOGSPACE</strong> or of <strong>NL=NLOGSPACE</strong> (or any sublinear space class) there is an extra tape (for the Turing machine): the input tape, which is only for reading - but for <em>arbitrary</em> reading. The machine can read the first 10 cells and then maybe go back to read... | complexity theory turing machines space complexity | 1 | The read tape in the definition of L and NL (logarithmic space) (DLOGSPACE, NLOGSPACE) (sublinear space) -- (complexity theory turing machines space complexity)
<p>By the definition of <strong>L=DLOGSPACE</strong> or of <strong>NL=NLOGSPACE</strong> (or any sublinear space class) there is an extra tape (for the Turing ... | habedi/stack-exchange-dataset |
78,006 | 2 means clustering | <p>I had an exam in algorithms. The question stated:</p>

<blockquote>
 <p>Given $n$ points in the plane, find an algorithm that finds two centers (which can be any centers in the plane) such that the sum of the squares of the distances from the points is minimized. Prove your algorithm and analyse its com... | algorithms clustering | 1 | 2 means clustering -- (algorithms clustering)
<p>I had an exam in algorithms. The question stated:</p>

<blockquote>
 <p>Given $n$ points in the plane, find an algorithm that finds two centers (which can be any centers in the plane) such that the sum of the squares of the distances from the points is minim... | habedi/stack-exchange-dataset |
78,014 | Algorithm to determine which vertices/edges would disconnect undirected graph if removed | <p>Is anyone aware of an algorithm to determine which vertices/edges would disconnect an undirected graph if removed? For all vertices/edges.</p>

<p>Of course I could run a BFS for each vertex and for each edge to test if the remaining graph would be connected. But is there anything more efficient?</p>
&#x... | algorithms graphs connected | 1 | Algorithm to determine which vertices/edges would disconnect undirected graph if removed -- (algorithms graphs connected)
<p>Is anyone aware of an algorithm to determine which vertices/edges would disconnect an undirected graph if removed? For all vertices/edges.</p>

<p>Of course I could run a BFS for each ver... | habedi/stack-exchange-dataset |
78,015 | Is this possible to solve 3SAT in O(n^24) time and O(1) space? | <p>Assume that <strong>n</strong> is the number variables of the given 3CNF formula (n≥3) and all clauses in the given 3CNF formula are different.</p>

<p>That means that for each clause, each literal can be either positive or negative and be one of the <strong>n</strong> variables, so the number of options ... | complexity theory satisfiability 3 sat sat solvers | 1 | Is this possible to solve 3SAT in O(n^24) time and O(1) space? -- (complexity theory satisfiability 3 sat sat solvers)
<p>Assume that <strong>n</strong> is the number variables of the given 3CNF formula (n≥3) and all clauses in the given 3CNF formula are different.</p>

<p>That means that for each clause, ea... | habedi/stack-exchange-dataset |
78,028 | How do we know INVERSIONS-COUNT algorithm implemented in balanced tree really works? | <p>How do we know INVERSIONS-COUNT algorithm (exercise 14.1-7 from <a href="http://sites.math.rutgers.edu/~ajl213/CLRS/Ch14.pdf" rel="nofollow noreferrer">here</a>), implemented in balanced tree really works?</p>

<p>We assume that the tree data structure we're using is an order statistic tree which means that ... | algorithms algorithm analysis correctness proof | 1 | How do we know INVERSIONS-COUNT algorithm implemented in balanced tree really works? -- (algorithms algorithm analysis correctness proof)
<p>How do we know INVERSIONS-COUNT algorithm (exercise 14.1-7 from <a href="http://sites.math.rutgers.edu/~ajl213/CLRS/Ch14.pdf" rel="nofollow noreferrer">here</a>), implemented in b... | habedi/stack-exchange-dataset |
78,030 | Prove that following graph problem is in $L$ | <p>I have some interesting problem: </p>

<blockquote>
 <p>Prove that following problem is in $L$ (decidable in logarythmic
 time). <em>Decide if given undirected graph $G=(\{1,\ldots,n\}, E)$ such
 that $\forall_{i,j\in \{1,\ldots,n\}} i\le j \to \operatorname{dist}(1, i) \le \operatorname{d... | complexity theory computability turing machines | 1 | Prove that following graph problem is in $L$ -- (complexity theory computability turing machines)
<p>I have some interesting problem: </p>

<blockquote>
 <p>Prove that following problem is in $L$ (decidable in logarythmic
 time). <em>Decide if given undirected graph $G=(\{1,\ldots,n\}, E)$ such&#x... | habedi/stack-exchange-dataset |
78,043 | "Type" of a function template? | <p>In C++ a simple function like </p>

<pre><code>int id_int(int x){return x;}
</code></pre>

<p>has type <code>id_int :: int->int</code>
a class template like</p>

<pre><code>template<class T>
class List<T>{...};
</code></pre>

<p>has kind <code>List :: *-... | type theory | 1 | "Type" of a function template? -- (type theory)
<p>In C++ a simple function like </p>

<pre><code>int id_int(int x){return x;}
</code></pre>

<p>has type <code>id_int :: int->int</code>
a class template like</p>

<pre><code>template<class T>
class List<T>{...};
</c... | habedi/stack-exchange-dataset |
78,048 | What exactly is going on in a proof by induction of a recurrence relation? | <p>In CLRS, it works through an example going through a recurrence relation proof using the "substitution method".</p>

<p>We have the recurrence $$T(n) = 2T(\lfloor n/2 \rfloor) + n \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ (4.19)$$</p>

<p>It claims:</p>

<... | proof techniques recurrence relation | 1 | What exactly is going on in a proof by induction of a recurrence relation? -- (proof techniques recurrence relation)
<p>In CLRS, it works through an example going through a recurrence relation proof using the "substitution method".</p>

<p>We have the recurrence $$T(n) = 2T(\lfloor n/2 \rfloor) + n \ \ \ \ \ ... | habedi/stack-exchange-dataset |
78,049 | Algorithm to generate self-avoiding random walk on a lattice | <p>Where can I find some code to generate random self-avoiding walks on 2 and 3-dimensional lattices whose side-lengths are powers of two? The walk should pass through every point on the lattice More specifically, how can I find a random hamiltonian path on a large $2^n \times 2^n$ or $2^n \times 2^n \times 2^n$ grid g... | random walks lattices | 1 | Algorithm to generate self-avoiding random walk on a lattice -- (random walks lattices)
<p>Where can I find some code to generate random self-avoiding walks on 2 and 3-dimensional lattices whose side-lengths are powers of two? The walk should pass through every point on the lattice More specifically, how can I find a r... | habedi/stack-exchange-dataset |
78,052 | What is the set of all minimal 3CNF formulas? | <p><strong>Definition:</strong> A <strong>minimal</strong> 3CNF formula is an <strong>un</strong>satisfiable 3CNF formula with <strong>minimum</strong> clauses connected by conjunctions, where each clause is disjunction of 3 literals, that is if <strong>any</strong> of it's clauses is removed from the formula, then the... | logic first order logic propositional logic | 1 | What is the set of all minimal 3CNF formulas? -- (logic first order logic propositional logic)
<p><strong>Definition:</strong> A <strong>minimal</strong> 3CNF formula is an <strong>un</strong>satisfiable 3CNF formula with <strong>minimum</strong> clauses connected by conjunctions, where each clause is disjunction of 3 ... | habedi/stack-exchange-dataset |
78,061 | What are some comparative studies on program termination verification tools? | <p>Comparative studies of tools like AProver, 2LS </p>
 | software verification | 1 | What are some comparative studies on program termination verification tools? -- (software verification)
<p>Comparative studies of tools like AProver, 2LS </p>
 | habedi/stack-exchange-dataset |
78,062 | Is this possible to solve 4SAT in polynomial time? | <p>I know and admit that this is <strong>long</strong>, but please read it slow and understand everything.</p>

<p>I think that this is one of the most interesting questions asked in computer science ever.</p>

<p>I do<strong>n't</strong> expect for quick answers. Take your time to read slowly and to un... | satisfiability propositional logic sat solvers 2 sat | 1 | Is this possible to solve 4SAT in polynomial time? -- (satisfiability propositional logic sat solvers 2 sat)
<p>I know and admit that this is <strong>long</strong>, but please read it slow and understand everything.</p>

<p>I think that this is one of the most interesting questions asked in computer science eve... | habedi/stack-exchange-dataset |
78,080 | Who was the first to show that there is a Universal Turing-Machine that uses a binary alphabet? | <p>The title says it all, I think.</p>
<p>We know there are universal Turing-machines that only use a binary alphabet. But who proved this first?</p>
<p>Turing himself showed the existence of a universal Turing machine ... but did he also show that such a machine can exist using only a binary alphabet? Or was ... | turing machines computation models turing completeness history | 1 | Who was the first to show that there is a Universal Turing-Machine that uses a binary alphabet? -- (turing machines computation models turing completeness history)
<p>The title says it all, I think.</p>
<p>We know there are universal Turing-machines that only use a binary alphabet. But who proved this first?</p>&#... | habedi/stack-exchange-dataset |
78,083 | Why is the log in the big-O of binary search not base 2? | <p>I am new to understanding computer science algorithms. I understand the process of the binary search, but I am having a slight misunderstanding with its efficiency.</p>

<p>In a size of $s = 2^n$ elements, it would take, on average, $n$ steps to find a particular element. Taking the base 2 logarithm of both ... | algorithms runtime analysis binary search | 1 | Why is the log in the big-O of binary search not base 2? -- (algorithms runtime analysis binary search)
<p>I am new to understanding computer science algorithms. I understand the process of the binary search, but I am having a slight misunderstanding with its efficiency.</p>

<p>In a size of $s = 2^n$ elements,... | habedi/stack-exchange-dataset |
78,085 | Can deterministic Turing machine beats/wins (if possible) the "Bombs and Levers" game in polynomial time? | <p>The description of this game is already exists in this <a href="https://cs.stackexchange.com/questions/78024/is-my-greedy-algorithm-correct">link</a></p>

<p>I am quoting from this link the description of the game to ease the reading of this question:</p>

<hr>

<p>In a game, where there are ... | algorithms complexity theory turing machines search problem | 1 | Can deterministic Turing machine beats/wins (if possible) the "Bombs and Levers" game in polynomial time? -- (algorithms complexity theory turing machines search problem)
<p>The description of this game is already exists in this <a href="https://cs.stackexchange.com/questions/78024/is-my-greedy-algorithm-correct">link<... | habedi/stack-exchange-dataset |
78,087 | Linear Temporal Logic with non-Boolean propositions (e.g. Integers)? | <p>LTL works with <em>Boolean</em> propositions.
People probably studied extensions to non-Boolean propositions...
<em>Do you know a good starting reference?</em></p>

<p>(I am aware of STL, but it also seems to talk about clocks, is there a variant without clocks?)</p>

<p><strong>Update</stron... | reference request logic linear temporal logic | 1 | Linear Temporal Logic with non-Boolean propositions (e.g. Integers)? -- (reference request logic linear temporal logic)
<p>LTL works with <em>Boolean</em> propositions.
People probably studied extensions to non-Boolean propositions...
<em>Do you know a good starting reference?</em></p>

<p>(I am aware o... | habedi/stack-exchange-dataset |
78,090 | Number of Pairs in Array | <p>so hey, I've been recently reading about the Two-Pointer algorithm that allows us to find pairs $(i,j)$ such that $a[i] + a[j] = x$ in $O(m+n)$ instead of the trivial $O(mn)$ time.</p>

<p>I was wondering how can I find the <em>number of pairs</em> $(i,j)$ in time less than $O(mn)$. I was trying to use Two-... | optimization time complexity asymptotics arrays | 1 | Number of Pairs in Array -- (optimization time complexity asymptotics arrays)
<p>so hey, I've been recently reading about the Two-Pointer algorithm that allows us to find pairs $(i,j)$ such that $a[i] + a[j] = x$ in $O(m+n)$ instead of the trivial $O(mn)$ time.</p>

<p>I was wondering how can I find the <em>num... | habedi/stack-exchange-dataset |
78,092 | if $L\in BPP$ then $NP\subseteq BPP$ | <blockquote>
 <p>Let $L$ to be the following problem:
 $$L = \{ \langle M,x,1^t \rangle \mid \text{$M$ accepts $x$ after $t$ steps with probability at least $3/4$} \}.$$
 Show that if $L\in BPP$ then $NP\subseteq BPP$.</p>
</blockquote>

<p>I already showed that $L$ is $BPP$-hard. I think a r... | complexity theory | 1 | if $L\in BPP$ then $NP\subseteq BPP$ -- (complexity theory)
<blockquote>
 <p>Let $L$ to be the following problem:
 $$L = \{ \langle M,x,1^t \rangle \mid \text{$M$ accepts $x$ after $t$ steps with probability at least $3/4$} \}.$$
 Show that if $L\in BPP$ then $NP\subseteq BPP$.</p>
</blockquote>
... | habedi/stack-exchange-dataset |
78,099 | Nested Loop Time Complexity vs Successive Loops | <p>An algorithm has a calculation whose worst case time complexity $T(x)=O(x^2)$ that outputs solutions $y$ & $z$ for input $x$ (the algorithm's worst case time complexity is greater than quadratic time):</p>

<pre><code>for (i = 1; i <= x; i++)
 {
 for (j = 1; j <= i; j++)
 {... | algorithm analysis runtime analysis loops | 1 | Nested Loop Time Complexity vs Successive Loops -- (algorithm analysis runtime analysis loops)
<p>An algorithm has a calculation whose worst case time complexity $T(x)=O(x^2)$ that outputs solutions $y$ & $z$ for input $x$ (the algorithm's worst case time complexity is greater than quadratic time):</p>

<pr... | habedi/stack-exchange-dataset |
78,101 | what are Structural recursion, primitive recursion, recursion combinator and recursion principles? | <p>Recently, I encountered terminologies such as primitive recursion and recursion combinator. One of the sources is here <a href="https://www4.in.tum.de/~berghofe/papers/IJCAR2006.pdf" rel="nofollow noreferrer">link</a> </p>

<p>I googled and read some, but missing the points of them. I know that recursion occ... | recursion primitive recursion variable binding | 1 | what are Structural recursion, primitive recursion, recursion combinator and recursion principles? -- (recursion primitive recursion variable binding)
<p>Recently, I encountered terminologies such as primitive recursion and recursion combinator. One of the sources is here <a href="https://www4.in.tum.de/~berghofe/paper... | habedi/stack-exchange-dataset |
78,108 | Showing a problem is $P$-complete | <p>Consider the well-known language: $$L = \{\langle M,x,1^t \rangle \ \ |\ \text{$M$ accepts $x$ after $t$ steps}\}$$</p>

<p>I've encountered some technical problem while trying to show a logarithmic reduction from some $L'\in P$ (which will show completeness of $L$)</p>

<p>Basically, the reduction i... | complexity theory reductions | 1 | Showing a problem is $P$-complete -- (complexity theory reductions)
<p>Consider the well-known language: $$L = \{\langle M,x,1^t \rangle \ \ |\ \text{$M$ accepts $x$ after $t$ steps}\}$$</p>

<p>I've encountered some technical problem while trying to show a logarithmic reduction from some $L'\in P$ (which will ... | habedi/stack-exchange-dataset |
78,123 | Trying to Classify MNIST where pixels are shuffled with a seed.Why is it not working? | <p>I transformed the MNIST dataset as follows:(<strong>X (70000 x 784)</strong> is the <strong>training</strong> matrix)</p>

<pre><code>np.random.seed(42)
def transform_X():
 for i in range(len(X[:,1])):
 np.random.shuffle(X[i,:])
</code></pre>

<p>I had thought that <strong>s... | machine learning neural networks statistics | 1 | Trying to Classify MNIST where pixels are shuffled with a seed.Why is it not working? -- (machine learning neural networks statistics)
<p>I transformed the MNIST dataset as follows:(<strong>X (70000 x 784)</strong> is the <strong>training</strong> matrix)</p>

<pre><code>np.random.seed(42)
def transform_X()... | habedi/stack-exchange-dataset |
78,124 | Right moving turing machines and FSA's | <p>I stumbled upon the following post while learning about turing machines:</p>

<p><a href="https://cs.stackexchange.com/questions/18639/right-moving-turing-machine">Right moving turing machine</a></p>

<p>I kind of understand the intuition behind why a TM that only moves to the right works like a <a h... | turing machines finite automata | 1 | Right moving turing machines and FSA's -- (turing machines finite automata)
<p>I stumbled upon the following post while learning about turing machines:</p>

<p><a href="https://cs.stackexchange.com/questions/18639/right-moving-turing-machine">Right moving turing machine</a></p>

<p>I kind of understand ... | habedi/stack-exchange-dataset |
78,126 | Complexity to generate every combination of every size for a given sequence | <p>I would like to estimate complexity in space and time of generating every combination of every size for a given sequence.</p>

<p>Exemple :</p>

<pre><code> seq = [1,2,3]
 combinations = [{1}, {2}, {3}, {1,2}, {1,3}, {2,3}, {1,2,3}]
</code></pre>

<p>From what i know, for a given sequ... | complexity theory time complexity | 1 | Complexity to generate every combination of every size for a given sequence -- (complexity theory time complexity)
<p>I would like to estimate complexity in space and time of generating every combination of every size for a given sequence.</p>

<p>Exemple :</p>

<pre><code> seq = [1,2,3]
 combinatio... | habedi/stack-exchange-dataset |
78,133 | Print the number of subarrays of an array having negative sums | <p><strong>Problem statement</strong>: Given an array of N integers, find its number of negative subarrays (i.e sub arrays having negative summation). E.g: for an array $[1,-2, 4, -5, 1]$ there are 9 subarrays whose sum is negative. Subarray means sequential array within an array.</p>

<p><strong>My code</stron... | algorithms searching | 1 | Print the number of subarrays of an array having negative sums -- (algorithms searching)
<p><strong>Problem statement</strong>: Given an array of N integers, find its number of negative subarrays (i.e sub arrays having negative summation). E.g: for an array $[1,-2, 4, -5, 1]$ there are 9 subarrays whose sum is negative... | habedi/stack-exchange-dataset |
78,136 | Is the term page replacement actually a misnomer? | <p>My understanding is that "page replacement" entails replacing the contents of a frame to bring in a new frame in it's place corresponding to a new page. Since it is not the page, but the frame that changes, shouldn't this process be called "frame replacement"? </p>
 | terminology operating systems virtual memory paging | 1 | Is the term page replacement actually a misnomer? -- (terminology operating systems virtual memory paging)
<p>My understanding is that "page replacement" entails replacing the contents of a frame to bring in a new frame in it's place corresponding to a new page. Since it is not the page, but the frame that changes, sho... | habedi/stack-exchange-dataset |
78,139 | Question about space complexity | <p>I'm trying to represent a directed acyclic graph using a structure similar to an adjacency list. The difference is, for a given vertex v, I need to know precisely which nodes are inwardly adjacent to v, and which nodes are outwardly adjacent to v. To get around this, my idea was to use a list of pairs, where each pa... | algorithms graphs algorithm analysis space complexity | 1 | Question about space complexity -- (algorithms graphs algorithm analysis space complexity)
<p>I'm trying to represent a directed acyclic graph using a structure similar to an adjacency list. The difference is, for a given vertex v, I need to know precisely which nodes are inwardly adjacent to v, and which nodes are out... | habedi/stack-exchange-dataset |
78,147 | Find non-overlapping subsets that maximize the sum of their values | <blockquote>
 <p>Given a set of elements $N$, a set $S$ of subsets of $N$, and a function $v:S \to \mathbb R$, determine a set $R\subseteq S$ of <em>non-overlapping</em> subsets that maximizes the total value.</p>
</blockquote>

<p>Has this problem already been studied somewhere, or is it linked to som... | optimization sets | 1 | Find non-overlapping subsets that maximize the sum of their values -- (optimization sets)
<blockquote>
 <p>Given a set of elements $N$, a set $S$ of subsets of $N$, and a function $v:S \to \mathbb R$, determine a set $R\subseteq S$ of <em>non-overlapping</em> subsets that maximizes the total value.</p>
</block... | habedi/stack-exchange-dataset |
78,155 | Can all optimizations be expressed in source code? | <p>If someone compiled a program with all optimization settings enabled, would it be possible to create source code that, if it was compiled with all optimizations disabled, produced an identical binary? We'll assume that inline assembly and similar features are not used. If this is not always possible, (and I suspect ... | optimization programming languages compilers language design | 1 | Can all optimizations be expressed in source code? -- (optimization programming languages compilers language design)
<p>If someone compiled a program with all optimization settings enabled, would it be possible to create source code that, if it was compiled with all optimizations disabled, produced an identical binary?... | habedi/stack-exchange-dataset |
78,163 | Ant colony optimization algorithm | <p>if i have an equation like
 $$f_n = x + y + z + a + b$$ 
and each variable has a discrete answer like $a = 0, 1 , 3$ . $b = 2 ,4,5$ etc.
i want to find the global optimum minimization point. I used Ant colony optimization (ACO) to solve the equation but i am stuck in the heuristic information ... | algorithms graphs optimization | 1 | Ant colony optimization algorithm -- (algorithms graphs optimization)
<p>if i have an equation like
 $$f_n = x + y + z + a + b$$ 
and each variable has a discrete answer like $a = 0, 1 , 3$ . $b = 2 ,4,5$ etc.
i want to find the global optimum minimization point. I used Ant colony optimization (A... | habedi/stack-exchange-dataset |
78,166 | Semi decidability proof | <p>I'm studying for my theory of computation exam and came accross the following question:</p>

<p><em>Construct an appropriate Turing machine for the following language and prove or disprove it's semi-decidability:</em></p>

<p>$A := \{w \in \{0, 1\}^*\ |\ \exists x \in \{0, 1\}^* .f_w(x) = |x| \}$</... | turing machines semi decidability | 1 | Semi decidability proof -- (turing machines semi decidability)
<p>I'm studying for my theory of computation exam and came accross the following question:</p>

<p><em>Construct an appropriate Turing machine for the following language and prove or disprove it's semi-decidability:</em></p>

<p>$A := \{w \i... | habedi/stack-exchange-dataset |
78,174 | Probability that all indices divisible by 100 in a hash table with linear probing are occupied | <p>I am trying to solve this question on Sedgewick's and Wayne's Algorithms book:</p>

<blockquote>
 <p>Suppose that a linear-probing table of size 10^6 is half full, with occupied positions chosen at random. Estimate the probability that all positions with indices divisible by 100 are occupied.</p>
</... | probability theory hash tables | 1 | Probability that all indices divisible by 100 in a hash table with linear probing are occupied -- (probability theory hash tables)
<p>I am trying to solve this question on Sedgewick's and Wayne's Algorithms book:</p>

<blockquote>
 <p>Suppose that a linear-probing table of size 10^6 is half full, with occu... | habedi/stack-exchange-dataset |
79,182 | I'm looking for an algorithm to find unknown patterns in a string | <p>I am trying to detect patterns in huge code bases.
I managed to filter the entire codebase into a tagged string,
as in:
ABACBABAABBCBABA</p>

<p>The result should be:
ABA *3
CBA *2</p>

<p>I'm trying to build / use an algorithm which will find ANY unknown repeating pattern inside ... | algorithms search algorithms strings substrings | 1 | I'm looking for an algorithm to find unknown patterns in a string -- (algorithms search algorithms strings substrings)
<p>I am trying to detect patterns in huge code bases.
I managed to filter the entire codebase into a tagged string,
as in:
ABACBABAABBCBABA</p>

<p>The result should be:
ABA *3&... | habedi/stack-exchange-dataset |
79,189 | How can a set of N players be split into M teams, given certain rules? | <p>A lot of times, I’ve needed to split a given set of people into a given number of teams but with some complications, like:</p>

<ul>
<li>Alice and Bob CANNOT be on the same team.</li>
<li>Carol and David just HAVE TO BE on the same team.</li>
</ul>

<p>I feel like this is already a thing.... | sets | 1 | How can a set of N players be split into M teams, given certain rules? -- (sets)
<p>A lot of times, I’ve needed to split a given set of people into a given number of teams but with some complications, like:</p>

<ul>
<li>Alice and Bob CANNOT be on the same team.</li>
<li>Carol and David just HAVE TO BE ... | habedi/stack-exchange-dataset |
79,192 | What problems are believed to have an efficient algorithm? | <p>Just out of curiosity, 
What problems are believed to have an efficient algorithm, yet haven't been found such an algorithm for them?</p>

<p>This question came up to my mind after reading about PRIMES problem.</p>

<p>I hope this question is appropriate for this forum</p>

<p>Thanks!</p>... | algorithms efficiency research | 1 | What problems are believed to have an efficient algorithm? -- (algorithms efficiency research)
<p>Just out of curiosity, 
What problems are believed to have an efficient algorithm, yet haven't been found such an algorithm for them?</p>

<p>This question came up to my mind after reading about PRIMES problem.... | habedi/stack-exchange-dataset |
79,195 | Find the appropriate product | <p>I have a number $n$ and an integer $x$ which ends on $1, 3, 7 \ or\ 9$, meaning that the last digit (rightmost digit) of $x$ is one of those 4 numbers.</p>

<p>Now if $z = x * y$, what number do I have to choose for $y$ such that the $n$ last (rightmost) digits of $z$ are equal to $1$ (I mean the numerical ... | algorithms number theory | 1 | Find the appropriate product -- (algorithms number theory)
<p>I have a number $n$ and an integer $x$ which ends on $1, 3, 7 \ or\ 9$, meaning that the last digit (rightmost digit) of $x$ is one of those 4 numbers.</p>

<p>Now if $z = x * y$, what number do I have to choose for $y$ such that the $n$ last (right... | habedi/stack-exchange-dataset |
79,199 | Consensus number of memory-to-memory swap | <p>I think that consensus number of mem-to-mem-swap(a,b) operation which atomically swaps the values between shared locations a and b (shared R/W memory) is <strong>infinite</strong> , but I'm having trouble proving it.<br>
I thought about implementing <strong>CAS</strong> with mem-to-mem-swap but comparing atomica... | concurrency consensus | 1 | Consensus number of memory-to-memory swap -- (concurrency consensus)
<p>I think that consensus number of mem-to-mem-swap(a,b) operation which atomically swaps the values between shared locations a and b (shared R/W memory) is <strong>infinite</strong> , but I'm having trouble proving it.<br>
I thought about impleme... | habedi/stack-exchange-dataset |
79,204 | "Smallest set" term in the trees set definition | <p>I often meet such kind of the definition of the set of <em>trees</em>, as:</p>

<p><em>The set of unranked $\Sigma$-trees, denoted by $T$, is the smallest set of strings over $\Sigma$ and the parenthesis symbols ‘)’ and ‘(’ such that for each $a\in\Sigma$ and $w\in T^*$, $a(w)$ is in $T$.</em> (<a href="http... | trees notation inductive datatypes | 1 | "Smallest set" term in the trees set definition -- (trees notation inductive datatypes)
<p>I often meet such kind of the definition of the set of <em>trees</em>, as:</p>

<p><em>The set of unranked $\Sigma$-trees, denoted by $T$, is the smallest set of strings over $\Sigma$ and the parenthesis symbols ‘)’ and ‘... | habedi/stack-exchange-dataset |
79,207 | Algorithm to create tournament brackets | <p>I'm designing a web app to host e-sports tournaments and want to create an algorithm that generates tournament brackets.</p>

<p>Given a list of participants' user ID's (minimum 4, maximum let's say 64), I want to generate a bracket in the form of a list of pairings, where each element of the pair represents... | algorithms binary trees randomness | 1 | Algorithm to create tournament brackets -- (algorithms binary trees randomness)
<p>I'm designing a web app to host e-sports tournaments and want to create an algorithm that generates tournament brackets.</p>

<p>Given a list of participants' user ID's (minimum 4, maximum let's say 64), I want to generate a brac... | habedi/stack-exchange-dataset |
79,211 | What is the complexity of determining whether or not conjunction of positive CNF and negative CNF is satisfiable? | <p>Definitions:</p>

<p>positive CNF is a conjunctive normal form formula, where all literals are positive, i.e. the unary connective ¬ does not exist in the formula.</p>

<p>negative CNF is a conjunctive normal form formula, where all literals are negative, i.e. the unary connective ¬ appears n... | complexity theory logic satisfiability propositional logic | 1 | What is the complexity of determining whether or not conjunction of positive CNF and negative CNF is satisfiable? -- (complexity theory logic satisfiability propositional logic)
<p>Definitions:</p>

<p>positive CNF is a conjunctive normal form formula, where all literals are positive, i.e. the unary connective ... | habedi/stack-exchange-dataset |
79,219 | What is the complexity of the problem of computing the cardinality of the union of many (finite) and small sets? | <p>What is the complexity of the problem of computing the cardinality of the union of many (finite) and small sets?</p>

<p>What is both the time and space complexity of the naive algorithm that does this computation?</p>

<p>An inefficient recursive algorithm to do this task is:</p>

<p><a href... | algorithms complexity theory algorithm analysis time complexity space complexity | 1 | What is the complexity of the problem of computing the cardinality of the union of many (finite) and small sets? -- (algorithms complexity theory algorithm analysis time complexity space complexity)
<p>What is the complexity of the problem of computing the cardinality of the union of many (finite) and small sets?</p>&#... | habedi/stack-exchange-dataset |
79,228 | Binarization of Constraints | <p>I am trying to solve a Constraint Satisfaction Problem that involves lots of n-ary constraints. But the solver I have implemented only works with algorithms for binary constraints.</p>

<p>I've been reading into the topic of the biniraztion of constraints (<a href="http://ktiml.mff.cuni.cz/~bartak/constraint... | algorithms satisfiability constraint satisfaction constraint programming backtracking | 1 | Binarization of Constraints -- (algorithms satisfiability constraint satisfaction constraint programming backtracking)
<p>I am trying to solve a Constraint Satisfaction Problem that involves lots of n-ary constraints. But the solver I have implemented only works with algorithms for binary constraints.</p>

<p>I... | habedi/stack-exchange-dataset |
79,234 | Type Inference and Generalization | <p>I've been trying to understand type inference for Hindley-Milner-based languages, and I'm struggling to understand how generalization works. Let's say I have the following program in Haskell:</p>

<pre><code>x :: Int
x = id 1

y :: Char
y = id 'a'

id :: a -> a
id x = x
</c... | programming languages functional programming type inference | 1 | Type Inference and Generalization -- (programming languages functional programming type inference)
<p>I've been trying to understand type inference for Hindley-Milner-based languages, and I'm struggling to understand how generalization works. Let's say I have the following program in Haskell:</p>

<pre><code>x ... | habedi/stack-exchange-dataset |
79,241 | What is Temperature in LSTM (and neural networks generally)? | <p>One of the hyperparameters for LSTM networks is temperature. What is it?</p>
 | machine learning neural networks | 1 | What is Temperature in LSTM (and neural networks generally)? -- (machine learning neural networks)
<p>One of the hyperparameters for LSTM networks is temperature. What is it?</p>
 | habedi/stack-exchange-dataset |
79,243 | Is computing the cardinality of sum of regular expressions without kleene star closure EXPTIME problem? | <p>Is computing the cardinality of sum of regular expressions without kleene star closure is EXPTIME problem?</p>

<p>Note that sum of regular expressions is union of regular expressions. The alphabet of each regular expression is Σ={0,1}, and each regular expression in the sum is concatenation of 0, 1 an... | complexity theory formal languages regular languages regular expressions | 1 | Is computing the cardinality of sum of regular expressions without kleene star closure EXPTIME problem? -- (complexity theory formal languages regular languages regular expressions)
<p>Is computing the cardinality of sum of regular expressions without kleene star closure is EXPTIME problem?</p>

<p>Note that su... | habedi/stack-exchange-dataset |
79,244 | How is the time complexity of an algorithm with successive-nested loops measured? | <p>Does the time complexity of the following pseudo-algorithm simplify as $O(n^2 log(n)) = O(n^2)$?</p>

<p>SOME ALGORITHM </p>

<pre><code>GET n
FOR (i=1; i<=n; i++) 
 {
 calculationOfN[i] // some polylogarithmic time calculation 

 FOR (j=1; j<=n; j++)
 ... | algorithm analysis runtime analysis | 1 | How is the time complexity of an algorithm with successive-nested loops measured? -- (algorithm analysis runtime analysis)
<p>Does the time complexity of the following pseudo-algorithm simplify as $O(n^2 log(n)) = O(n^2)$?</p>

<p>SOME ALGORITHM </p>

<pre><code>GET n
FOR (i=1; i<=n; i++) 
 ... | habedi/stack-exchange-dataset |
79,253 | How do solve assignment of one interval to another? | <p>Is there an efficient algorithm for the following problem?</p>

<p><strong>Input:</strong> Set of holes and pegs. Each hole/peg is an interval $[\ell,u]$ with integer endpoints.</p>

<p><strong>Question:</strong> Can all the holes be filled using the pegs given, satisfying the following conditions... | algorithms decision problem assignment problem | 1 | How do solve assignment of one interval to another? -- (algorithms decision problem assignment problem)
<p>Is there an efficient algorithm for the following problem?</p>

<p><strong>Input:</strong> Set of holes and pegs. Each hole/peg is an interval $[\ell,u]$ with integer endpoints.</p>

<p><strong>Q... | habedi/stack-exchange-dataset |
79,263 | Count arrays with size n, sum k and largest element m | <p>I'm trying to solve pretty complex problem with combinatorics.</p>

<p>Namely, we have given three numbers N, K, M. Now we want to count how many different arrays of integers are there with length N, sum K and all the elements in the range [1, M]</p>

<p>Constraints:</p>

<ul>
<li>1 <=... | algorithms counting | 1 | Count arrays with size n, sum k and largest element m -- (algorithms counting)
<p>I'm trying to solve pretty complex problem with combinatorics.</p>

<p>Namely, we have given three numbers N, K, M. Now we want to count how many different arrays of integers are there with length N, sum K and all the elements in ... | habedi/stack-exchange-dataset |
79,264 | Basic mapping reductions without using Turing machines | <p>I have problems with the basics of mapping reductions.</p>

<p>I can understand how to do reductions using a Turing machine, but without it, I get a little bit confused.</p>

<p>For example:</p>

<ol>
<li>How do I do a mapping reduction from $a$ to $b$, where $a$ is $\{0,1\}$ and $b$ is $... | reductions computation models | 1 | Basic mapping reductions without using Turing machines -- (reductions computation models)
<p>I have problems with the basics of mapping reductions.</p>

<p>I can understand how to do reductions using a Turing machine, but without it, I get a little bit confused.</p>

<p>For example:</p>

<ol>&#x... | habedi/stack-exchange-dataset |
79,265 | What is the Name of This Problem? | <blockquote>
 <p>Given two integers $a$ and $b$, determine if $a$ and $b$ are equivalent modulo any $k \, (k: 1 \lt k \lt |a - b|)$. </p>
</blockquote>

<p>If $\exists$ an integer $ (k: 1 \lt k \lt |a - b|) \text{ and }a \equiv b \mod k$, then the algorithm would return <strong>true</strong>, o... | reference request number theory | 1 | What is the Name of This Problem? -- (reference request number theory)
<blockquote>
 <p>Given two integers $a$ and $b$, determine if $a$ and $b$ are equivalent modulo any $k \, (k: 1 \lt k \lt |a - b|)$. </p>
</blockquote>

<p>If $\exists$ an integer $ (k: 1 \lt k \lt |a - b|) \text{ and }a \eq... | habedi/stack-exchange-dataset |
79,284 | Finite State Automata Within A Compiler | <p>I've read up on Finite State Automata in a lot of different books on compiler construction (two of which are actually called Compiler Construction) and I'm kind of at a loss. I understand the idea of moving from state to state and having a state that is accepted. What I don't understand is why in the world this theo... | finite automata compilers | 1 | Finite State Automata Within A Compiler -- (finite automata compilers)
<p>I've read up on Finite State Automata in a lot of different books on compiler construction (two of which are actually called Compiler Construction) and I'm kind of at a loss. I understand the idea of moving from state to state and having a state ... | habedi/stack-exchange-dataset |
79,290 | Compute lebesgue measure of set of intervals | <p>Let $S = \{ [x_1, y_1], [x_2, y_2], \dots, [x_n, y_n] \}$ be a set of not necessarily disjoint intervals on $\mathbb{R}$. Is there an efficient way to compute the lebesgue measure of the union
$\displaystyle \bigcup_{i = 1}^n [x_i, y_i]$ ?</p>

<p>I present my ideas and approaches as following.</p>
&... | algorithms numerical algorithms intervals | 1 | Compute lebesgue measure of set of intervals -- (algorithms numerical algorithms intervals)
<p>Let $S = \{ [x_1, y_1], [x_2, y_2], \dots, [x_n, y_n] \}$ be a set of not necessarily disjoint intervals on $\mathbb{R}$. Is there an efficient way to compute the lebesgue measure of the union
$\displaystyle \bigcup_{i = ... | habedi/stack-exchange-dataset |
79,294 | Number of cliques in a graph | <p>I think the number of cliques in a graph is generally exponential in the of vertices of that graph. Does anyone know any reference for that?</p>
 | graphs reference request clique | 1 | Number of cliques in a graph -- (graphs reference request clique)
<p>I think the number of cliques in a graph is generally exponential in the of vertices of that graph. Does anyone know any reference for that?</p>
 | habedi/stack-exchange-dataset |
79,299 | Sorting the number sequence | <p>I have </p>

<ul>
<li><p>$4$ variables $n_1, n_2, n_3, n_4 \in \mathbb N$ that sum to $N$.</p></li>
<li><p>$4$ positive real constants $c_1 < c_2 < c_3 < c_4$. </p></li>
</ul>

<p>Given a particular tuple $(k_1,k_2,k_3,k_4)$, how do I find the partial sum of the ordered (w.r.t. t... | optimization sorting linear programming | 1 | Sorting the number sequence -- (optimization sorting linear programming)
<p>I have </p>

<ul>
<li><p>$4$ variables $n_1, n_2, n_3, n_4 \in \mathbb N$ that sum to $N$.</p></li>
<li><p>$4$ positive real constants $c_1 < c_2 < c_3 < c_4$. </p></li>
</ul>

<p>Given a particular tuple $(... | habedi/stack-exchange-dataset |
79,302 | Programming question for a new approach | <p>There is a matrix of size (M x N) in which the cells are marked by one of the three letters (either 'a','b' or 'c'). Now given that there is only one cell that is marked with value 'a' but more than one cells can be marked with value 'b' or 'c'.</p>

<p>There is 8 ways in which one can move form one cell to ... | algorithms dynamic programming | 1 | Programming question for a new approach -- (algorithms dynamic programming)
<p>There is a matrix of size (M x N) in which the cells are marked by one of the three letters (either 'a','b' or 'c'). Now given that there is only one cell that is marked with value 'a' but more than one cells can be marked with value 'b' or ... | habedi/stack-exchange-dataset |
79,305 | Is it possible to solve the halting-after-$n$ steps problem more efficient than just execute $n$ steps? | <p>The halting-after-$n$ steps problem may be defined as the question if a given turing machine halts after a maximum of $n\in\mathbb{N}$ steps. Is it theoretically possible to solve this problem in general in less than $n$ execution steps (just execution the program) or can't this be done? If not, why not?</p>
&#x... | turing machines halting problem | 1 | Is it possible to solve the halting-after-$n$ steps problem more efficient than just execute $n$ steps? -- (turing machines halting problem)
<p>The halting-after-$n$ steps problem may be defined as the question if a given turing machine halts after a maximum of $n\in\mathbb{N}$ steps. Is it theoretically possible to so... | habedi/stack-exchange-dataset |
79,311 | The height of 5-balnced tree is O(logn) | <p>Binary tree with external leaves is a 5-balanced tree if the path from the root to the farthest external leaf is no more than 5 times as long as the path from the root to the nearest external leaf, and if his right and left subtrees are 5-balanced too. Show that the height of such a tree is O(logn).</p>

<p>... | data structures binary trees | 1 | The height of 5-balnced tree is O(logn) -- (data structures binary trees)
<p>Binary tree with external leaves is a 5-balanced tree if the path from the root to the farthest external leaf is no more than 5 times as long as the path from the root to the nearest external leaf, and if his right and left subtrees are 5-bala... | habedi/stack-exchange-dataset |
79,315 | What's wrong with this | <p>Here's the question: Do more baby names start with "A" or "B"? Write code to count and print those two counts ("A" count, then "B" count).</p>

<p>I then write this code down:</p>

<p>table = new SimpleTable("baby-2010.csv");</p>

<p>count1 = 0;</p>

<p>count2 = 0;</p>

<p>for... | counting | 1 | What's wrong with this -- (counting)
<p>Here's the question: Do more baby names start with "A" or "B"? Write code to count and print those two counts ("A" count, then "B" count).</p>

<p>I then write this code down:</p>

<p>table = new SimpleTable("baby-2010.csv");</p>

<p>count1 = 0;</p>
&#... | habedi/stack-exchange-dataset |
79,333 | Accurate way to compute the sum of exponentials | <p>In my work, I had to essentially compute the following quantity.</p>

<p>Given a sequence of positive floating point numbers $\{a_i\}_{i=1}^n$, such that</p>

<p>$$6000 \leq a_i \leq 7000$$</p>

<p>I needed to compute the following quantity (for some $n>1$, but for now can assume $n=1000$)... | algorithms numerical algorithms | 1 | Accurate way to compute the sum of exponentials -- (algorithms numerical algorithms)
<p>In my work, I had to essentially compute the following quantity.</p>

<p>Given a sequence of positive floating point numbers $\{a_i\}_{i=1}^n$, such that</p>

<p>$$6000 \leq a_i \leq 7000$$</p>

<p>I needed t... | habedi/stack-exchange-dataset |
79,336 | Can lambda-calculus be used for knowledge representation? | <p>Natural language semantics (in computational linguistics) uses lambda terms for expressing the semantics of natural language sentences. There is vast literature about combinatorial categorial grammars and lambda semantics of natural language, e.g. tutorial about framework <a href="http://yoavartzi.com/tutorial/" rel... | lambda calculus knowledge representation curry howard computational linguistics | 1 | Can lambda-calculus be used for knowledge representation? -- (lambda calculus knowledge representation curry howard computational linguistics)
<p>Natural language semantics (in computational linguistics) uses lambda terms for expressing the semantics of natural language sentences. There is vast literature about combina... | habedi/stack-exchange-dataset |
79,339 | NP-completeness of solving quadratic equations over $\mathbb{Z}_2$ | <blockquote>
 <p>Let $\chi$ be a degree 2 equation over $\mathbb{Z}_2$ of the form:
 $$x_{i_1}x_{j_1} + x_{i_{2}}x_{j_1} + \cdots + x_{i_m}x_{j_m} + x_{k_1} + \cdots + x_{k_l} = b $$ for $ k_i \in \{1, \dots, n\}, b \in \{0,1\}$ for some $m, l \in \mathbb{N}$ </p>
 
 <p><br></p>
 
 <p>Prov... | np complete np hard | 1 | NP-completeness of solving quadratic equations over $\mathbb{Z}_2$ -- (np complete np hard)
<blockquote>
 <p>Let $\chi$ be a degree 2 equation over $\mathbb{Z}_2$ of the form:
 $$x_{i_1}x_{j_1} + x_{i_{2}}x_{j_1} + \cdots + x_{i_m}x_{j_m} + x_{k_1} + \cdots + x_{k_l} = b $$ for $ k_i \in \{1, \dots, n\}, b \i... | habedi/stack-exchange-dataset |
79,340 | Decision tree complexity of finding parameters of "zigzag" array | <p>I am currently studying for a test on data structures.</p>
<p>I have to find the lower and upper bounds for the following problem:</p>
<blockquote>
<p>An array is called a <em>zigzag</em> array if there are <span class="math-container">$1 \leq i \leq j \leq n$</span> so that the array increases from <spa... | data structures decision tree | 1 | Decision tree complexity of finding parameters of "zigzag" array -- (data structures decision tree)
<p>I am currently studying for a test on data structures.</p>
<p>I have to find the lower and upper bounds for the following problem:</p>
<blockquote>
<p>An array is called a <em>zigzag</em> array if there ar... | habedi/stack-exchange-dataset |
79,344 | Can nested structures be encoded more "readably" with a single delimiter? | <p>Imagine you have two systems of delimiting. One with paired delimiters, <code>[</code> and <code>]</code>:</p>

<pre><code> [abc]
</code></pre>

<p>Then another system which uses a single interstitial delimiter, <code>/</code>:</p>

<pre><code> a/b/c
</code></pre>

<p>It's ea... | encoding scheme | 1 | Can nested structures be encoded more "readably" with a single delimiter? -- (encoding scheme)
<p>Imagine you have two systems of delimiting. One with paired delimiters, <code>[</code> and <code>]</code>:</p>

<pre><code> [abc]
</code></pre>

<p>Then another system which uses a single interstitial ... | habedi/stack-exchange-dataset |
79,348 | Numerator of HRRN scheduling formula | <p>In the HRRN scheduling, priority formula is</p>

<p>P = (W+E)/E , where W: waiting time and E: estimated run time.</p>

<p>CPU finds the job that has highest priority value and does that job.</p>

<p>However, the formula is equivalent to P = 1 + W/E. If we just "minus 1" and make a new formul... | operating systems process scheduling | 1 | Numerator of HRRN scheduling formula -- (operating systems process scheduling)
<p>In the HRRN scheduling, priority formula is</p>

<p>P = (W+E)/E , where W: waiting time and E: estimated run time.</p>

<p>CPU finds the job that has highest priority value and does that job.</p>

<p>However, the f... | habedi/stack-exchange-dataset |
79,353 | Number of bits to encode number of accepting paths of an $NP$ machine? | <p>Can polynomial number of bits always encode the number of accepting paths of an $NP$ machine?</p>

<p>Can polynomial number of bits always encode the number of accepting paths of any machine in the polynomial hierarchy?</p>
 | complexity theory np | 1 | Number of bits to encode number of accepting paths of an $NP$ machine? -- (complexity theory np)
<p>Can polynomial number of bits always encode the number of accepting paths of an $NP$ machine?</p>

<p>Can polynomial number of bits always encode the number of accepting paths of any machine in the polynomial hie... | habedi/stack-exchange-dataset |
79,355 | $UP^{\ O}\neq P^{\ O}$ for some oracle $O$ | <p>The definition of the class $UP$ is <a href="https://complexityzoo.uwaterloo.ca/Complexity_Zoo:U#up" rel="nofollow noreferrer">here</a>. It is of course easy to see that $P\subseteq UP$. </p>

<p>I have a problem of proving that there is an oracle $O$ and a language $L$ such that $L\in UP^{\ O}$ but $L\notin... | complexity theory polynomial time oracle machines | 1 | $UP^{\ O}\neq P^{\ O}$ for some oracle $O$ -- (complexity theory polynomial time oracle machines)
<p>The definition of the class $UP$ is <a href="https://complexityzoo.uwaterloo.ca/Complexity_Zoo:U#up" rel="nofollow noreferrer">here</a>. It is of course easy to see that $P\subseteq UP$. </p>

<p>I have a proble... | habedi/stack-exchange-dataset |
79,356 | $\mathsf{NL}$ versus $\mathsf{NL}[2]$ | <p>There is an equivalent definition for the class $\mathsf{NL}$ with verifier. Those verifiers are deterministic Turing machines that can read the witness tape only once in one way from left to right. </p>

<p>Given a function $f:\mathbb{N}\to\mathbb{N}$ we say that $\mathsf{NL}[f(n)]$ is the class obtained by... | complexity theory turing machines nondeterminism | 1 | $\mathsf{NL}$ versus $\mathsf{NL}[2]$ -- (complexity theory turing machines nondeterminism)
<p>There is an equivalent definition for the class $\mathsf{NL}$ with verifier. Those verifiers are deterministic Turing machines that can read the witness tape only once in one way from left to right. </p>

<p>Given a f... | habedi/stack-exchange-dataset |
79,358 | Efficient algorithm for edit distance for short sequences | <p>I have an application that needs to compute billions of levenshtein distance between pairs of strings. The strings are short (70 in length) DNA sequences, consisting only of 4 characters. Also it can be assumed that one of the strings is fixed, i.e., we are comparing one fixed string to a billion other strings. </p>... | strings edit distance | 1 | Efficient algorithm for edit distance for short sequences -- (strings edit distance)
<p>I have an application that needs to compute billions of levenshtein distance between pairs of strings. The strings are short (70 in length) DNA sequences, consisting only of 4 characters. Also it can be assumed that one of the strin... | habedi/stack-exchange-dataset |
79,371 | What is the set of all maximal 3CNF formulas? | <p><strong>Definition:</strong> A <strong>maximal</strong> 3CNF formula is satisfiable 3CNF formula, but if you conjuct it with another any <strong>new different</strong> 3 disjuctive literals clause, then the formula becomes <strong>un</strong>satisfiable.</p>

<p>Please do<strong>n't</strong> confuse with the... | logic first order logic propositional logic | 1 | What is the set of all maximal 3CNF formulas? -- (logic first order logic propositional logic)
<p><strong>Definition:</strong> A <strong>maximal</strong> 3CNF formula is satisfiable 3CNF formula, but if you conjuct it with another any <strong>new different</strong> 3 disjuctive literals clause, then the formula becomes... | habedi/stack-exchange-dataset |
79,376 | What is the complexity to show this theorem? | <p>Given a sum of regular expressions, where each regular expression in the sum is <strong>n-1</strong> concatenations of 0, 1 and (0+1).</p>

<p>There is need to show that the sum of all regular expressions is either equal to or not equal to the regular expression, which is <strong>n-1</strong> concatenations ... | complexity theory time complexity runtime analysis space complexity space analysis | 1 | What is the complexity to show this theorem? -- (complexity theory time complexity runtime analysis space complexity space analysis)
<p>Given a sum of regular expressions, where each regular expression in the sum is <strong>n-1</strong> concatenations of 0, 1 and (0+1).</p>

<p>There is need to show that the su... | habedi/stack-exchange-dataset |
79,386 | Is this possible to solve SAT in polynomial time by reducing it to the problem of solving system of nonlinear equations? | <p>Every conjunctive normal form (CNF) formula can be converted to nonlinear system of equations, where each clause becomes an equation in the system and:</p>

<p>If A and B are logical/boolean variables and defined as A∈{T,F} ∧ B∈{T,F} or (A,B)∈{T,F}<sup>2</sup> where</p>

<p>{T,F}<s... | complexity theory np complete satisfiability sat solvers | 1 | Is this possible to solve SAT in polynomial time by reducing it to the problem of solving system of nonlinear equations? -- (complexity theory np complete satisfiability sat solvers)
<p>Every conjunctive normal form (CNF) formula can be converted to nonlinear system of equations, where each clause becomes an equation i... | habedi/stack-exchange-dataset |
79,387 | What is the problem with this Busy Wait solution for two threads? | <p>We have two processes. One process produces F and the other process consumes F </p>

<p>Initialization:</p>

<pre><code>Consuming = false
Produced = false
F = EMPTY
</code></pre>

<p>The first thread (we can think of it as some kind of producer):</p>

<pre><code>P1:
lo... | concurrency mutual exclusion critical section | 1 | What is the problem with this Busy Wait solution for two threads? -- (concurrency mutual exclusion critical section)
<p>We have two processes. One process produces F and the other process consumes F </p>

<p>Initialization:</p>

<pre><code>Consuming = false
Produced = false
F = EMPTY
</code>... | habedi/stack-exchange-dataset |
79,391 | No polynomial time approximation algorithm better than $n^{1 − ε}$ | <p>What does this sentence mean?</p>

<p>For all $ε > 0$, it is NP-hard to approximate MAX CLIQUE to within $n^{1 − ε}$.</p>

<p>Is the fact that complexity of approximation depends on $\epsilon$ hidden in the statement? I mean, if not, I guess we can make $\epsilon$ arbitrarily small, (like $\epsilo... | complexity theory np complete np hard approximation | 1 | No polynomial time approximation algorithm better than $n^{1 − ε}$ -- (complexity theory np complete np hard approximation)
<p>What does this sentence mean?</p>

<p>For all $ε > 0$, it is NP-hard to approximate MAX CLIQUE to within $n^{1 − ε}$.</p>

<p>Is the fact that complexity of approximation dep... | habedi/stack-exchange-dataset |
79,393 | Generating values from a probability density function | <p>If I have a probability density function, some f(x) which is >= 0 everywhere and integrates to 1, is there a method to generate random numbers using that PDF?</p>

<p>I know there is the box-muller transform to convert uniform random numbers to gaussian, but is there anything for the general case, or at leas... | random number generator monte carlo | 1 | Generating values from a probability density function -- (random number generator monte carlo)
<p>If I have a probability density function, some f(x) which is >= 0 everywhere and integrates to 1, is there a method to generate random numbers using that PDF?</p>

<p>I know there is the box-muller transform to con... | habedi/stack-exchange-dataset |
79,394 | An elementary oracle query | <p>Why is $P^{NP}\not\subseteq NP$ possible? After all we have a $P$ machine which uses an $NP$ oracle and since $P\subseteq NP$ why cannot the $P$ machine with $NP$ oracle just be replaced by an $NP$ machine?</p>

<p>Similarly why is not the case $P^{coNP}\subseteq coNP$?</p>
 | complexity theory | 1 | An elementary oracle query -- (complexity theory)
<p>Why is $P^{NP}\not\subseteq NP$ possible? After all we have a $P$ machine which uses an $NP$ oracle and since $P\subseteq NP$ why cannot the $P$ machine with $NP$ oracle just be replaced by an $NP$ machine?</p>

<p>Similarly why is not the case $P^{coNP}\subs... | habedi/stack-exchange-dataset |
79,408 | Are counting problems the same as problems involving listing all possible combinations? | <p>I recently tried coming up with an algorithm that uses dynamic programming for the counting variant of the change problem. Given a set of target and a set of denominations, print the number of possible combinations that add up to the target. So if my target is 5 and my set is <code>{ 1, 2, 5, 10 }</code> then the so... | algorithms dynamic programming counting | 1 | Are counting problems the same as problems involving listing all possible combinations? -- (algorithms dynamic programming counting)
<p>I recently tried coming up with an algorithm that uses dynamic programming for the counting variant of the change problem. Given a set of target and a set of denominations, print the n... | habedi/stack-exchange-dataset |
79,420 | Show that (2,3)-satisfability is np-complete | <p>First of all, I introduce <em>(2,3)-satisfability</em>:<br>
Formulas are in CNF form, the special property is that each clause has $2$ or $3$ literals. Formula is satisfied iff only and only if there exists valuation such that: </p>

<ul>
<li>clauses with two literals are treated normally - it suffi... | complexity theory time complexity np complete np | 1 | Show that (2,3)-satisfability is np-complete -- (complexity theory time complexity np complete np)
<p>First of all, I introduce <em>(2,3)-satisfability</em>:<br>
Formulas are in CNF form, the special property is that each clause has $2$ or $3$ literals. Formula is satisfied iff only and only if there exists valuati... | habedi/stack-exchange-dataset |
79,421 | Finding $L^*$ when $L=\{a^nb^n | n \geq 1\}$ | <p>Let $L=\{a^nb^n | n \ge 1\}$, then $L^\star=L^0 \cup L^1 \cup L^2 \cup L^3 \cup \dots = \{\epsilon\} \cup \{a^nb^n\} \cup L^2 \cup L^3 \cup \cdots$ . </p>

<p>How to find $L^2$ and $L^3$, and is $L^2=\{a^nb^na^nb^n\}$? In this video <a href="https://youtu.be/rnGpW6RRAcw" rel="nofollow noreferrer">https://you... | formal languages kleene star | 1 | Finding $L^*$ when $L=\{a^nb^n | n \geq 1\}$ -- (formal languages kleene star)
<p>Let $L=\{a^nb^n | n \ge 1\}$, then $L^\star=L^0 \cup L^1 \cup L^2 \cup L^3 \cup \dots = \{\epsilon\} \cup \{a^nb^n\} \cup L^2 \cup L^3 \cup \cdots$ . </p>

<p>How to find $L^2$ and $L^3$, and is $L^2=\{a^nb^na^nb^n\}$? In this vid... | habedi/stack-exchange-dataset |
79,425 | Does exist an algorithm to find all equivalence classes of given regular expression without kleene star? If yes then what is it? | <p>Does exist an algorithm to find all equivalence classes of given regular expression without kleene star?</p>

<p>If yes then what is it?</p>

<p>Note that alphabet of the given regular expression is binary, i.e. it contains only 2 symbols exactly.</p>

<p>This is important, because I can easi... | formal languages automata regular languages finite automata regular expressions | 1 | Does exist an algorithm to find all equivalence classes of given regular expression without kleene star? If yes then what is it? -- (formal languages automata regular languages finite automata regular expressions)
<p>Does exist an algorithm to find all equivalence classes of given regular expression without kleene star... | habedi/stack-exchange-dataset |
79,437 | Given DAG G(V,E), and weight on the vertices, find the heaviest path that starts from s | <p><strong>Given:</strong> G(V,E) DAG, vertex s, and function w: V -> R. <strong>(the weight on the vertices)</strong></p>

<p><strong>Define:</strong> We define a weighted path in G as sum of all the <strong>vertices weight</strong>.</p>

<p><strong>Question:</strong> Find the heaviest path in G that s... | algorithms | 1 | Given DAG G(V,E), and weight on the vertices, find the heaviest path that starts from s -- (algorithms)
<p><strong>Given:</strong> G(V,E) DAG, vertex s, and function w: V -> R. <strong>(the weight on the vertices)</strong></p>

<p><strong>Define:</strong> We define a weighted path in G as sum of all the <strong... | habedi/stack-exchange-dataset |
79,446 | What will be the Turing machine to show that the function $T(n) = n$ is time constructible? | <p>Specifically, we need a Turing machine that on input $1^n$ outputs binary representation of $n$ on output tape in $O(n)$ time. I am not able to get any thing better than trivial $O(n \log n)$ time. Any hints or solution?</p>
 | complexity theory | 1 | What will be the Turing machine to show that the function $T(n) = n$ is time constructible? -- (complexity theory)
<p>Specifically, we need a Turing machine that on input $1^n$ outputs binary representation of $n$ on output tape in $O(n)$ time. I am not able to get any thing better than trivial $O(n \log n)$ time. Any ... | habedi/stack-exchange-dataset |
79,448 | Does an RL agent need to experience a complete episode in order to learn? | <p>Suppose we have a game where there is no good measure of how "far" the target is (that we could use to nudge the agent towards the goal via the immediate returns).</p>

<p>If the agent gets only -1 reward per time step and experiencing a full episode where it reaches the goal is extremely improbable (it's eq... | machine learning reinforcement learning | 1 | Does an RL agent need to experience a complete episode in order to learn? -- (machine learning reinforcement learning)
<p>Suppose we have a game where there is no good measure of how "far" the target is (that we could use to nudge the agent towards the goal via the immediate returns).</p>

<p>If the agent gets ... | habedi/stack-exchange-dataset |
79,452 | Optimal covering of 2D matrix elements given spatial constraints | <p>I have a particular problem I need to solve, but I'm not sure how to classify the problem or pick the right algorithm to solve it. I'm hoping someone here can lead me in the right direction.</p>

<p>I've generalized and reduced the problem to this:</p>

<p>Given an $M \times N$ matrix with elements i... | algorithms optimization network flow set cover | 1 | Optimal covering of 2D matrix elements given spatial constraints -- (algorithms optimization network flow set cover)
<p>I have a particular problem I need to solve, but I'm not sure how to classify the problem or pick the right algorithm to solve it. I'm hoping someone here can lead me in the right direction.</p>
&... | habedi/stack-exchange-dataset |
79,461 | Solving a T(n) recursion without Master Theorem | <p>i have a problem solving the recursion $T(n) = T(n-20)+log(n)$, because
the Master Theorem is not applicable in this case.</p>

<p>This is my attempt:<br/>
$T(1) = 1$(given)<br/>
$T(n) = T(n-20)+log(n)$<br/>
$T(n) = T(n-20-20)+log(n-20)+log(n) $<br/>
...<br/>
...<br/>
$T(n) = T(n-... | asymptotics recurrence relation | 1 | Solving a T(n) recursion without Master Theorem -- (asymptotics recurrence relation)
<p>i have a problem solving the recursion $T(n) = T(n-20)+log(n)$, because
the Master Theorem is not applicable in this case.</p>

<p>This is my attempt:<br/>
$T(1) = 1$(given)<br/>
$T(n) = T(n-20)+log(n)$<br/>
... | habedi/stack-exchange-dataset |
79,472 | Given a binary min-heap, getting a sorted array of the $\log n$ smallest elements | <p>Let's say we have a binary min-heap of size $n$, and we want to get an array of the smallest $\log n$ values in the heap, sorted. What is the best complexity that we can get and how do we implement it?</p>

<p>The simplest solution would be using $\text{Get-Min, Delete-Min}$, $\log n$ times, and that would b... | time complexity heaps selection problem | 1 | Given a binary min-heap, getting a sorted array of the $\log n$ smallest elements -- (time complexity heaps selection problem)
<p>Let's say we have a binary min-heap of size $n$, and we want to get an array of the smallest $\log n$ values in the heap, sorted. What is the best complexity that we can get and how do we im... | habedi/stack-exchange-dataset |
79,491 | Decide if binary encoded number is divisible by 3 | <p>Let's consider the language over $\{0,1\}$ containing such words $w$ that: 
$$w = m_1m_2..m_n $$ where $m_i$ has length $n$. (so $|w|=n^2$) and $$m_1 + m_2 + .. + m_n \mod 3 = 0$$</p>

<p>($m_i$ we interpret as binary encoded number).</p>

<p>Prove, that the language is $NC^1$ class. </p>
&#... | circuits | 1 | Decide if binary encoded number is divisible by 3 -- (circuits)
<p>Let's consider the language over $\{0,1\}$ containing such words $w$ that: 
$$w = m_1m_2..m_n $$ where $m_i$ has length $n$. (so $|w|=n^2$) and $$m_1 + m_2 + .. + m_n \mod 3 = 0$$</p>

<p>($m_i$ we interpret as binary encoded number).</p>&#... | habedi/stack-exchange-dataset |
79,497 | Asymptotic runtime of a nested sum | <p>i have to calculate the asymptotic runtime of a nested sum:</p>

<p>Sum $\sum_{n=1}^{log_{4}(n)} \sum_{n=1}^{\sqrt{n}}1$<br/></p>

<p>My solution is $\Theta(log(n) \cdot \sqrt{n})$, which is wrong, because the solution says $\Theta(\sqrt{n})$. I dont understand where my mistake is:</p>

<p>Su... | asymptotics runtime analysis | 1 | Asymptotic runtime of a nested sum -- (asymptotics runtime analysis)
<p>i have to calculate the asymptotic runtime of a nested sum:</p>

<p>Sum $\sum_{n=1}^{log_{4}(n)} \sum_{n=1}^{\sqrt{n}}1$<br/></p>

<p>My solution is $\Theta(log(n) \cdot \sqrt{n})$, which is wrong, because the solution says $\Theta(... | habedi/stack-exchange-dataset |
79,508 | How similar is the Goldwasser-Sipser Set Lower Bound Protocol to the Hashcash/Bitcoin Proof-of-Work? | <p>Given a hash function $H:\{0,1\}^*\rightarrow\{0,1\}^n$, a difficulty $d\in\mathbb{N}$, and data $D\in\{0,1\}^*$, the framework of the Hashcash/Bitcoin Proof-of-Work entails finding a nonce $c$ such that $H(c\Vert D)$ starts with $d$ zero’s. That is to say, Hashcash/Bitcoin Proofs-of-Work appear to find a preimage ... | hash graph isomorphism interactive proof systems proof of work | 1 | How similar is the Goldwasser-Sipser Set Lower Bound Protocol to the Hashcash/Bitcoin Proof-of-Work? -- (hash graph isomorphism interactive proof systems proof of work)
<p>Given a hash function $H:\{0,1\}^*\rightarrow\{0,1\}^n$, a difficulty $d\in\mathbb{N}$, and data $D\in\{0,1\}^*$, the framework of the Hashcash/Bitc... | habedi/stack-exchange-dataset |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.