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 |
|---|---|---|---|---|---|---|
67,163 | Boolean variable true iff equation is satisfied in ILP | <p>Assuming $y$ is a boolean variable in an ILP program (that is $y \in Z$, s.t. $0 <= y <= 1$) and $x_1$, $x_2$ are bounded integer variables between $0$ and $M$. I want to encode the following high level constraint:</p>

<p>$$y = 1 \iff x_1 \le x_2$$</p>

<p>So far I've got this:</p>

<p... | integer programming | 1 | Boolean variable true iff equation is satisfied in ILP -- (integer programming)
<p>Assuming $y$ is a boolean variable in an ILP program (that is $y \in Z$, s.t. $0 <= y <= 1$) and $x_1$, $x_2$ are bounded integer variables between $0$ and $M$. I want to encode the following high level constraint:</p>

<p>... | habedi/stack-exchange-dataset |
67,171 | Is mapping reduction from $\overline{A_{TM}}$ possible? | <p>I know $\overline{A_{TM}}$ is not Turing Recognizable (to prove it, infact, I proved its complement to be both Turing-recognizable and not decidable). </p>

<p>My question is, if $\overline{A_{TM}}$ is not Turing Recognizable, can I reduce $\overline{A_{TM}}$ to some language A (say $E_{TM}$) to show it is n... | turing machines reductions | 1 | Is mapping reduction from $\overline{A_{TM}}$ possible? -- (turing machines reductions)
<p>I know $\overline{A_{TM}}$ is not Turing Recognizable (to prove it, infact, I proved its complement to be both Turing-recognizable and not decidable). </p>

<p>My question is, if $\overline{A_{TM}}$ is not Turing Recogniz... | habedi/stack-exchange-dataset |
67,175 | Admissibility of heuristic in the $A^*$ algorithm | <p>The <a href="https://youtu.be/ka5KpaKDGF0?t=45m1s" rel="nofollow noreferrer">CS188 course from Berkeley</a> goes to great length in explaining why the optimality of $A^*$ algorithm is conditioned by the admissibility of heuristic.</p>

<p>Note: admissibility of heuristic means that:</p>

<p>$$\forall... | algorithms search algorithms trees | 1 | Admissibility of heuristic in the $A^*$ algorithm -- (algorithms search algorithms trees)
<p>The <a href="https://youtu.be/ka5KpaKDGF0?t=45m1s" rel="nofollow noreferrer">CS188 course from Berkeley</a> goes to great length in explaining why the optimality of $A^*$ algorithm is conditioned by the admissibility of heurist... | habedi/stack-exchange-dataset |
67,180 | Is there a way to check if a path in a graph is infinite? | <p><strong>Edit:</strong> Maybe this is not the best title, so few free to change it.</p>

<p>So I'm trying to prove the following statement:</p>

<blockquote>
 <p>A finitely branching tree $T$ with infinitely many vertices must have an infinite path.</p>
</blockquote>

<p>My proof is l... | graphs | 1 | Is there a way to check if a path in a graph is infinite? -- (graphs)
<p><strong>Edit:</strong> Maybe this is not the best title, so few free to change it.</p>

<p>So I'm trying to prove the following statement:</p>

<blockquote>
 <p>A finitely branching tree $T$ with infinitely many vertices must ... | habedi/stack-exchange-dataset |
67,183 | Is it possible to prove Language L context-free? | <p>Give a question:
Language L= {a^n b^(n+m) a^m}, where both n and m are >=0. Is L context-free or not.</p>

<p>If the answer is yes, can I use the following PDA to prove it?</p>

<p>Since {a^n b^(n+m) a^m}={a^n b^n b^m a^m}, in the PDA, we first push n a's onto the stack. Then, we pop n a's from t... | context free | 1 | Is it possible to prove Language L context-free? -- (context free)
<p>Give a question:
Language L= {a^n b^(n+m) a^m}, where both n and m are >=0. Is L context-free or not.</p>

<p>If the answer is yes, can I use the following PDA to prove it?</p>

<p>Since {a^n b^(n+m) a^m}={a^n b^n b^m a^m}, in the... | habedi/stack-exchange-dataset |
67,192 | Is it possible to copy data in a linear type system? | <p>I'm having a little problem with the abstraction layers in linear types. If every variable is used exactly once, there is no way to copy data, since you have to read each datum twice in order to write it twice to two different locations. </p>

<p>However, you could argue that once a variable is loaded into a... | type theory | 1 | Is it possible to copy data in a linear type system? -- (type theory)
<p>I'm having a little problem with the abstraction layers in linear types. If every variable is used exactly once, there is no way to copy data, since you have to read each datum twice in order to write it twice to two different locations. </p>
... | habedi/stack-exchange-dataset |
67,209 | What does "monotonicity" mean in the context of mutability | <p>I'm reading <em>The Rust Programming Language</em> and found the following passage:</p>

<blockquote>
 <p>Remember that writing to a struct is not an atomic operation, and many
 functions like <code>vec.push()</code> can reallocate internally and cause unsafe
 behavior, so even <strong>monoton... | programming languages synchronization | 1 | What does "monotonicity" mean in the context of mutability -- (programming languages synchronization)
<p>I'm reading <em>The Rust Programming Language</em> and found the following passage:</p>

<blockquote>
 <p>Remember that writing to a struct is not an atomic operation, and many
 functions like <cod... | habedi/stack-exchange-dataset |
67,211 | “Standard” approach to syncing data? | <p>I'm wondering if there are any universally accepted "best" algorithms for syncing data sets.</p>

<p>I imagine there would be different solutions depending on circumstances:</p>

<ul>
<li>Are all peers online all the time or not?</li>
<li>Are we more limited by bandwidth or processing power?<... | algorithms synchronization | 1 | “Standard” approach to syncing data? -- (algorithms synchronization)
<p>I'm wondering if there are any universally accepted "best" algorithms for syncing data sets.</p>

<p>I imagine there would be different solutions depending on circumstances:</p>

<ul>
<li>Are all peers online all the time or not... | habedi/stack-exchange-dataset |
67,219 | Proof that multi-armed bandit optimization has exponential regret if loss function is general | <p>I was reading Robert Kelinberg's paper on <a href="https://papers.nips.cc/paper/2634-nearly-tight-bounds-for-the-continuum-armed-bandit-problem.pdf" rel="nofollow noreferrer">Nearly Tight Bounds for the Continuum-Armed Bandit Problem</a> 
There is a section where he says:</p>

<p>"For a d-dimensional str... | optimization machine learning | 1 | Proof that multi-armed bandit optimization has exponential regret if loss function is general -- (optimization machine learning)
<p>I was reading Robert Kelinberg's paper on <a href="https://papers.nips.cc/paper/2634-nearly-tight-bounds-for-the-continuum-armed-bandit-problem.pdf" rel="nofollow noreferrer">Nearly Tight ... | habedi/stack-exchange-dataset |
67,223 | What kind of language uses an infinite alphabet? | <p>Kind of what it says on the tin. Let's say I have a countably infinite alphabet $A$ and a "language" $L = \{s_1s_2 | s_1,s_2 \in A\}$ (i.e. all possible strings of length 2). Now, my question is this: does it even make sense to think of this in terms of formal languages? Is there some construct akin to a state machi... | formal languages | 1 | What kind of language uses an infinite alphabet? -- (formal languages)
<p>Kind of what it says on the tin. Let's say I have a countably infinite alphabet $A$ and a "language" $L = \{s_1s_2 | s_1,s_2 \in A\}$ (i.e. all possible strings of length 2). Now, my question is this: does it even make sense to think of this in t... | habedi/stack-exchange-dataset |
67,227 | Comparing complexity of function | <p>Let's say I have a function that runs in $O(n \lg n)$.</p>

<p>Let's say instead of running this function with a $n$-sized input, I run it <strong>$k$ times</strong> with an <strong>$(n/k)$-sized</strong> input, so I want to check if</p>

<p>$$ O(n \lg n) = k \left( O \left( \frac{n}{k} \lg \frac{n}... | complexity theory time complexity | 1 | Comparing complexity of function -- (complexity theory time complexity)
<p>Let's say I have a function that runs in $O(n \lg n)$.</p>

<p>Let's say instead of running this function with a $n$-sized input, I run it <strong>$k$ times</strong> with an <strong>$(n/k)$-sized</strong> input, so I want to check if</p>... | habedi/stack-exchange-dataset |
67,229 | MAX SAT Optimization problem | <p>search problem: find the assignment that maximize the number of satisfied clauses</p>

<p>For decision problem: determine whether there is an assignment that satisfies k of clauses.</p>

<p>optimization problem : determine the number of clauses that maximize the number of satisfied clauses ( is this ... | complexity theory optimization reductions decision problem search problem | 1 | MAX SAT Optimization problem -- (complexity theory optimization reductions decision problem search problem)
<p>search problem: find the assignment that maximize the number of satisfied clauses</p>

<p>For decision problem: determine whether there is an assignment that satisfies k of clauses.</p>

<p>opt... | habedi/stack-exchange-dataset |
67,237 | Correctness of algorithm to find maximum in array | <p>I want to show correctness of "Algorithm to find maximum element in array" using induction and contradiction.</p>

<pre><code>ans=-infinity
for (i=0; i<n; i++)
 ans= max(ans, A[i])
</code></pre>

<p>where A[0:n-1] is array and max is the function to return maximum of its two argumen... | algorithms arrays correctness proof | 1 | Correctness of algorithm to find maximum in array -- (algorithms arrays correctness proof)
<p>I want to show correctness of "Algorithm to find maximum element in array" using induction and contradiction.</p>

<pre><code>ans=-infinity
for (i=0; i<n; i++)
 ans= max(ans, A[i])
</code></pre>
&... | habedi/stack-exchange-dataset |
67,243 | What are the uses of multi-dimensional arrays? | <p>While studying arrays a question came to my mind. If only 1D and 2D arrays can be used, then why multi-dimensional arrays exist? Is there any use of multi-dimensional arrays?</p>
 | data structures arrays | 1 | What are the uses of multi-dimensional arrays? -- (data structures arrays)
<p>While studying arrays a question came to my mind. If only 1D and 2D arrays can be used, then why multi-dimensional arrays exist? Is there any use of multi-dimensional arrays?</p>
 | habedi/stack-exchange-dataset |
67,245 | Curious about an old algorithm which calculates modular inverse | <p>I am not sure if I should ask this question here or somewhere else. In fact, I initially asked my question <a href="https://mathoverflow.net/questions/256906/curious-about-an-old-algorithm-which-calculates-modular-inverse">here at mathoverflow.net</a> but it was marked as off-topic</p>

<p><strong>Background... | algorithm analysis correctness proof number theory modular arithmetic | 1 | Curious about an old algorithm which calculates modular inverse -- (algorithm analysis correctness proof number theory modular arithmetic)
<p>I am not sure if I should ask this question here or somewhere else. In fact, I initially asked my question <a href="https://mathoverflow.net/questions/256906/curious-about-an-old... | habedi/stack-exchange-dataset |
67,259 | Is it decidable whether a Turing machine modifies the tape, on a particular input? | <p>Is $L=\{\langle M,w \rangle|M\text{ does not modify the tape on input w}\}$ decidable?</p>

<p>We could tell if a TM does not modify the tape on <strong>any</strong> input by checking if there are no transitions in $M$ that write on the tape, but can it be decided for a given $w$?</p>
 | computability turing machines reductions undecidability | 1 | Is it decidable whether a Turing machine modifies the tape, on a particular input? -- (computability turing machines reductions undecidability)
<p>Is $L=\{\langle M,w \rangle|M\text{ does not modify the tape on input w}\}$ decidable?</p>

<p>We could tell if a TM does not modify the tape on <strong>any</strong>... | habedi/stack-exchange-dataset |
67,261 | A minimal automaton for a language quotient $w^{-1}L$ if $L$ is regular | <p>For a given language $L$ and $w \in X^{\ast}$ denote by $w^{-1} L := \{ u \in X^{\ast} : wu \in L \}$ the (left) quotients of $L$. The left quotients are closely related to the minimal automaton of $L$ in case $L$ is regular, i.e. in that case $(X, Q, \delta, q_0, F)$
with $Q := \{ w^{-1} L : w \in X^{\ast} \}$,... | formal languages | 1 | A minimal automaton for a language quotient $w^{-1}L$ if $L$ is regular -- (formal languages)
<p>For a given language $L$ and $w \in X^{\ast}$ denote by $w^{-1} L := \{ u \in X^{\ast} : wu \in L \}$ the (left) quotients of $L$. The left quotients are closely related to the minimal automaton of $L$ in case $L$ is regula... | habedi/stack-exchange-dataset |
67,268 | Properties of language that can be enumerated in a finite amount of time with an enumerator? | <p>Suppose an enumerator <em>E</em> can enumerate some language <em>L</em> in a finite amount of time (3 days, 3 hours, etc.). What properties does this language have?</p>

<p>My guess: </p>

<ul>
<li><em>L</em> is finite, so <em>L</em> is a context-free language. </li>
<li>Since <em>L</em> is a... | computability turing machines undecidability | 1 | Properties of language that can be enumerated in a finite amount of time with an enumerator? -- (computability turing machines undecidability)
<p>Suppose an enumerator <em>E</em> can enumerate some language <em>L</em> in a finite amount of time (3 days, 3 hours, etc.). What properties does this language have?</p>
&... | habedi/stack-exchange-dataset |
67,273 | Turing machine decides languages in RE | <p>Given this language:
$$L_{s_1,s_2} = \{ \langle M_1 \rangle \langle M_2 \rangle | L(M_1) \in S_1 \text{ and } L(M_2) \in S_2 \}$$
I want to prove that for $S_1=RE$ and $S_2=RE$, then $L_{S_1,S_2} \in R$.</p>

<p>The way I started was by trying to build a Turing Machine that decides $L_{S_1,S_2}$:</p... | computability turing machines | 1 | Turing machine decides languages in RE -- (computability turing machines)
<p>Given this language:
$$L_{s_1,s_2} = \{ \langle M_1 \rangle \langle M_2 \rangle | L(M_1) \in S_1 \text{ and } L(M_2) \in S_2 \}$$
I want to prove that for $S_1=RE$ and $S_2=RE$, then $L_{S_1,S_2} \in R$.</p>

<p>The way I star... | habedi/stack-exchange-dataset |
67,287 | Succinct data structure to return occurences of letters until an index | <p>I want to try and use a succinct type data structure in order to find the amount of occurences of a letter $C$ in a string $S$ until a given index $I$.</p>

<p>Assume we have a string $S$ of length $n$ over the alphabet $\Sigma = \{1,2,3,\ldots,n\}$. I want to build a data structure whose space usage is at m... | data structures succinct data structures | 1 | Succinct data structure to return occurences of letters until an index -- (data structures succinct data structures)
<p>I want to try and use a succinct type data structure in order to find the amount of occurences of a letter $C$ in a string $S$ until a given index $I$.</p>

<p>Assume we have a string $S$ of l... | habedi/stack-exchange-dataset |
67,294 | Providing $1^n$ as input to protect against degenerate cases | <p>The following language is NP-complete:</p>

<p>$$\{ (\alpha, x, 1^n, 1^t): \exists u \in \{0,1\}^n s.t. M_\alpha \text{ outputs 1 on input } (x,u) \text{ within t steps}\}$$</p>

<p>I would like to have a stronger understanding of the $1^n$ and $1^t$ inputs that are provided as auxiliary inputs. Is t... | turing machines np complete | 1 | Providing $1^n$ as input to protect against degenerate cases -- (turing machines np complete)
<p>The following language is NP-complete:</p>

<p>$$\{ (\alpha, x, 1^n, 1^t): \exists u \in \{0,1\}^n s.t. M_\alpha \text{ outputs 1 on input } (x,u) \text{ within t steps}\}$$</p>

<p>I would like to have a st... | habedi/stack-exchange-dataset |
67,297 | Linear time algorithm for least positive integer missing from array | <blockquote>
<p>Design a linear time algorithm for finding the least positive integer missing from an unsorted array. Changes in the array are allowed.</p>
<p>For example, for the array -10,-1,2,3,6,30, the answer is 1.</p>
</blockquote>
<p>I thought about finding the maximum and minimum numbers in the ... | algorithms | 1 | Linear time algorithm for least positive integer missing from array -- (algorithms)
<blockquote>
<p>Design a linear time algorithm for finding the least positive integer missing from an unsorted array. Changes in the array are allowed.</p>
<p>For example, for the array -10,-1,2,3,6,30, the answer is 1.</p>
... | habedi/stack-exchange-dataset |
67,312 | Valid actions of Reductions to NP-Completeness | <p>To my understanding, as long as we can find some polytime function $f$ such that $\forall x:x \in A \Longleftrightarrow f(x) \in B, x\notin A \Longleftrightarrow f(x) \notin B$, it follows that if $A$ is NP-complete and B is in NP, then B is also in NP-complete.</p>

<p>My question is about what sort of 'thi... | complexity theory np complete reductions proof techniques | 1 | Valid actions of Reductions to NP-Completeness -- (complexity theory np complete reductions proof techniques)
<p>To my understanding, as long as we can find some polytime function $f$ such that $\forall x:x \in A \Longleftrightarrow f(x) \in B, x\notin A \Longleftrightarrow f(x) \notin B$, it follows that if $A$ is NP-... | habedi/stack-exchange-dataset |
67,320 | Can every single regular expression be translated into deterministic finite automata? | <p>Can every regex be translated into a DFA? Or only a subset of regular expressions?</p>

<p>If so, what is an example of a regular expression that cannot be translated into a DFA?</p>
 | formal languages regular languages finite automata regular expressions | 1 | Can every single regular expression be translated into deterministic finite automata? -- (formal languages regular languages finite automata regular expressions)
<p>Can every regex be translated into a DFA? Or only a subset of regular expressions?</p>

<p>If so, what is an example of a regular expression that c... | habedi/stack-exchange-dataset |
67,366 | Why do we need "potential” for amortized analysis? | <p>In <a href="https://en.wikipedia.org/w/index.php?title=Potential_method&oldid=713008203" rel="nofollow noreferrer">the current version</a> as of <a href="https://en.wikipedia.org/wiki/Potential_method" rel="nofollow noreferrer">the Wikipedia article “Potential method”</a>, the amortized cost of each operation is... | algorithms complexity theory amortized analysis | 1 | Why do we need "potential” for amortized analysis? -- (algorithms complexity theory amortized analysis)
<p>In <a href="https://en.wikipedia.org/w/index.php?title=Potential_method&oldid=713008203" rel="nofollow noreferrer">the current version</a> as of <a href="https://en.wikipedia.org/wiki/Potential_method" rel="no... | habedi/stack-exchange-dataset |
67,367 | How to find indexes of numbers that has many occurrences? | <p>Disclaimer: This is a simplified part of a question from my homework, addressing the point that I didn't figure out.</p>

<blockquote>
 <p>let A be a 1-indexed sorted array of $n$ elements.</p>
 
 <p>There are at most 3 numbers that has at least $\lfloor n/4 \rfloor+1$
 occurrences.</p>&#... | algorithms | 1 | How to find indexes of numbers that has many occurrences? -- (algorithms)
<p>Disclaimer: This is a simplified part of a question from my homework, addressing the point that I didn't figure out.</p>

<blockquote>
 <p>let A be a 1-indexed sorted array of $n$ elements.</p>
 
 <p>There are at most 3 ... | habedi/stack-exchange-dataset |
67,368 | Is it possible to eliminate the unit rules in this? | <pre><code>S -> aA | bC | CC | a | b | C
A -> B
B -> S
C -> A | S
</code></pre>

<p>It looks like its going to loop so it would be endless replacing the unit rule....</p>
 | context free chomsky hierarchy | 1 | Is it possible to eliminate the unit rules in this? -- (context free chomsky hierarchy)
<pre><code>S -> aA | bC | CC | a | b | C
A -> B
B -> S
C -> A | S
</code></pre>

<p>It looks like its going to loop so it would be endless replacing the unit rule....</p>
 | habedi/stack-exchange-dataset |
67,377 | On asymptotic complexity class notation? | <p>Is the class of problems with complexity $O(n^{n^\epsilon})$ at every $\epsilon>0$ same as class of problems with complexity $O(n^{f(n)})$ at every $f(n)\in\omega(1)$ and hence both classes are equivalent to $\mathsf P$ ($n$ is number of input bits)?</p>

<p>(This is my view. Denote $C(n^{n^\epsilon})$ to... | asymptotics notation | 1 | On asymptotic complexity class notation? -- (asymptotics notation)
<p>Is the class of problems with complexity $O(n^{n^\epsilon})$ at every $\epsilon>0$ same as class of problems with complexity $O(n^{f(n)})$ at every $f(n)\in\omega(1)$ and hence both classes are equivalent to $\mathsf P$ ($n$ is number of input bit... | habedi/stack-exchange-dataset |
67,378 | Is the exact cover problem NP-hard when there is a restriction on the size? | <p>The exact cover problem with restrictions on the size is:</p>

<p><em>Input:</em> Given a set $U=\{1,2,\ldots,n\}$ and a collection of $C$ of subsets of $U$.</p>

<p><em>Question:</em> Is there a subcollection $C^\star$ of $C$ such that</p>

<ul>
<li>The intersection of any two distinct s... | np hard set cover | 1 | Is the exact cover problem NP-hard when there is a restriction on the size? -- (np hard set cover)
<p>The exact cover problem with restrictions on the size is:</p>

<p><em>Input:</em> Given a set $U=\{1,2,\ldots,n\}$ and a collection of $C$ of subsets of $U$.</p>

<p><em>Question:</em> Is there a subcol... | habedi/stack-exchange-dataset |
67,379 | Is there a general algorithm to fill holes in terms of the Calculus of Constructions? | <p>Suppose that you extend the Calculus of Constructions with "holes" - i.e., incomplete pieces of code that you didn't fill yet. I wonder if there is an algorithm to fill those roles automatically. For example (using <a href="http://www.haskellforall.com/2014/09/morte-intermediate-language-for-super.html" rel="norefer... | machine learning programming languages unification | 1 | Is there a general algorithm to fill holes in terms of the Calculus of Constructions? -- (machine learning programming languages unification)
<p>Suppose that you extend the Calculus of Constructions with "holes" - i.e., incomplete pieces of code that you didn't fill yet. I wonder if there is an algorithm to fill those ... | habedi/stack-exchange-dataset |
67,380 | "Uniform" Set Cover Approximation? | <p>The (optimization version of) Set Cover problem is the following: given a "universe" set $S$ and a collection of subsets $S_1, \cdots, S_m \subseteq S$, we want to find the minimum cardinality set of $k$ elements $\{i_1, \cdots, i_k\}$ such that $\bigcup_{i=1}^k S_{i_j} = S$.</p>

<p>It is a well-known resul... | reference request approximation | 1 | "Uniform" Set Cover Approximation? -- (reference request approximation)
<p>The (optimization version of) Set Cover problem is the following: given a "universe" set $S$ and a collection of subsets $S_1, \cdots, S_m \subseteq S$, we want to find the minimum cardinality set of $k$ elements $\{i_1, \cdots, i_k\}$ such that... | habedi/stack-exchange-dataset |
67,382 | Inverse Homomorphisms and Kleene star | <p>The exercise is to prove or give a counterexample to the following proposition with $L \subseteq \Gamma^*$ regular and $h: \Gamma \to \Sigma^*$ a homomorphism.</p>

<p>Is there any regular language $L'$ such that $h^{-1}(L^*) = L'^*$
?</p>

<p>I know that it isn't that easy to see, since $h^{-1}(... | formal languages regular languages closure properties | 1 | Inverse Homomorphisms and Kleene star -- (formal languages regular languages closure properties)
<p>The exercise is to prove or give a counterexample to the following proposition with $L \subseteq \Gamma^*$ regular and $h: \Gamma \to \Sigma^*$ a homomorphism.</p>

<p>Is there any regular language $L'$ such that... | habedi/stack-exchange-dataset |
67,386 | Location Selection Algorithm in Solar Engineering | <p>This is a practical problem in energy generation with heliostats.</p>

<p>We have a number of heliostats basically forming the shape of a doughnut. The facility needs to deploy hubs on those heliostats. One hub can support 12 harnesses (a kind of cable) and one harness can support 16 heliostats; namely, one ... | algorithms graphs optimization | 1 | Location Selection Algorithm in Solar Engineering -- (algorithms graphs optimization)
<p>This is a practical problem in energy generation with heliostats.</p>

<p>We have a number of heliostats basically forming the shape of a doughnut. The facility needs to deploy hubs on those heliostats. One hub can support ... | habedi/stack-exchange-dataset |
67,387 | Binary search algorithm - worst-case complexity | <p>I tried to calculate the worst case of binary search (not binary search tree). My calculations:
$$T(n) = T(\frac{n}{2}) + 1$$
$$T(n) = T\left(\frac{n}{4}\right) + (1+1) = T\left(\frac{n}{8}\right) + (1+1+1) = ... = T\left(\frac{n}{2^{k}}\right)+(1\cdot k) $$
$$T(n)=T(1) + (1\cdot k) = c_{1} + (1\cdot k) ... | complexity theory recurrence relation binary search | 1 | Binary search algorithm - worst-case complexity -- (complexity theory recurrence relation binary search)
<p>I tried to calculate the worst case of binary search (not binary search tree). My calculations:
$$T(n) = T(\frac{n}{2}) + 1$$
$$T(n) = T\left(\frac{n}{4}\right) + (1+1) = T\left(\frac{n}{8}\right) + (1+1+... | habedi/stack-exchange-dataset |
67,390 | If X reduces to a problem in NP, is X in NP? | <p>Let $X$ and $Y$ be problems, and let $X \le_p Y$. Is it true that 
\begin{equation}
Y \in NP \rightarrow X \in NP\ ?
\end{equation}</p>

<p>I do mean $NP$ here, not $NP$-complete or $NP$-hard.</p>

<p>The solution is simple if the reduction from $X$ to $Y$ transforms an instance of $X$ t... | complexity theory | 1 | If X reduces to a problem in NP, is X in NP? -- (complexity theory)
<p>Let $X$ and $Y$ be problems, and let $X \le_p Y$. Is it true that 
\begin{equation}
Y \in NP \rightarrow X \in NP\ ?
\end{equation}</p>

<p>I do mean $NP$ here, not $NP$-complete or $NP$-hard.</p>

<p>The solution is sim... | habedi/stack-exchange-dataset |
67,394 | Is Bounded Waiting satisfied for this 2 process Solution? | <p>This is my new post linked with my previous post. </p>

<p><a href="https://cs.stackexchange.com/questions/67240/is-bounded-waiting-satisfied-in-the-2-process-solution/67282">Is bounded waiting satisfied in the 2 Process Solution?</a></p>

<hr>

<p>The answer in that post was very useful and ... | operating systems synchronization deadlocks | 1 | Is Bounded Waiting satisfied for this 2 process Solution? -- (operating systems synchronization deadlocks)
<p>This is my new post linked with my previous post. </p>

<p><a href="https://cs.stackexchange.com/questions/67240/is-bounded-waiting-satisfied-in-the-2-process-solution/67282">Is bounded waiting satisfie... | habedi/stack-exchange-dataset |
67,396 | Why divide by $b-1$ when computing size of a tree | <p>In one of the lectures I went to, my professor stated that in order to determine the size of a search tree, we use the following formula: 
$$\frac{b^{d+1}-1}{b-1},$$
whee $b$ is the branching factor and $d$ is the depth of the tree in question. I would like to understand why we divide by $b-1$. I would have ... | trees search trees | 1 | Why divide by $b-1$ when computing size of a tree -- (trees search trees)
<p>In one of the lectures I went to, my professor stated that in order to determine the size of a search tree, we use the following formula: 
$$\frac{b^{d+1}-1}{b-1},$$
whee $b$ is the branching factor and $d$ is the depth of the tree in ... | habedi/stack-exchange-dataset |
67,406 | Does Deadlock imply Starvation | <p>If there is a deadlock between the processes does that mean that there is starvation also?</p>

<p>My Thinking:<br>
deadlock is no process using that resources , but starvation is like not giving chance to only that process so there is progress in starvation but not in deadlock<br>
Is my thinking rig... | operating systems synchronization process scheduling deadlocks | 1 | Does Deadlock imply Starvation -- (operating systems synchronization process scheduling deadlocks)
<p>If there is a deadlock between the processes does that mean that there is starvation also?</p>

<p>My Thinking:<br>
deadlock is no process using that resources , but starvation is like not giving chance to ... | habedi/stack-exchange-dataset |
67,407 | Find out duplicate number between 1 to N numbers | <p>I first saw this question on this website where I was trying on Java puzzles. </p>

<p>Here is the Question:-</p>

<pre><code>You are given in an ArrayList, 1 to N Numbers. For Example, 1,2,3,4,5. However, one of
the numbers is repeated twice. That is, in the form 1,2,3,4,2,5. Find the duplicate ... | algorithms java lists real numbers | 1 | Find out duplicate number between 1 to N numbers -- (algorithms java lists real numbers)
<p>I first saw this question on this website where I was trying on Java puzzles. </p>

<p>Here is the Question:-</p>

<pre><code>You are given in an ArrayList, 1 to N Numbers. For Example, 1,2,3,4,5. However, one of... | habedi/stack-exchange-dataset |
67,411 | Machine Learning - Data Pre-Processing | <p>I'm trying to do some non-linear predictions and am going to use a random forest with Sk-learn. However my question has to do with data pre-processing.</p>

<p>I'm planning on using minmaxscaler to normalize the temperature, wind, and humidity data...however I have two other variables class, and month. Class... | machine learning | 1 | Machine Learning - Data Pre-Processing -- (machine learning)
<p>I'm trying to do some non-linear predictions and am going to use a random forest with Sk-learn. However my question has to do with data pre-processing.</p>

<p>I'm planning on using minmaxscaler to normalize the temperature, wind, and humidity data... | habedi/stack-exchange-dataset |
67,420 | How to convert a decimal number to ASCII representation | <p>The question that was in my lecture notes said </p>

<pre><code> "Encode the decimal number 2370 in ASCII. " 
</code></pre>

<p>and the answer given there is </p>

<pre><code> 32 33 37 30 (ASCII code representation)
</code></pre>

<p>My question is how do we get this? D... | number formats | 1 | How to convert a decimal number to ASCII representation -- (number formats)
<p>The question that was in my lecture notes said </p>

<pre><code> "Encode the decimal number 2370 in ASCII. " 
</code></pre>

<p>and the answer given there is </p>

<pre><code> 32 33 37 30 (ASCII code repres... | habedi/stack-exchange-dataset |
67,451 | Shortest walk through a given subset of edges | <p>Given an undirected weighted graph $G = (V, \{E,F\})$, how to find the shortest walk that passes through all edges $e \in E$ exactly once?</p>

<hr>

<p>I'd like to know if there is a general approach to this problem. However, additional constraint may be added for my specific scenario.</p>

... | graphs optimization shortest path weighted graphs | 1 | Shortest walk through a given subset of edges -- (graphs optimization shortest path weighted graphs)
<p>Given an undirected weighted graph $G = (V, \{E,F\})$, how to find the shortest walk that passes through all edges $e \in E$ exactly once?</p>

<hr>

<p>I'd like to know if there is a general approach... | habedi/stack-exchange-dataset |
67,455 | Having trouble in understanding the definition of a clique | <p>My definition says</p>

<blockquote>
 <p>A clique is a graph that has an edge connecting every pair of vertices</p>
</blockquote>

<p>but as I understand, an edge connects only two vertices. Like <span class="math-container">$A-B$</span>.</p>

<p>If we want to connect three vertices,... | graphs clique | 1 | Having trouble in understanding the definition of a clique -- (graphs clique)
<p>My definition says</p>

<blockquote>
 <p>A clique is a graph that has an edge connecting every pair of vertices</p>
</blockquote>

<p>but as I understand, an edge connects only two vertices. Like <span class="math-... | habedi/stack-exchange-dataset |
67,459 | Converting If-else condition to Linear Programming | <p>I have a constraint in a linear programming formulation with two variables: $X \ge Y$</p>

<p>To which I want to apply the following if-else conditions:</p>

<pre><code>if Y=1:
 X=1
else:
 X=0
</code></pre>

<p>Where $X$ and $Y$ are binary.</p>

<p>How can I fit ... | linear programming integer programming | 1 | Converting If-else condition to Linear Programming -- (linear programming integer programming)
<p>I have a constraint in a linear programming formulation with two variables: $X \ge Y$</p>

<p>To which I want to apply the following if-else conditions:</p>

<pre><code>if Y=1:
 X=1
else:
 ... | habedi/stack-exchange-dataset |
67,474 | Efficient algorithm to find all distances to a specific node in a tree | <p>I wish to calculate the number of nodes within a certain distance of a particular node in a tree such as the one below:</p>

<p><a href="https://i.stack.imgur.com/4A60H.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/4A60H.png" alt="a tree"></a></p>

<p>Let's assume I'm looking for... | time complexity trees graph traversal | 1 | Efficient algorithm to find all distances to a specific node in a tree -- (time complexity trees graph traversal)
<p>I wish to calculate the number of nodes within a certain distance of a particular node in a tree such as the one below:</p>

<p><a href="https://i.stack.imgur.com/4A60H.png" rel="nofollow norefer... | habedi/stack-exchange-dataset |
67,480 | Is detecting easy instances of NP-hard problems easy? | <p>My question is the following. Assume that $\Pi$ is an NP-hard problem. Given an arbitrary instance $I$ of $\Pi$ and assume that an adversary knows that this instance is easy to solve, is it possible to find a deterministic polynomial-time algorithm to solve this particular instance $I$?</p>

<p>For example: ... | complexity theory np complete np hard np p vs np | 1 | Is detecting easy instances of NP-hard problems easy? -- (complexity theory np complete np hard np p vs np)
<p>My question is the following. Assume that $\Pi$ is an NP-hard problem. Given an arbitrary instance $I$ of $\Pi$ and assume that an adversary knows that this instance is easy to solve, is it possible to find a ... | habedi/stack-exchange-dataset |
67,484 | How do we know that the reduction is correct? | <p>I'm having a really difficult time understanding the logic behind reduction of the halting problems to other problems in order to prove them undecidable.</p>

<p>Here's my reasoning:</p>

<p>Let's say that we want to find out if the following problem is decidable: given any machine $M$ and a string $... | computability reductions undecidability proof techniques halting problem | 1 | How do we know that the reduction is correct? -- (computability reductions undecidability proof techniques halting problem)
<p>I'm having a really difficult time understanding the logic behind reduction of the halting problems to other problems in order to prove them undecidable.</p>

<p>Here's my reasoning:</p... | habedi/stack-exchange-dataset |
67,485 | Data-flow analysis problem adjust to Ullman-Aho's framework? | <p>I am reading the classical book "Compilers. Principles, techniques and tools" by Aho et alii. On chapter 9.3 they talk about a general framework to solve data-flow analysis problems that use a framework which is monotone and of finite height. </p>

<p>The technique is shown to be useful for live variable and... | compilers lattices data flow analysis | 1 | Data-flow analysis problem adjust to Ullman-Aho's framework? -- (compilers lattices data flow analysis)
<p>I am reading the classical book "Compilers. Principles, techniques and tools" by Aho et alii. On chapter 9.3 they talk about a general framework to solve data-flow analysis problems that use a framework which is m... | habedi/stack-exchange-dataset |
67,487 | What algorithm to find end state probabilities | <p>I need help identifying what algorithm I need to solve a problem. I'm not asking for programming help here, just identifying the algorithm.</p>

<p>Each row of a matrix represents a state. Each element corresponds to the count of how often the current state transitions to another state. Some states are final... | algorithms | 1 | What algorithm to find end state probabilities -- (algorithms)
<p>I need help identifying what algorithm I need to solve a problem. I'm not asking for programming help here, just identifying the algorithm.</p>

<p>Each row of a matrix represents a state. Each element corresponds to the count of how often the cu... | habedi/stack-exchange-dataset |
67,494 | Computing all possible partial sum-function of a given set of numbers | <p>Let there be $N$ positive numbers given as $\lambda_1\geq\dots\geq\lambda_N$. Now I am interested in the following numbers given as $$\alpha_i=\exp(\frac{\lambda_i}{\lambda})$$ for some positive constant $\lambda$. Define the function $\mathcal{S}(..)$ which takes a subset of these numbers (let me call me them as a ... | algorithms | 1 | Computing all possible partial sum-function of a given set of numbers -- (algorithms)
<p>Let there be $N$ positive numbers given as $\lambda_1\geq\dots\geq\lambda_N$. Now I am interested in the following numbers given as $$\alpha_i=\exp(\frac{\lambda_i}{\lambda})$$ for some positive constant $\lambda$. Define the funct... | habedi/stack-exchange-dataset |
67,499 | One element that differs in two arrays. How to find it efficiently? | <p>I am preparing for a coding interview and I can't really figure out the most efficient way to solve this problem.</p>

<p>Let's say we have two arrays consisting of numbers that are unsorted. Array 2 contains a number that Array 1 does not. Both arrays have randomly located numbers, not necessarily in the sa... | algorithms search algorithms arrays efficiency | 1 | One element that differs in two arrays. How to find it efficiently? -- (algorithms search algorithms arrays efficiency)
<p>I am preparing for a coding interview and I can't really figure out the most efficient way to solve this problem.</p>

<p>Let's say we have two arrays consisting of numbers that are unsorte... | habedi/stack-exchange-dataset |
67,513 | Converting any computable function into a sequence of additions | <p>Not sure if this question should be here, or on <a href="http://math.stackexchange.com">math.se</a>.</p>

<p>That said, let me proceed:</p>

<p>On the <a href="https://en.wikipedia.org/wiki/Ackermann_function" rel="nofollow noreferrer">Wikipedia page for the Ackermann function</a>, it is mentioned th... | algorithms computability | 1 | Converting any computable function into a sequence of additions -- (algorithms computability)
<p>Not sure if this question should be here, or on <a href="http://math.stackexchange.com">math.se</a>.</p>

<p>That said, let me proceed:</p>

<p>On the <a href="https://en.wikipedia.org/wiki/Ackermann_functio... | habedi/stack-exchange-dataset |
67,520 | Algorithm to detect if word belongs to pushdown automaton | <p>I am creating a simple program to detect if the given pushdown automaton accepts the given word, and I have a problem in finding an algorithm that does that. </p>

<p>My thought at first would be to go through all possible transitions, and check if we didn't match this word in accepting state, but got in pro... | algorithms automata search algorithms pushdown automata | 1 | Algorithm to detect if word belongs to pushdown automaton -- (algorithms automata search algorithms pushdown automata)
<p>I am creating a simple program to detect if the given pushdown automaton accepts the given word, and I have a problem in finding an algorithm that does that. </p>

<p>My thought at first wou... | habedi/stack-exchange-dataset |
67,522 | Algorithm to get maximal selection set of a collection of sets with a binary relation | <p>I have a finite collection of finite sets $\{A_i\}_{i \in I}$. There is a relation $R$ defined on the elements of those sets (which is not transitive, it is irreflexive, and it is symetric). Suppose we define a <em>related partial choice</em> as a set $\{a_j\}_{j\in J}$ such that: </p>

<ol>
<li>$J\subs... | algorithms sets clique finite sets | 1 | Algorithm to get maximal selection set of a collection of sets with a binary relation -- (algorithms sets clique finite sets)
<p>I have a finite collection of finite sets $\{A_i\}_{i \in I}$. There is a relation $R$ defined on the elements of those sets (which is not transitive, it is irreflexive, and it is symetric).... | habedi/stack-exchange-dataset |
67,523 | recursive algorithm to find the max sum of 2 numbers | <p>I am looking for a recursive algorithm to find the max sum of 2 numbers in an array, and the numbers can't be "neighbours" ( for example $a[0]$ and $a[1]$ or $a[4]$ and $a[5]$, in general $a[i]$ and $a[i+1]$ )</p>

<p>example:
for the array 5 8 3 9 20 1 4,
the result will be 28. </p>
 | algorithms arrays | 1 | recursive algorithm to find the max sum of 2 numbers -- (algorithms arrays)
<p>I am looking for a recursive algorithm to find the max sum of 2 numbers in an array, and the numbers can't be "neighbours" ( for example $a[0]$ and $a[1]$ or $a[4]$ and $a[5]$, in general $a[i]$ and $a[i+1]$ )</p>

<p>example:
fo... | habedi/stack-exchange-dataset |
67,526 | How can a probability distribution across classical states be computed for the measurement of a Quantum State represented by a Complex Vector? | <p>Suppose I have a quantum state represented by a Complex vector, arbitrarily:</p>

<p>$[~-0.538, 0.044 - 0.323i, 0.706, 0.044 + 0.323i~]$</p>

<p>With each value in that vector corresponding to some classical state:</p>

<p>$[~ |00\rangle, |01\rangle, |10\rangle, |11\rangle ~]$</p>

<p... | quantum computing | 1 | How can a probability distribution across classical states be computed for the measurement of a Quantum State represented by a Complex Vector? -- (quantum computing)
<p>Suppose I have a quantum state represented by a Complex vector, arbitrarily:</p>

<p>$[~-0.538, 0.044 - 0.323i, 0.706, 0.044 + 0.323i~]$</p>&#x... | habedi/stack-exchange-dataset |
67,533 | Description of lists with functions in LISP | <p>I have been given the following implementation of basic list functions in LISP:</p>

<pre><code>nil = (lambda (k) (k ’none ’none))
(cons x y) = (lambda (k) (k x y))
(car l) = (l (lambda (x y) x))
(cdr l) = (l (lambda (x y) y))
(null? l) = (l (lambda (x y) (= x ’none)))
</code></pre>
&... | functional programming lists lisp | 1 | Description of lists with functions in LISP -- (functional programming lists lisp)
<p>I have been given the following implementation of basic list functions in LISP:</p>

<pre><code>nil = (lambda (k) (k ’none ’none))
(cons x y) = (lambda (k) (k x y))
(car l) = (l (lambda (x y) x))
(cdr l) = (l (lamb... | habedi/stack-exchange-dataset |
67,537 | How does size of a number in an array affect time complexity algorithm analysis? | <p>This question stems from <a href="https://cs.stackexchange.com/q/67499/22046">this</a> question and <a href="https://cs.stackexchange.com/a/67503/22046">this</a> answer. I also want to preface this question by stating that this question is done from the perspective of a RAM (or PRAM if it's more accurate term) model... | algorithms algorithm analysis runtime analysis search algorithms computation models | 1 | How does size of a number in an array affect time complexity algorithm analysis? -- (algorithms algorithm analysis runtime analysis search algorithms computation models)
<p>This question stems from <a href="https://cs.stackexchange.com/q/67499/22046">this</a> question and <a href="https://cs.stackexchange.com/a/67503/2... | habedi/stack-exchange-dataset |
67,538 | Do cryptographic hash function solve clustering problems with linear probing? | <p>I understand in open addressing hash tables some clustering will always happen just by random chance, even if the input data is perfectly random, leading to some "best possible" lookup performance hit (for an open addressing scheme).</p>

<p>If the hash function is of low quality, and we use linear or quadra... | cryptography hash hash tables | 1 | Do cryptographic hash function solve clustering problems with linear probing? -- (cryptography hash hash tables)
<p>I understand in open addressing hash tables some clustering will always happen just by random chance, even if the input data is perfectly random, leading to some "best possible" lookup performance hit (fo... | habedi/stack-exchange-dataset |
67,554 | Enumerating the set of polynomial time Turing machines | <p>I was checking <a href="https://cs.stackexchange.com/questions/3101/is-the-set-of-turing-machines-which-stop-in-at-most-50-steps-on-all-inputs-deci">this question</a> and wondered how to apply it to the following language to prove it is in $RE$:
$$ L = \{ \langle M \rangle : \exists P \text{ such that } M \text{... | computability turing machines undecidability | 1 | Enumerating the set of polynomial time Turing machines -- (computability turing machines undecidability)
<p>I was checking <a href="https://cs.stackexchange.com/questions/3101/is-the-set-of-turing-machines-which-stop-in-at-most-50-steps-on-all-inputs-deci">this question</a> and wondered how to apply it to the following... | habedi/stack-exchange-dataset |
67,555 | Lambda calculus lists construction explanation | <p>I have the following notes that introduce how lambda calculus handles lists. They go as follows:</p>
<blockquote>
<p>A list is something we can match on and deconstruct if it is not
empty:</p>
<pre><code>list match{
 case Nil => M
 case Cons(x,y) => N(x,y)
}
</code></pre>
<p... | lambda calculus lists | 1 | Lambda calculus lists construction explanation -- (lambda calculus lists)
<p>I have the following notes that introduce how lambda calculus handles lists. They go as follows:</p>
<blockquote>
<p>A list is something we can match on and deconstruct if it is not
empty:</p>
<pre><code>list match{
 case N... | habedi/stack-exchange-dataset |
67,560 | How reducing languages work? | <p>I am reading Automata Theory book by Hopcroft, Motwani and Ullman 2nd ed.
In this book, there are these sentences:</p>

<blockquote>
 <p>In general, if we have an algorithm to convert instances of a problem $P_1$ to instances of a problem $P_2$ that have the same answer, then we say that $P_1$ * red... | automata undecidability | 1 | How reducing languages work? -- (automata undecidability)
<p>I am reading Automata Theory book by Hopcroft, Motwani and Ullman 2nd ed.
In this book, there are these sentences:</p>

<blockquote>
 <p>In general, if we have an algorithm to convert instances of a problem $P_1$ to instances of a problem $P_... | habedi/stack-exchange-dataset |
67,568 | NP-completeness of DISCONNECTED-SET | <p>I'd like to show that the language DISCONNECTED-SET, defined by $$ \{\langle G, k\rangle | \text{$G$ is an undirected graph that contains a disconnected set of size $k$}\},$$ is NP-complete. (A <em>disconnected set</em> $S$ is defined as a set of vertices such that for every pair of vertices $u,v \in G$, if there is... | complexity theory np complete np hard | 1 | NP-completeness of DISCONNECTED-SET -- (complexity theory np complete np hard)
<p>I'd like to show that the language DISCONNECTED-SET, defined by $$ \{\langle G, k\rangle | \text{$G$ is an undirected graph that contains a disconnected set of size $k$}\},$$ is NP-complete. (A <em>disconnected set</em> $S$ is defined as ... | habedi/stack-exchange-dataset |
67,579 | Does a time quantum affect priority non preemptive scheduling? | <p>I am given a list of processes with their arrival time, CPU, time and Priority. The time quantum is given as 2 seconds. A <strong>lower</strong> priority number translates to a <strong>higher</strong> priority. </p>

<p>(process #, arrival time, CPU time, Priority)</p>

<p>-P0: 0, 8, 5</p>

<... | process scheduling | 1 | Does a time quantum affect priority non preemptive scheduling? -- (process scheduling)
<p>I am given a list of processes with their arrival time, CPU, time and Priority. The time quantum is given as 2 seconds. A <strong>lower</strong> priority number translates to a <strong>higher</strong> priority. </p>

<p>(p... | habedi/stack-exchange-dataset |
67,586 | Is the given grammar LL(2)? | <p><a href="http://dickgrune.com/Books/PTAPG_1st_Edition/BookBody.pdf" rel="nofollow noreferrer">http://dickgrune.com/Books/PTAPG_1st_Edition/BookBody.pdf</a></p>

<p>The book by Grune and Jacobs presents an example of a grammar that is $LL(K + 1)$ but not $LL(K)$</p>

<p>The example is $S -> a^kb/a^... | automata formal grammars compilers parsers | 1 | Is the given grammar LL(2)? -- (automata formal grammars compilers parsers)
<p><a href="http://dickgrune.com/Books/PTAPG_1st_Edition/BookBody.pdf" rel="nofollow noreferrer">http://dickgrune.com/Books/PTAPG_1st_Edition/BookBody.pdf</a></p>

<p>The book by Grune and Jacobs presents an example of a grammar that is... | habedi/stack-exchange-dataset |
67,589 | Where we Use Dynamic Programming and Greedy Algorithm? | <p>Can someone tell me where we use Dynamic/Greedy algorithm and how we trace from the question that it will solved by any one of the above?</p>

<p>Thanks </p>
 | algorithms dynamic programming greedy algorithms | 1 | Where we Use Dynamic Programming and Greedy Algorithm? -- (algorithms dynamic programming greedy algorithms)
<p>Can someone tell me where we use Dynamic/Greedy algorithm and how we trace from the question that it will solved by any one of the above?</p>

<p>Thanks </p>
 | habedi/stack-exchange-dataset |
67,599 | Claimed problems with Lisp dynamic scoping | <p>What would be the problem of running the following scala codes assuming we are working with dynamic scoping and a global stack to store environments as some variants of Lisp do?</p>

<pre><code>def fact(n:Int,f:() => Int):Int = 
 if(n == 0) f()
 else fact(n-1,() => n*f())
fact(7,() => 1)... | stacks variable binding lisp | 1 | Claimed problems with Lisp dynamic scoping -- (stacks variable binding lisp)
<p>What would be the problem of running the following scala codes assuming we are working with dynamic scoping and a global stack to store environments as some variants of Lisp do?</p>

<pre><code>def fact(n:Int,f:() => Int):Int = &... | habedi/stack-exchange-dataset |
67,603 | Algorithm for finding largest subset with equal number of even and odd elements | <blockquote>
 <p>A sequence of positive integers $a_1, ..., a_n$ is given. Compute the
 length of the largest continuous subsequence such that the number of
 even integers is equal to the number of odd integers in the subsequence.</p>
</blockquote>

<p>I have thought that we could take all th... | algorithms | 1 | Algorithm for finding largest subset with equal number of even and odd elements -- (algorithms)
<blockquote>
 <p>A sequence of positive integers $a_1, ..., a_n$ is given. Compute the
 length of the largest continuous subsequence such that the number of
 even integers is equal to the number of odd integer... | habedi/stack-exchange-dataset |
67,632 | Linear programming, Checking a constraint based on condition | <p>I have a constraint $X \ge Y$ in a Linear programming formulation, where both $X$ and $Y$ are binary. I want to check this constraint on a condition like:</p>

<pre><code>if (Y==1)
 then check the constraint
else
 Don't care about the constraint
</code></pre>

<p>How to do i... | linear programming integer programming | 1 | Linear programming, Checking a constraint based on condition -- (linear programming integer programming)
<p>I have a constraint $X \ge Y$ in a Linear programming formulation, where both $X$ and $Y$ are binary. I want to check this constraint on a condition like:</p>

<pre><code>if (Y==1)
 then check th... | habedi/stack-exchange-dataset |
67,634 | Given a set C of set P of sets R, find the smallest set S such that at least one subset R from each P is a subset of S | <p>Given a universal set of elements $\mathbf{U} = \{a_1, a_2, .., a_n\}$, a set $\mathbf{R} = \{a_i\} \subset \mathbf{U}$ where $i ϵ \{1, .., n\}$, a set $\mathbf{P} = \{R_1, .., R_m\}$ and a set $\mathbf{C} = \{P_1, P_2, .., P_l\}$, how do I go about finding a set $\mathbf{S} = \{a_1, .., a_n\} \subset \mathbf{U}$ su... | algorithms set cover | 1 | Given a set C of set P of sets R, find the smallest set S such that at least one subset R from each P is a subset of S -- (algorithms set cover)
<p>Given a universal set of elements $\mathbf{U} = \{a_1, a_2, .., a_n\}$, a set $\mathbf{R} = \{a_i\} \subset \mathbf{U}$ where $i ϵ \{1, .., n\}$, a set $\mathbf{P} = \{R_1,... | habedi/stack-exchange-dataset |
67,637 | Equivalent DPDA that always halts for every DPDA with empty stack language | <p>I want to show that for every deterministic pushdown automaton with the language of the empty stack there is a deterministic pushdown automaton that always halts.
my transition function of $P$ is</p>

<p>$\delta: \Gamma \times Q \times \Sigma_\lambda \to \Gamma^* \times Q$</p>

<p>I tried to use ... | automata pushdown automata simulation | 1 | Equivalent DPDA that always halts for every DPDA with empty stack language -- (automata pushdown automata simulation)
<p>I want to show that for every deterministic pushdown automaton with the language of the empty stack there is a deterministic pushdown automaton that always halts.
my transition function of $P$ is... | habedi/stack-exchange-dataset |
67,664 | PRNG for generating numbers with n set bits exactly | <p>I'm currently writing some code to generate binary data. I specifically need to generate 64-bit numbers with a given number of set bits; more precisely, the procedure should take some $0 < n < 64$ and return a pseudo-random 64-bit number with exactly $n$ bits set to $1$, and the rest set to 0.</p>

<p>... | algorithms information theory coding theory pseudo random generators | 1 | PRNG for generating numbers with n set bits exactly -- (algorithms information theory coding theory pseudo random generators)
<p>I'm currently writing some code to generate binary data. I specifically need to generate 64-bit numbers with a given number of set bits; more precisely, the procedure should take some $0 <... | habedi/stack-exchange-dataset |
67,665 | Pushdown automaton accepting $\{a,b\}^*$ with twice as many $a$s as $b$s | <p>Design a pushdown automaton that can accept</p>

<blockquote>
 <p>$$\{w|w\in\{a,b\}^*\text{ and $w$ has twice as many $a$s as $b$s}\} \, .$$</p>
</blockquote>

<p>I have a solution as the following. The notation seems to follow "An Introduction to Formal Languages and Automaton" by Peter Li... | formal languages automata | 1 | Pushdown automaton accepting $\{a,b\}^*$ with twice as many $a$s as $b$s -- (formal languages automata)
<p>Design a pushdown automaton that can accept</p>

<blockquote>
 <p>$$\{w|w\in\{a,b\}^*\text{ and $w$ has twice as many $a$s as $b$s}\} \, .$$</p>
</blockquote>

<p>I have a solution as the ... | habedi/stack-exchange-dataset |
67,679 | Countably many oracle Turing machines? | <p>In Sipser's text, when proving that there exists an oracle $A$ such that $P^A \ne NP^A$, he writes:</p>

<blockquote>
 <p>Let $M_1, M_2, \ldots$ be a list of all polynomial time oracle TMs.</p>
</blockquote>

<p>I understand that there are countably many Turing machines, but aren't there unc... | complexity theory turing machines oracle machines | 1 | Countably many oracle Turing machines? -- (complexity theory turing machines oracle machines)
<p>In Sipser's text, when proving that there exists an oracle $A$ such that $P^A \ne NP^A$, he writes:</p>

<blockquote>
 <p>Let $M_1, M_2, \ldots$ be a list of all polynomial time oracle TMs.</p>
</blockquote... | habedi/stack-exchange-dataset |
67,681 | Extracting Randomness from Mouse Acceleration | <p>I'm working on trying to make an "entropy pool" that will be fed as input into an RNG (as in, ex, Fortuna). In order to do so, I need to take various collected data and extract as much entropy as possible to turn it into unpredictable bits. I've read many papers about extracting randomness, but I haven't understood ... | reference request randomness entropy | 1 | Extracting Randomness from Mouse Acceleration -- (reference request randomness entropy)
<p>I'm working on trying to make an "entropy pool" that will be fed as input into an RNG (as in, ex, Fortuna). In order to do so, I need to take various collected data and extract as much entropy as possible to turn it into unpredic... | habedi/stack-exchange-dataset |
67,684 | Does a byte contain 8 bits, or 9? | <p>I read in <a href="https://www.tutorialspoint.com/assembly_programming/assembly_introduction.htm">this assembly programming tutorial</a> that 8 bits are used for data while 1 bit is for parity, which is then used for detecting parity error (caused by hardware fault or electrical disturbance).</p>

<p>Is this... | computer architecture numeral representations | 1 | Does a byte contain 8 bits, or 9? -- (computer architecture numeral representations)
<p>I read in <a href="https://www.tutorialspoint.com/assembly_programming/assembly_introduction.htm">this assembly programming tutorial</a> that 8 bits are used for data while 1 bit is for parity, which is then used for detecting parit... | habedi/stack-exchange-dataset |
67,690 | Is a unary language regular iff its exponent is a linear function? | <p>While doing the current assignment for my formal languages and automata course, I kind of got stuck on exercises involving unary languages (I hope that's the right term), i.e., languages which build upon a single letter. I don't want to ask about the specific exercises, though, but rather about a much more general c... | formal languages regular languages | 1 | Is a unary language regular iff its exponent is a linear function? -- (formal languages regular languages)
<p>While doing the current assignment for my formal languages and automata course, I kind of got stuck on exercises involving unary languages (I hope that's the right term), i.e., languages which build upon a sing... | habedi/stack-exchange-dataset |
67,693 | Comparison using only bitwise operators (and return -1 or 0) | <p>I have to use only bitwise operators to compare two numbers (represented in two's complement), and return $-1$ (represented by all $1$'s) if the numbers aren't equal or return $0$ (represented by all $0$'s) otherwise.</p>

<p>Say $a$ and $b$ are $W$ bits long ($W$ is not necessarily $2^n$). I find it easy to... | algorithms | 1 | Comparison using only bitwise operators (and return -1 or 0) -- (algorithms)
<p>I have to use only bitwise operators to compare two numbers (represented in two's complement), and return $-1$ (represented by all $1$'s) if the numbers aren't equal or return $0$ (represented by all $0$'s) otherwise.</p>

<p>Say $a... | habedi/stack-exchange-dataset |
67,695 | Chaitin's constant is normal? | <p>According to this source, Chaitin's constant $\Omega$ is normal.</p>

<blockquote>
 <p>Each halting probability is a normal and transcendental real number that is not computable, which means that there is no algorithm to compute its digits. Indeed, each halting probability is Martin-Löf random, meaning ... | halting problem | 1 | Chaitin's constant is normal? -- (halting problem)
<p>According to this source, Chaitin's constant $\Omega$ is normal.</p>

<blockquote>
 <p>Each halting probability is a normal and transcendental real number that is not computable, which means that there is no algorithm to compute its digits. Indeed, each... | habedi/stack-exchange-dataset |
67,722 | Rice–Shapiro theorem in computation theory | <p>I am trying to learn the <a href="https://en.wikipedia.org/wiki/Rice%E2%80%93Shapiro_theorem" rel="nofollow noreferrer">Rice–Shapiro theorem</a> on my own. Here is the theorem:</p>

<blockquote>
 <p>Let $Γ$ be a set of computable functions such that the set $R_Γ$ is recursively enumerable. We have $f ∈ ... | computability | 1 | Rice–Shapiro theorem in computation theory -- (computability)
<p>I am trying to learn the <a href="https://en.wikipedia.org/wiki/Rice%E2%80%93Shapiro_theorem" rel="nofollow noreferrer">Rice–Shapiro theorem</a> on my own. Here is the theorem:</p>

<blockquote>
 <p>Let $Γ$ be a set of computable functions su... | habedi/stack-exchange-dataset |
67,727 | Does a greedy strategy exist for this instance of the Bin Packing Problem? | <p>I was wondering whether I can solve the following problem by using a greedy strategy: Let's say that I have a set of containers with 2 dimensions (width and height) and a set of items also with 2 dimensions. Can a solution be found where each item is assigned to a container so that it fits inside? I can have contain... | greedy algorithms packing | 1 | Does a greedy strategy exist for this instance of the Bin Packing Problem? -- (greedy algorithms packing)
<p>I was wondering whether I can solve the following problem by using a greedy strategy: Let's say that I have a set of containers with 2 dimensions (width and height) and a set of items also with 2 dimensions. Can... | habedi/stack-exchange-dataset |
67,746 | Determining if an integer appears more than $n/2$ times | <blockquote>
 <p>What is the minimum number of comparisons required to determine if an integer appears more than $n/2$ times in a sorted array of $n$ integers?</p>
</blockquote>

<p>I am trying binary search on the array A.</p>

<p>Algorithm(A): </p>

<ol>
<li>x = A[mid], where mid ... | algorithms algorithm analysis lower bounds | 1 | Determining if an integer appears more than $n/2$ times -- (algorithms algorithm analysis lower bounds)
<blockquote>
 <p>What is the minimum number of comparisons required to determine if an integer appears more than $n/2$ times in a sorted array of $n$ integers?</p>
</blockquote>

<p>I am trying binar... | habedi/stack-exchange-dataset |
67,748 | Finding optimal set for a sum of a product function over a 2D lattice | <p>Given a 2D lattice with coordinates $1 \leq x \leq c$ and $1 \leq y \leq d$, we define $f(x, y) = xy$. </p>

<p>We wish to find a boolean function $I(x,y)$ that determines in $O(1)$ time whether or not $(x,y)$ belongs to the set of points $S$ of size $k$ such that the sum $Z(S) = \sum_{(x,y) \in S} f(x,y)$ i... | lattices | 1 | Finding optimal set for a sum of a product function over a 2D lattice -- (lattices)
<p>Given a 2D lattice with coordinates $1 \leq x \leq c$ and $1 \leq y \leq d$, we define $f(x, y) = xy$. </p>

<p>We wish to find a boolean function $I(x,y)$ that determines in $O(1)$ time whether or not $(x,y)$ belongs to the ... | habedi/stack-exchange-dataset |
67,754 | How to compare two circular sequences in linear time? | <p>We have two circular sequences, which means there is no start or end in the sequences, how to test if two sequence are equal or not in linear time? I have two circular sequences of E. Coli bacteria with length (4,639,221). I thought about attaching two sample of the first sequence and find the other one in it in lin... | algorithms time complexity | 1 | How to compare two circular sequences in linear time? -- (algorithms time complexity)
<p>We have two circular sequences, which means there is no start or end in the sequences, how to test if two sequence are equal or not in linear time? I have two circular sequences of E. Coli bacteria with length (4,639,221). I though... | habedi/stack-exchange-dataset |
67,755 | Simple Recognition Algorithm, How Does It Work? | <p>I am trying to understand how a simple image recognition of an image with dynamic size could work. What I have seen is that parts of the images are taken and evaluated. For example a simple finger recognition could be done turning the image grayscale, taking parts of the image and evaluating them. What I understand ... | machine learning image processing pattern recognition | 1 | Simple Recognition Algorithm, How Does It Work? -- (machine learning image processing pattern recognition)
<p>I am trying to understand how a simple image recognition of an image with dynamic size could work. What I have seen is that parts of the images are taken and evaluated. For example a simple finger recognition c... | habedi/stack-exchange-dataset |
67,763 | What is this type of consistency called in DataRetrieval? | <p>I am trying to find the name of this feature that is implemented with SQL Databases:</p>

<p>Given a Record $R^1$ in table having two values for two different fields, e.g. 
Let value of field 1 $F_1$ be $V_1$, Let value of field 2 $F_2$ be $V_2$
A any query requiring records s.t. $F_1 = V_1$ should c... | database theory | 1 | What is this type of consistency called in DataRetrieval? -- (database theory)
<p>I am trying to find the name of this feature that is implemented with SQL Databases:</p>

<p>Given a Record $R^1$ in table having two values for two different fields, e.g. 
Let value of field 1 $F_1$ be $V_1$, Let value of fie... | habedi/stack-exchange-dataset |
67,773 | Restrictions to counter machines capturing LBA | <p>As you know in computation theory, there is a simple programming language equivalent in power to Turing machines. It is described as follows:</p>

<p>Values: natural numbers only, but of unlimited precision.</p>

<p>• Variables:</p>

<p>– Input variables X1, X2, X3, . . . </p>

<p>– A... | computability turing machines linear bounded automata | 1 | Restrictions to counter machines capturing LBA -- (computability turing machines linear bounded automata)
<p>As you know in computation theory, there is a simple programming language equivalent in power to Turing machines. It is described as follows:</p>

<p>Values: natural numbers only, but of unlimited precis... | habedi/stack-exchange-dataset |
67,774 | Which part of Go(lang) is in Crystal(lang)? | <p>Reading <a href="https://en.wikipedia.org/wiki/Crystal_(programming_language)" rel="nofollow noreferrer">Crystal Programming Language</a> They says it is inspired from many programming language and Go.</p>

<p>I would like too know which part of Golang, since it is not its syntax.</p>
 | programming languages syntax | 1 | Which part of Go(lang) is in Crystal(lang)? -- (programming languages syntax)
<p>Reading <a href="https://en.wikipedia.org/wiki/Crystal_(programming_language)" rel="nofollow noreferrer">Crystal Programming Language</a> They says it is inspired from many programming language and Go.</p>

<p>I would like too know... | habedi/stack-exchange-dataset |
67,776 | Approximation with imperfect dichotomy oracle | <p>Given an unknown $x$ and an oracle $O(r)$ such that:</p>

<ol>
<li>If $O(r)$ is true then $x \geq r$.</li>
<li>If $O(r)$ is false then $x < 2r$.</li>
</ol>

<p>Conversely, the oracle has a defined behaviour only outside the interval $(x/2, x]$, and may output anything between.</p>
... | algorithms search algorithms approximation binary search | 1 | Approximation with imperfect dichotomy oracle -- (algorithms search algorithms approximation binary search)
<p>Given an unknown $x$ and an oracle $O(r)$ such that:</p>

<ol>
<li>If $O(r)$ is true then $x \geq r$.</li>
<li>If $O(r)$ is false then $x < 2r$.</li>
</ol>

<p>Conversely, the or... | habedi/stack-exchange-dataset |
67,784 | Finding proper subsequence | <p>I'm preparing for CS201 exam and I stumbled upon an interesting problem.</p>

<p>Input: 
A sequence of random positive and negative integers (up to 1.0000).</p>

<p>Output:
A <strong>contiguous (to be clear: subsequence of consecutive elements)</strong> subsequence of the original sequence, s... | algorithms | 1 | Finding proper subsequence -- (algorithms)
<p>I'm preparing for CS201 exam and I stumbled upon an interesting problem.</p>

<p>Input: 
A sequence of random positive and negative integers (up to 1.0000).</p>

<p>Output:
A <strong>contiguous (to be clear: subsequence of consecutive elements)</stro... | habedi/stack-exchange-dataset |
67,788 | A nim game variant with pass move | <p>This variant is almost similar to the normal nim game which states - </p>

<blockquote>
 <p>Two players take turns to remove one or more items from a single, non-empty pile. The player who removes the last item from the last non-empty pile is declared as a winner.</p>
</blockquote>

<p>The t... | combinatorics game theory board games | 1 | A nim game variant with pass move -- (combinatorics game theory board games)
<p>This variant is almost similar to the normal nim game which states - </p>

<blockquote>
 <p>Two players take turns to remove one or more items from a single, non-empty pile. The player who removes the last item from the last no... | habedi/stack-exchange-dataset |
67,795 | Running time for Testing Polygonal Neighbours for Intersection or Inclusion | <p>I was reading this paper by Shamos, M.I, on "Geometric Intersection Problems" (<a href="http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.366.9983&rep=rep1&type=pdf" rel="nofollow noreferrer">http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.366.9983&rep=rep1&type=pdf</a>) , and was tr... | time complexity asymptotics computational geometry polygons | 1 | Running time for Testing Polygonal Neighbours for Intersection or Inclusion -- (time complexity asymptotics computational geometry polygons)
<p>I was reading this paper by Shamos, M.I, on "Geometric Intersection Problems" (<a href="http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.366.9983&rep=rep1&type... | habedi/stack-exchange-dataset |
67,796 | Does deterministic imply algorithmic? | <p>I'm not exactly sure whether this question belongs to this SE or not, but it doesn't seem to fit elsewhere.</p>

<p>Say a process behaves in a deterministic fashion (that is, it gives the same output when an input is entered over and over again), then <strong>can we build it as an algorithm?</strong>; if not... | algorithms | 1 | Does deterministic imply algorithmic? -- (algorithms)
<p>I'm not exactly sure whether this question belongs to this SE or not, but it doesn't seem to fit elsewhere.</p>

<p>Say a process behaves in a deterministic fashion (that is, it gives the same output when an input is entered over and over again), then <st... | habedi/stack-exchange-dataset |
67,797 | Why theorem proving is hard? | <p>Every time I ask why most people think that P ≠ NP, I get a response like "because theorem proving is harder than proof checking". </p>

<p>From this, I understand that proving theorems is hard. But why is this? In fact, it is known that a <em>theorem</em>, in mathematics, is a statement that <em>has been pr... | complexity theory terminology | 1 | Why theorem proving is hard? -- (complexity theory terminology)
<p>Every time I ask why most people think that P ≠ NP, I get a response like "because theorem proving is harder than proof checking". </p>

<p>From this, I understand that proving theorems is hard. But why is this? In fact, it is known that a <em>t... | habedi/stack-exchange-dataset |
67,801 | Getting a tighter upper bound on the following function | <p>We have the following function which determines the Nth fibonacci number:</p>

<pre><code>int fib(int n){
 if(n<=0) return 0;
 else if (n==1) return 1;
 return fib(n-1)+ fib(n-2)

}
</code></pre>

<p>Find the time complexity </p>

<p>I am currently reading... | algorithms time complexity asymptotics | 1 | Getting a tighter upper bound on the following function -- (algorithms time complexity asymptotics)
<p>We have the following function which determines the Nth fibonacci number:</p>

<pre><code>int fib(int n){
 if(n<=0) return 0;
 else if (n==1) return 1;
 return fib(n-1)+ fib(n-2)
&#... | habedi/stack-exchange-dataset |
67,806 | Running Time of naive implementation of Dijkstra's Algorithm | <p>Here is the "naive" implementation of Dijkstra's algorithm that the professor uses:</p>
<blockquote>
<p>For a directed graph <span class="math-container">$G = (V,E)$</span> as input</p>
<p>Initialize:</p>
<ul>
<li><p><span class="math-container">$X = \{s\}$</span> (the vertices proces... | graphs shortest path | 1 | Running Time of naive implementation of Dijkstra's Algorithm -- (graphs shortest path)
<p>Here is the "naive" implementation of Dijkstra's algorithm that the professor uses:</p>
<blockquote>
<p>For a directed graph <span class="math-container">$G = (V,E)$</span> as input</p>
<p>Initialize:</p>
... | habedi/stack-exchange-dataset |
67,820 | Calculate $(u,v) \in \mathbb{R}$ so that $\sum (a_i + b_i)$ with $ a_i \geq u$ and $b_i \geq v$ maximizes | <p>I have two datasets $A$ and $B$:</p>

<p>$A = \{1, 5, -34, 34.34323, -23.5444, 9.43, ....\}$
$B = \{-0.5, 44, -0.243, -3455, 2.22221, -23.23, ....\}$</p>

<p>Those datasets contain a big amount of "random" numbers (They are actually not random, but their source does not matter for this question).... | algorithms | 1 | Calculate $(u,v) \in \mathbb{R}$ so that $\sum (a_i + b_i)$ with $ a_i \geq u$ and $b_i \geq v$ maximizes -- (algorithms)
<p>I have two datasets $A$ and $B$:</p>

<p>$A = \{1, 5, -34, 34.34323, -23.5444, 9.43, ....\}$
$B = \{-0.5, 44, -0.243, -3455, 2.22221, -23.23, ....\}$</p>

<p>Those datasets co... | habedi/stack-exchange-dataset |
67,826 | Sorting an array of length $n$ with $k$ distinct elements | <p>There is an integer array that contain $n$ numbers, in the array there are $k$ distinct elements up to $k = 50$.<br>
Is it possible to sort this array in linear time, by using only comparisons?</p>

<p>I know that comparison sorts cannot perform better than $\mathcal O(n\log n)$, so maybe I have to show ... | algorithms sorting | 1 | Sorting an array of length $n$ with $k$ distinct elements -- (algorithms sorting)
<p>There is an integer array that contain $n$ numbers, in the array there are $k$ distinct elements up to $k = 50$.<br>
Is it possible to sort this array in linear time, by using only comparisons?</p>

<p>I know that compariso... | habedi/stack-exchange-dataset |
67,827 | Complexity of Integer Division | <p>My favourite algorithm textbook: The Algorithm Design Manual S. Skiena.pdf
had this interesting problem:</p>

<blockquote>
 <p>1-28. [5] Write a function to perform integer division without using either the / or * operators. Find a fast way to do it.</p>
</blockquote>

<p>What's the lowe... | complexity theory arithmetic integers | 1 | Complexity of Integer Division -- (complexity theory arithmetic integers)
<p>My favourite algorithm textbook: The Algorithm Design Manual S. Skiena.pdf
had this interesting problem:</p>

<blockquote>
 <p>1-28. [5] Write a function to perform integer division without using either the / or * operators. F... | habedi/stack-exchange-dataset |
67,835 | Efficiently computing the smallest integer with n divisors | <p>In order to tackle this problem I first observed that</p>

<p>$$\phi(p_1^{e_1} \space p_2^{e_2} \cdots \space p_k^{e_k}) = (e_1 + 1)(e_2 + 1)\cdots(e_k +1)$$</p>

<p>Where $\phi(m)$ is the number of (not necessarily prime) divisors of $m$. If $m$ is the smallest integer such that $\phi(m) = n$, then<... | number theory primes | 1 | Efficiently computing the smallest integer with n divisors -- (number theory primes)
<p>In order to tackle this problem I first observed that</p>

<p>$$\phi(p_1^{e_1} \space p_2^{e_2} \cdots \space p_k^{e_k}) = (e_1 + 1)(e_2 + 1)\cdots(e_k +1)$$</p>

<p>Where $\phi(m)$ is the number of (not necessarily ... | habedi/stack-exchange-dataset |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.