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 |
|---|---|---|---|---|---|---|
101,723 | Keywords/terminology for using "extra" information in search problems? | <p>I am trying to find references on a particular idea, but I don't know which keywords to use in a google search.</p>

<p>the idea is: as an example, consider graph search. maybe the problem is: find a path from node <span class="math-container">$X$</span> to node <span class="math-container">$Y$</span>. We ca... | terminology search algorithms | 1 | Keywords/terminology for using "extra" information in search problems? -- (terminology search algorithms)
<p>I am trying to find references on a particular idea, but I don't know which keywords to use in a google search.</p>

<p>the idea is: as an example, consider graph search. maybe the problem is: find a pat... | habedi/stack-exchange-dataset |
101,724 | Grover algorithm when element not present in the array/database | <p>I've been reading about the Grover algorithm for finding elements in an unstructured database by the means of quantum computing, and even done some exercises.</p>

<p>What I don't understand (and can't find anywhere) is what is supposed to happen if the element is NOT present in the database. The oracle woul... | quantum computing | 1 | Grover algorithm when element not present in the array/database -- (quantum computing)
<p>I've been reading about the Grover algorithm for finding elements in an unstructured database by the means of quantum computing, and even done some exercises.</p>

<p>What I don't understand (and can't find anywhere) is wh... | habedi/stack-exchange-dataset |
101,728 | Efficiency/Redundancy in Chomsky normal form | <p>I have a context-free grammar with the following production rules, <span class="math-container">$S$</span> being the start symbol:</p>

<p><span class="math-container">$$\begin{align*}
S &\to AB \\
A &\to a \\
B &\to a\end{align*}$$</span></p>

<p>Is this in Chomsky normal for... | formal languages context free formal grammars normal forms | 1 | Efficiency/Redundancy in Chomsky normal form -- (formal languages context free formal grammars normal forms)
<p>I have a context-free grammar with the following production rules, <span class="math-container">$S$</span> being the start symbol:</p>

<p><span class="math-container">$$\begin{align*}
S &\to ... | habedi/stack-exchange-dataset |
101,730 | Time Complexity and graphs | <p>I'm learning graphs these days and need to clear few doubts-</p>

<ol>
<li>Can I determine weather 5 points in two dimensions whose X and Y coordinates are given lie on the same straight line in O(1).</li>
<li>What is the efficient way to find out the degree of the specified vertex in an undirected g... | algorithms graphs time complexity eulerian paths | 1 | Time Complexity and graphs -- (algorithms graphs time complexity eulerian paths)
<p>I'm learning graphs these days and need to clear few doubts-</p>

<ol>
<li>Can I determine weather 5 points in two dimensions whose X and Y coordinates are given lie on the same straight line in O(1).</li>
<li>What is th... | habedi/stack-exchange-dataset |
101,745 | Evaluation of $\beta$-Reduction with Parentheses in $\lambda$-Calculus | <p>I'm studying <span class="math-container">$\lambda$</span>-calculus, and had a question regarding an exercise I came across. I understand that <span class="math-container">$\lambda$</span>-calculus uses three main strategies of evaluation, but I'm having trouble applying it. Specifically <span class="math-container"... | reductions lambda calculus | 1 | Evaluation of $\beta$-Reduction with Parentheses in $\lambda$-Calculus -- (reductions lambda calculus)
<p>I'm studying <span class="math-container">$\lambda$</span>-calculus, and had a question regarding an exercise I came across. I understand that <span class="math-container">$\lambda$</span>-calculus uses three main ... | habedi/stack-exchange-dataset |
101,765 | Addition errors in IEEE754 floating point representation | <p>So in class, we were talking about the idea of floating point precision in IEEE754 format, and how, when some numbers are added, precision is lost. My professor then gave the following example of a large absolute error between what we think the answer might be, and what the answer actually is when our program (writt... | arithmetic floating point error estimation | 1 | Addition errors in IEEE754 floating point representation -- (arithmetic floating point error estimation)
<p>So in class, we were talking about the idea of floating point precision in IEEE754 format, and how, when some numbers are added, precision is lost. My professor then gave the following example of a large absolute... | habedi/stack-exchange-dataset |
101,768 | K Perfect Subgraph Algorithm | <p>I have a problem that goes as follows:</p>

<p><strong>Problem.</strong> Suppose we have undirected graph <span class="math-container">$G$</span>. We denote a <span class="math-container">$k$</span>-perfect graph as a graph such that <span class="math-container">$\forall v \in G, degree(v) = k$</span>. Prese... | algorithms graphs | 1 | K Perfect Subgraph Algorithm -- (algorithms graphs)
<p>I have a problem that goes as follows:</p>

<p><strong>Problem.</strong> Suppose we have undirected graph <span class="math-container">$G$</span>. We denote a <span class="math-container">$k$</span>-perfect graph as a graph such that <span class="math-conta... | habedi/stack-exchange-dataset |
101,770 | Leo's deterministic reduction for Earley Parsing | <p>I am trying to build an Earley parser using the <a href="https://en.wikipedia.org/wiki/Earley_parser" rel="nofollow noreferrer">Wikipedia pesudocode</a> as a base, with <a href="https://pdfs.semanticscholar.org/5b27/7a3f9a9f5250939f334e282d1393971722a9.pdf" rel="nofollow noreferrer">Aycock's fix</a> for epsilon rule... | algorithms context free parsers | 1 | Leo's deterministic reduction for Earley Parsing -- (algorithms context free parsers)
<p>I am trying to build an Earley parser using the <a href="https://en.wikipedia.org/wiki/Earley_parser" rel="nofollow noreferrer">Wikipedia pesudocode</a> as a base, with <a href="https://pdfs.semanticscholar.org/5b27/7a3f9a9f5250939... | habedi/stack-exchange-dataset |
101,771 | If a DFA were implemented as a circuit, what would the empty string correspond to as input? | <p>Say we have a DFA like the one shown below that accepts the empty string, <span class="math-container">$\varepsilon$</span>. 
<a href="https://i.stack.imgur.com/9YwQY.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/9YwQY.png" alt="enter image description here"></a></p>

<p>Also suppose... | formal languages finite automata | 1 | If a DFA were implemented as a circuit, what would the empty string correspond to as input? -- (formal languages finite automata)
<p>Say we have a DFA like the one shown below that accepts the empty string, <span class="math-container">$\varepsilon$</span>. 
<a href="https://i.stack.imgur.com/9YwQY.png" rel="nofoll... | habedi/stack-exchange-dataset |
101,772 | Two Turing machines $M_1$ and $M_2$ with $L(M_1) \subseteq L(M_2)$ | <p>Suppose <span class="math-container">$M_1$</span> and <span class="math-container">$M_2$</span> are two Turing machines such that <span class="math-container">$L(M_1)\subseteq L(M_2)$</span>. Which of the following is true? </p>

<ul>
<li>(A) On every input on which <span class="math-container">$M_1$</sp... | turing machines | 1 | Two Turing machines $M_1$ and $M_2$ with $L(M_1) \subseteq L(M_2)$ -- (turing machines)
<p>Suppose <span class="math-container">$M_1$</span> and <span class="math-container">$M_2$</span> are two Turing machines such that <span class="math-container">$L(M_1)\subseteq L(M_2)$</span>. Which of the following is true? </p>&... | habedi/stack-exchange-dataset |
101,774 | What will be big O complexity for this loop? | <p>I am not able to understand time complexity of this for loop. 
While outer loop is O(n) the inner loop jumps certain calculation. How to find the complexity? </p>

<pre><code>public void function(n) {
 for(int i = 1; i< n; i++) {
 for(int j = ... | algorithm analysis runtime analysis loops | 1 | What will be big O complexity for this loop? -- (algorithm analysis runtime analysis loops)
<p>I am not able to understand time complexity of this for loop. 
While outer loop is O(n) the inner loop jumps certain calculation. How to find the complexity? </p>

<pre><code>public void function(n) {
 ... | habedi/stack-exchange-dataset |
101,777 | Interview Question: Insert switch to maximize time lightbulb spends on | <p>Problem statement: </p>

<blockquote>
 <p>You have a lightbulb for an interval of <span class="math-container">$N$</span> seconds, where <span class="math-container">$N$</span> is given.
 At time 0, the lightbulb switches on, and at time <span class="math-container">$N$</span>, it switches off,&#x... | algorithms data structures | 1 | Interview Question: Insert switch to maximize time lightbulb spends on -- (algorithms data structures)
<p>Problem statement: </p>

<blockquote>
 <p>You have a lightbulb for an interval of <span class="math-container">$N$</span> seconds, where <span class="math-container">$N$</span> is given.
 At time... | habedi/stack-exchange-dataset |
101,782 | Show that for any real constants $a$ and $b$, where $b > 0$, $(n + a)^b = \Theta(n^b)$ | <p>I'm currently studying growth of function chapter in Introduction to Algorithm. In exercise 3.1-2 the question is: </p>

<blockquote>
 <p>Show that for any real constants <span class="math-container">$a$</span> and <span class="math-container">$b$</span>, where <span class="math-container">$b>0$</sp... | algorithms time complexity asymptotics | 1 | Show that for any real constants $a$ and $b$, where $b > 0$, $(n + a)^b = \Theta(n^b)$ -- (algorithms time complexity asymptotics)
<p>I'm currently studying growth of function chapter in Introduction to Algorithm. In exercise 3.1-2 the question is: </p>

<blockquote>
 <p>Show that for any real constants <... | habedi/stack-exchange-dataset |
101,799 | Find the minimum edge size, L, that would allow the construction of a tree whose edges connect all given 2-d points, but no edge exceeds length L | <p>Given a set of points in the 2-d plane, find the minimum edge size, L, that would allow the construction of a tree whose edges connect all given points, but no edge exceeds length L.</p>

<p>Here is an algorithm, which I think might work but seems slow:</p>

<ol>
<li><p>Pick a random point </p><... | algorithms graphs | 1 | Find the minimum edge size, L, that would allow the construction of a tree whose edges connect all given 2-d points, but no edge exceeds length L -- (algorithms graphs)
<p>Given a set of points in the 2-d plane, find the minimum edge size, L, that would allow the construction of a tree whose edges connect all given po... | habedi/stack-exchange-dataset |
101,802 | Construct context-free grammars that generate for the languages L(G) = {01(110)^n 10 (11)^n : n >= 0} | <p>I have given this question as home assignment. I tried a lot to solve it but couldn't found any solution. Please help 
Thanks in Advance!</p>
 | finite automata context free | 1 | Construct context-free grammars that generate for the languages L(G) = {01(110)^n 10 (11)^n : n >= 0} -- (finite automata context free)
<p>I have given this question as home assignment. I tried a lot to solve it but couldn't found any solution. Please help 
Thanks in Advance!</p>
 | habedi/stack-exchange-dataset |
101,804 | How to draw NPDA for words whose number of b's is strictly more than that of a's but strictly less than twice the amount | <p>I know that CFG for <span class="math-container">$$ \{a^{m}b^{n}\mid m\leq n\leq 2m \}$$</span> is
<span class="math-container">$$ S\rightarrow ab/abb/aSb/aSbb $$</span> but I am not able to tweak it in such a way that it is <strong>strictly</strong> in between m and 2m and not equal to any of m or 2m. 
I w... | finite automata context free pushdown automata | 1 | How to draw NPDA for words whose number of b's is strictly more than that of a's but strictly less than twice the amount -- (finite automata context free pushdown automata)
<p>I know that CFG for <span class="math-container">$$ \{a^{m}b^{n}\mid m\leq n\leq 2m \}$$</span> is
<span class="math-container">$$ S\rightar... | habedi/stack-exchange-dataset |
101,806 | Find the smallest element greater than current element | <p>my question is that given a list of integers (lets say A), for each element A[i], find the smallest element A[j] which could satisfy A[i] < A[j] and i < j. Return -1 if there is no such element.</p>

<p>For example, given [4,2,1,9,3], return [9,3,3,-1,-1]</p>

<p>I have come up with a brute for... | algorithms arrays | 1 | Find the smallest element greater than current element -- (algorithms arrays)
<p>my question is that given a list of integers (lets say A), for each element A[i], find the smallest element A[j] which could satisfy A[i] < A[j] and i < j. Return -1 if there is no such element.</p>

<p>For example, given [4,... | habedi/stack-exchange-dataset |
101,812 | The first Turing machine | <p>Does anyone know how efficient was the first Turing machine that Alan Turing made? I mean how many moves did it do per second or so... I'm just curious. Also couldn't find any info about it on the web.</p>
 | turing machines | 1 | The first Turing machine -- (turing machines)
<p>Does anyone know how efficient was the first Turing machine that Alan Turing made? I mean how many moves did it do per second or so... I'm just curious. Also couldn't find any info about it on the web.</p>
 | habedi/stack-exchange-dataset |
101,844 | How is $L^* - \{\epsilon \} \neq L^+$? | <p>I was asked which among the following is true:</p>

<blockquote>
 <ol>
 <li><span class="math-container">$\Sigma^*-\{\epsilon\} = \Sigma^+$</span> </li>
 <li><span class="math-container">$L^* - \{\epsilon \} = L^+$</span></li>
 </ol>
</blockquote>

<p>As I can see, both <span ... | formal languages kleene star | 1 | How is $L^* - \{\epsilon \} \neq L^+$? -- (formal languages kleene star)
<p>I was asked which among the following is true:</p>

<blockquote>
 <ol>
 <li><span class="math-container">$\Sigma^*-\{\epsilon\} = \Sigma^+$</span> </li>
 <li><span class="math-container">$L^* - \{\epsilon \} = L^+$</span>... | habedi/stack-exchange-dataset |
101,853 | Time Complexity of Nested For Loops where second loop starts from +1 index of the first loop | <p>Hi I know two nested for loops will have time Complexity of O(n²). However let's say first loop starts from 0 and goes upto variable X max value(suppose x is n) and second loop starts from +1 of the first loop then we woudn't compare all the values of x with all the other values of x.In that case it woudn't be n². I... | algorithms | 1 | Time Complexity of Nested For Loops where second loop starts from +1 index of the first loop -- (algorithms)
<p>Hi I know two nested for loops will have time Complexity of O(n²). However let's say first loop starts from 0 and goes upto variable X max value(suppose x is n) and second loop starts from +1 of the first loo... | habedi/stack-exchange-dataset |
101,855 | The role of the root switch after Spanning Tree Protocol has established a tree network in a LAN? | <p>In <strong>Spanning Tree Protocol</strong>, a root switch is selected at first, and then somehow, the shortest path from each other switch to the root is obtained. Thus we established a tree network. </p>

<p>My questions are: </p>

<blockquote>
 <ul>
 <li>After the tree network is establis... | computer networks spanning trees communication protocols | 1 | The role of the root switch after Spanning Tree Protocol has established a tree network in a LAN? -- (computer networks spanning trees communication protocols)
<p>In <strong>Spanning Tree Protocol</strong>, a root switch is selected at first, and then somehow, the shortest path from each other switch to the root is obt... | habedi/stack-exchange-dataset |
101,863 | Polynomial Time Algorithm for Steiner Tree Problem | <p>I know about Steiner Tree Problem. It is stated as </p>

<blockquote>
 <p>Input to Steiner Tree Problem is a weighted graph G and a subset T of the nodes (called terminal nodes) and goal is to find a minimum weight tree that spans all the nodes in T. </p>
</blockquote>

<p>Can we give a <cod... | algorithms polynomial time | 1 | Polynomial Time Algorithm for Steiner Tree Problem -- (algorithms polynomial time)
<p>I know about Steiner Tree Problem. It is stated as </p>

<blockquote>
 <p>Input to Steiner Tree Problem is a weighted graph G and a subset T of the nodes (called terminal nodes) and goal is to find a minimum weight tree t... | habedi/stack-exchange-dataset |
101,866 | Graph Edit Distance | <p>Source: K. Riesen, Structural Pattern Recognition with Graph Edit Distance,
Advances in Computer Vision and Pattern Recognition.</p>

<p>Link: <a href="https://www.springer.com/cda/content/document/cda_downloaddocument/9783319272511-c2.pdf?SGWID=0-0-45-1545097-p177820399" rel="nofollow noreferrer">https:... | algorithms graphs np hard edit distance | 1 | Graph Edit Distance -- (algorithms graphs np hard edit distance)
<p>Source: K. Riesen, Structural Pattern Recognition with Graph Edit Distance,
Advances in Computer Vision and Pattern Recognition.</p>

<p>Link: <a href="https://www.springer.com/cda/content/document/cda_downloaddocument/9783319272511-c2.pdf?... | habedi/stack-exchange-dataset |
101,874 | Complexity of linear programming with restricted quadratic constraints | <p>A problem instance is a linear program with the following kind of quadratic inequalities allowed: For some of the variables <span class="math-container">$x_i$</span>, there is a variable <span class="math-container">$s_i$</span> (intuitively for approximating <span class="math-container">$x_i^2$</span>, and distinct... | complexity theory optimization linear programming | 1 | Complexity of linear programming with restricted quadratic constraints -- (complexity theory optimization linear programming)
<p>A problem instance is a linear program with the following kind of quadratic inequalities allowed: For some of the variables <span class="math-container">$x_i$</span>, there is a variable <spa... | habedi/stack-exchange-dataset |
101,882 | Show that the following algorithm takes $O(n)$ time | <p>You are given a linked list of size <span class="math-container">$n$</span>.
An element can be accessed from the start of the list or the end of the list. The cost to access any location is <span class="math-container">$\min(i,n-i)$</span>, if the location being accessed is at index <span class="math-container">... | algorithms runtime analysis | 1 | Show that the following algorithm takes $O(n)$ time -- (algorithms runtime analysis)
<p>You are given a linked list of size <span class="math-container">$n$</span>.
An element can be accessed from the start of the list or the end of the list. The cost to access any location is <span class="math-container">$\min(i,n... | habedi/stack-exchange-dataset |
101,886 | Two Problems in understanding the algorithm for computing shortest paths in undirected graphs with possibly negative edge weights | <p>Section 2 of this <a href="http://people.math.sfu.ca/~goddyn/Courses/800/Resources/GraphMisc/short_path.pdf" rel="nofollow noreferrer">Lecture Note: Shortest Path Algorithms Luis Goddyn, Math 408</a> describes an algorithm using Edmonds' Minimum Weight Perfect Matching Algorithm to solve the shortest path problem fo... | graphs shortest path correctness proof matching | 1 | Two Problems in understanding the algorithm for computing shortest paths in undirected graphs with possibly negative edge weights -- (graphs shortest path correctness proof matching)
<p>Section 2 of this <a href="http://people.math.sfu.ca/~goddyn/Courses/800/Resources/GraphMisc/short_path.pdf" rel="nofollow noreferrer"... | habedi/stack-exchange-dataset |
101,895 | Complexity classes: What if different algorithms exist for different sizes of input? | <p>If I understand(*) correctly, a decision problem is some function <span class="math-container">$f(x)$</span> whose function argument <span class="math-container">$x$</span> can be represented by data of a limited length (e.g. not an irrational number) and whose value is either 0 or 1.</p>

<p>If there exists... | time complexity | 1 | Complexity classes: What if different algorithms exist for different sizes of input? -- (time complexity)
<p>If I understand(*) correctly, a decision problem is some function <span class="math-container">$f(x)$</span> whose function argument <span class="math-container">$x$</span> can be represented by data of a limite... | habedi/stack-exchange-dataset |
101,912 | Can this set of propositions be represented and proved in Haskell? | <p>I used a set of natural language statements and their formalization from <a href="https://books.google.ie/books?id=103UBwAAQBAJ&pg=PA89&lpg=PA89&dq=gries%20and%20schneider%20superman&source=bl&ots=aHMU11no9D&sig=ewxhn_RkSwvan9tr_As39WF9eAA&hl=en&sa=X&ved=2ahUKEwiCgPLQ5LHfAhXuSxU... | logic propositional logic haskell | 1 | Can this set of propositions be represented and proved in Haskell? -- (logic propositional logic haskell)
<p>I used a set of natural language statements and their formalization from <a href="https://books.google.ie/books?id=103UBwAAQBAJ&pg=PA89&lpg=PA89&dq=gries%20and%20schneider%20superman&source=bl&... | habedi/stack-exchange-dataset |
101,919 | picking a word for pumping lemma for L = {a^n b^m c^n b^m a^n | m,n≥0} | <p>If i have a language like <span class="math-container">$L = \{a^n b^m c^n b^m a^n \mid m,n\ge0\}$</span></p>

<p>when i pick a word for the language, would it be correct if i pick any of </p>

<p>these words: <span class="math-container">$w = a^k c^k$</span>, <span class="math-container">$w = a^k b^m... | regular languages pumping lemma | 1 | picking a word for pumping lemma for L = {a^n b^m c^n b^m a^n | m,n≥0} -- (regular languages pumping lemma)
<p>If i have a language like <span class="math-container">$L = \{a^n b^m c^n b^m a^n \mid m,n\ge0\}$</span></p>

<p>when i pick a word for the language, would it be correct if i pick any of </p>

... | habedi/stack-exchange-dataset |
101,931 | Private IP and public IP | <p>What we see on our devices is essentially the private IP given to us by the ISP; thereby, whenever we access the internet, this private IP is first converted to public IP (by ISP through NAT), following which requests are made on the internet. If the assumptions above are right, then how does a website gets my priva... | computer networks communication protocols | 1 | Private IP and public IP -- (computer networks communication protocols)
<p>What we see on our devices is essentially the private IP given to us by the ISP; thereby, whenever we access the internet, this private IP is first converted to public IP (by ISP through NAT), following which requests are made on the internet. I... | habedi/stack-exchange-dataset |
101,944 | Is a set $B = \{y, \exists x \in A, f(x)=y\}$ recursive if A is a recursive set and f is a $N->N$ total computable function? | <p>Obviously, B would be recursive if for every TCF f, there was an inverse fuction that would return all possible values, as we could just take these and then check if any of them is in A. However I cannot find a proof (or counter-proof) that you can invert TCFs this way. AFAIK, all injective functions are invertible,... | computability sets | 1 | Is a set $B = \{y, \exists x \in A, f(x)=y\}$ recursive if A is a recursive set and f is a $N->N$ total computable function? -- (computability sets)
<p>Obviously, B would be recursive if for every TCF f, there was an inverse fuction that would return all possible values, as we could just take these and then check if an... | habedi/stack-exchange-dataset |
101,952 | For Loop Range with Smaller Number on Right | <p>Simple question from an algorithm noob...</p>

<p>If <span class="math-container">$i=1$</span> then the inner loop will include what I believe to be an invalid range. Is this acceptable pseudocode? </p>

<pre><code>For i=1 to n
 For k=1 to i-1
 ...
</code></pre>
 | algorithms syntax pseudocode | 1 | For Loop Range with Smaller Number on Right -- (algorithms syntax pseudocode)
<p>Simple question from an algorithm noob...</p>

<p>If <span class="math-container">$i=1$</span> then the inner loop will include what I believe to be an invalid range. Is this acceptable pseudocode? </p>

<pre><code>For i=1 ... | habedi/stack-exchange-dataset |
101,960 | Finding the k-th smallest ternary sum of elements from three different arrays | <p>The problem goes like this:</p>

<p>Given arrays <span class="math-container">$\{ a_i: 0\leq i \leq n-1 \},\{ b_i: 0\leq i \leq n-1 \} $</span> and <span class="math-container">$\{ c_i: 0\leq i \leq n-1 \}$</span>, we want to know what is the <span class="math-container">$k$</span>-th <strong>smallest combi... | algorithms algorithm analysis sorting trees heaps | 1 | Finding the k-th smallest ternary sum of elements from three different arrays -- (algorithms algorithm analysis sorting trees heaps)
<p>The problem goes like this:</p>

<p>Given arrays <span class="math-container">$\{ a_i: 0\leq i \leq n-1 \},\{ b_i: 0\leq i \leq n-1 \} $</span> and <span class="math-container... | habedi/stack-exchange-dataset |
101,969 | Cache and Main Memory | <p>As we know that average access time is given by</p>

<p>t=p*(tc)+(1-p)*(tc+tm)</p>

<p>where t represent the average time, p is the hit ratio , tc is the time to access the data from the cache and tm is time to retrieve data from main memory.
I was wondering wouldn't it be possible to decrease th... | computer architecture operating systems | 1 | Cache and Main Memory -- (computer architecture operating systems)
<p>As we know that average access time is given by</p>

<p>t=p*(tc)+(1-p)*(tc+tm)</p>

<p>where t represent the average time, p is the hit ratio , tc is the time to access the data from the cache and tm is time to retrieve data from main... | habedi/stack-exchange-dataset |
101,971 | Example of tree with > 6 vertices, tree would have depth = n after splay() deepest vertex | <p>How to build tree with more than 6 vertices, that after operation splay() would have depth = number of vertices? Is it possible?</p>

<p>UPD:
Example for n = 4:</p>

<ul>
<li>insert 60 </li>
<li>insert 10 </li>
<li>insert 20 </li>
<li>insert 50 </li>
<li>splay(10)</li>
</u... | data structures trees splay trees | 1 | Example of tree with > 6 vertices, tree would have depth = n after splay() deepest vertex -- (data structures trees splay trees)
<p>How to build tree with more than 6 vertices, that after operation splay() would have depth = number of vertices? Is it possible?</p>

<p>UPD:
Example for n = 4:</p>

<u... | habedi/stack-exchange-dataset |
101,972 | How to formulate constraints in zero-one linear programming | <p>There is a factory which produces 5 types of ice cream. If the <span class="math-container">$i_{th}$</span> ice cream is produced then <span class="math-container">$b_i=1$</span> otherwise <span class="math-container">$b_i=0$</span></p>

<p>How can I express the following constraints:</p>

<ul>
<... | linear programming | 1 | How to formulate constraints in zero-one linear programming -- (linear programming)
<p>There is a factory which produces 5 types of ice cream. If the <span class="math-container">$i_{th}$</span> ice cream is produced then <span class="math-container">$b_i=1$</span> otherwise <span class="math-container">$b_i=0$</span><... | habedi/stack-exchange-dataset |
101,973 | How to properly calculate dependent nested loops for big-O | <p>I am revising for my algorithms exam and I have come across one topic in particular that I do not quite understand; which is how to analyse dependent nested loops. I know if we have a 2-nested loop, both of which iterate <span class="math-container">$n$</span> times, the order will be of <span class="math-container"... | algorithms algorithm analysis asymptotics | 1 | How to properly calculate dependent nested loops for big-O -- (algorithms algorithm analysis asymptotics)
<p>I am revising for my algorithms exam and I have come across one topic in particular that I do not quite understand; which is how to analyse dependent nested loops. I know if we have a 2-nested loop, both of whic... | habedi/stack-exchange-dataset |
101,990 | Multi-level Paging | <p>Consider a system which has 2 level paging.The page table is divided into 2K pages and each page is having 4K entries.Memory is word addressable and Physical address space is 64MW which is divided into 16K frames.Page table entry size is 2 words.</p>

<p>(A)Length of logical address</p>

<p>(B)Length... | paging | 1 | Multi-level Paging -- (paging)
<p>Consider a system which has 2 level paging.The page table is divided into 2K pages and each page is having 4K entries.Memory is word addressable and Physical address space is 64MW which is divided into 16K frames.Page table entry size is 2 words.</p>

<p>(A)Length of logical ad... | habedi/stack-exchange-dataset |
101,994 | Greedy Algorithm Proof Min Swaps | <p><strong>Problem to get the min. no. of swaps required for arranging pairs togethe.</strong></p>

<p>There exists an array of size 2N with integers ranging from 0 to 2N-1 arranged at random. Each integer is paired with another
i.e. 0 paired with 1, 2 paired with 3,...2N-2 paired with 2N-1. What is the min... | greedy algorithms | 1 | Greedy Algorithm Proof Min Swaps -- (greedy algorithms)
<p><strong>Problem to get the min. no. of swaps required for arranging pairs togethe.</strong></p>

<p>There exists an array of size 2N with integers ranging from 0 to 2N-1 arranged at random. Each integer is paired with another
i.e. 0 paired with 1, 2... | habedi/stack-exchange-dataset |
101,999 | How to prove a LTL formula correct in a specific model? | <p>I have been learning <strong>Verification by model checking</strong> recently and I get the following question:</p>

<p><span class="math-container">$Whether\ the\ LTL\ formula\ M, q_3\ \models (X\ \lnot a) \rightarrow (F\ G\ \lnot a)\ is\ established\ or\ not\ in\ this\ model\ M?$</span></p>

<p>And... | logic formal methods model checking linear temporal logic | 1 | How to prove a LTL formula correct in a specific model? -- (logic formal methods model checking linear temporal logic)
<p>I have been learning <strong>Verification by model checking</strong> recently and I get the following question:</p>

<p><span class="math-container">$Whether\ the\ LTL\ formula\ M, q_3\ \mod... | habedi/stack-exchange-dataset |
102,001 | Validity of CTL formula $s_0 \models EG\ AF\ p$ in given model | <p>I have been learning <strong>Verification by model checking</strong> recently and I get the following question:</p>

<blockquote>
 <p>Is the CTL formula <span class="math-container">$s_{0} \models EG\ AF\ p$</span> valid in the following model?</p>
 
 <p><a href="https://i.stack.imgur.com/H8RU... | logic model checking computation tree logic | 1 | Validity of CTL formula $s_0 \models EG\ AF\ p$ in given model -- (logic model checking computation tree logic)
<p>I have been learning <strong>Verification by model checking</strong> recently and I get the following question:</p>

<blockquote>
 <p>Is the CTL formula <span class="math-container">$s_{0} \mo... | habedi/stack-exchange-dataset |
102,003 | IA network that is path-consistent, but not consistent | <p>I'm studying continuous CSP from the slides of my professor and i got that with the <a href="https://www.cs.cmu.edu/afs/cs/project/jair/pub/volume4/vanbeek96a-html/node5.html" rel="nofollow noreferrer">PATH-CONSISTENCY</a> algorithm you can check consistency for PA (Point Algebra), SIA and ORD-Horn; however it canno... | constraint satisfaction | 1 | IA network that is path-consistent, but not consistent -- (constraint satisfaction)
<p>I'm studying continuous CSP from the slides of my professor and i got that with the <a href="https://www.cs.cmu.edu/afs/cs/project/jair/pub/volume4/vanbeek96a-html/node5.html" rel="nofollow noreferrer">PATH-CONSISTENCY</a> algorithm ... | habedi/stack-exchange-dataset |
102,007 | Boolean Functions | <p>Say you have N input Boolean function, let's use a parity tree for the example. The function outputs a one or a zero depending on the values of the N inputs. Are the N inputs considered the preimage of the function?</p>
 | boolean algebra | 1 | Boolean Functions -- (boolean algebra)
<p>Say you have N input Boolean function, let's use a parity tree for the example. The function outputs a one or a zero depending on the values of the N inputs. Are the N inputs considered the preimage of the function?</p>
 | habedi/stack-exchange-dataset |
102,010 | Pipelining and instruction cycle | <p>Consider the sequence of machine instruction given below:
<span class="math-container">\begin{array}{ll} \text{MUL} & \text{R5, R0, R1} \\ \text{DIV} & \text{R6, R2, R3} \\ \text{ADD} & \text{R7, R5, R6} \\ \text{SUB} & \text{R8, R7, R4} \\ \end{array}</span></p>
<p>In the above sequenc... | computer architecture | 1 | Pipelining and instruction cycle -- (computer architecture)
<p>Consider the sequence of machine instruction given below:
<span class="math-container">\begin{array}{ll} \text{MUL} & \text{R5, R0, R1} \\ \text{DIV} & \text{R6, R2, R3} \\ \text{ADD} & \text{R7, R5, R6} \\ \text{SUB} & \text{R8, R7,... | habedi/stack-exchange-dataset |
102,013 | set cover where only certain special subsets are allowed | <p>I am trying to solve a problem which turns out to be a form of the set cover problem. I've implemented the greedy Set cover approximation algorithm for set cover, but it turns out to not be accurate enough for my needs.</p>

<p>Specifically I have a fixed, finite, list of special sets and I am trying to crea... | dynamic programming approximation sets greedy algorithms set cover | 1 | set cover where only certain special subsets are allowed -- (dynamic programming approximation sets greedy algorithms set cover)
<p>I am trying to solve a problem which turns out to be a form of the set cover problem. I've implemented the greedy Set cover approximation algorithm for set cover, but it turns out to not b... | habedi/stack-exchange-dataset |
102,016 | Complexity of an instance of a NP-complete problem | <p>I am trying to prove the NP-Completeness of problem <strong>[A]</strong>. </p>

<p>I know there is a well-known NP-Complete problem called problem <strong>[B]</strong>. </p>

<p>I can model <strong>[A]</strong> into an instance of <strong>[B]</strong> (<strong>[B]</strong> is a very general problem a... | complexity theory np complete | 1 | Complexity of an instance of a NP-complete problem -- (complexity theory np complete)
<p>I am trying to prove the NP-Completeness of problem <strong>[A]</strong>. </p>

<p>I know there is a well-known NP-Complete problem called problem <strong>[B]</strong>. </p>

<p>I can model <strong>[A]</strong> into... | habedi/stack-exchange-dataset |
102,022 | Halting problem with extra input | <p>Can there be a function <code>HALT(f, y)</code> so that:</p>

<ul>
<li>There are some <code>x</code> such that <code>f(x)</code> halts iff there are some <code>y</code> such that <code>HALT(f, y)</code> return true;</li>
<li>There are some <code>x</code> such that <code>f(x)</code> doesn't halt iff t... | computability halting problem | 1 | Halting problem with extra input -- (computability halting problem)
<p>Can there be a function <code>HALT(f, y)</code> so that:</p>

<ul>
<li>There are some <code>x</code> such that <code>f(x)</code> halts iff there are some <code>y</code> such that <code>HALT(f, y)</code> return true;</li>
<li>There ar... | habedi/stack-exchange-dataset |
102,026 | Can I say the two cases of Recursion Tree are always either $\theta{(n)}$ or $\theta({n\log{n}})$ | <p>Given positive constants: <span class="math-container">$c_1, c_2, ..., c_k, c^\prime$</span>, assume that <br>
<span class="math-container">$T(n) = T(c_1n) + T(c_2n) + ...+ T(c_kn) + c^\prime n$</span></p>

<p>There are two cases:</p>

<ol>
<li><span class="math-container">$c_1 + c_2 + ...+ c... | asymptotics recurrence relation | 1 | Can I say the two cases of Recursion Tree are always either $\theta{(n)}$ or $\theta({n\log{n}})$ -- (asymptotics recurrence relation)
<p>Given positive constants: <span class="math-container">$c_1, c_2, ..., c_k, c^\prime$</span>, assume that <br>
<span class="math-container">$T(n) = T(c_1n) + T(c_2n) + ...+ T(c_k... | habedi/stack-exchange-dataset |
102,029 | MergeSort k arbitrary words in linear time | <p>Given <span class="math-container">$k$</span> arbitrary words, such as <span class="math-container">$\{\text{"fjqke"}, \text{"gbqig"}, \text{"a"}\}$</span>, is there a way to mergesort these words in linear time so that the final output would be "abefgggijkq"? I tried to approach it by first sorting all the words in... | algorithms sorting efficiency mergesort | 1 | MergeSort k arbitrary words in linear time -- (algorithms sorting efficiency mergesort)
<p>Given <span class="math-container">$k$</span> arbitrary words, such as <span class="math-container">$\{\text{"fjqke"}, \text{"gbqig"}, \text{"a"}\}$</span>, is there a way to mergesort these words in linear time so that the final... | habedi/stack-exchange-dataset |
102,037 | Constructive proof to show the quotient of two regular languages is regular | <p>I have a question regarding the quotient of two regular languages, <span class="math-container">$R$</span> and <span class="math-container">$L$</span>.</p>

<p>I saw the answers to this question: <a href="https://cs.stackexchange.com/questions/34006/are-regular-languages-closed-under-division">are regular la... | automata regular languages finite automata | 1 | Constructive proof to show the quotient of two regular languages is regular -- (automata regular languages finite automata)
<p>I have a question regarding the quotient of two regular languages, <span class="math-container">$R$</span> and <span class="math-container">$L$</span>.</p>

<p>I saw the answers to this... | habedi/stack-exchange-dataset |
102,056 | Binary search in log time on a Turing Machine | <p>I was thinking about TM (Turing Machine) as a computation model, and I came up with the following question :</p>

<p>Is it possible to make a TM that answers binary search (tell wether <span class="math-container">$x$</span> belong to a sorted array <span class="math-container">$A$</span>) in <span class="ma... | turing machines time complexity binary search | 1 | Binary search in log time on a Turing Machine -- (turing machines time complexity binary search)
<p>I was thinking about TM (Turing Machine) as a computation model, and I came up with the following question :</p>

<p>Is it possible to make a TM that answers binary search (tell wether <span class="math-container... | habedi/stack-exchange-dataset |
102,060 | Minimum number of adjacent swaps needed to sort a circle of elements | <p>I have been thinking about some problems in combinatorics and I came across a problem I'm having trouble with.</p>

<p>Suppose you have a list <span class="math-container">$L$</span> of length <span class="math-container">$n$</span> (wlog the elements of the list are 1,2,3,...,n) and you want to sort it circ... | algorithms sorting | 1 | Minimum number of adjacent swaps needed to sort a circle of elements -- (algorithms sorting)
<p>I have been thinking about some problems in combinatorics and I came across a problem I'm having trouble with.</p>

<p>Suppose you have a list <span class="math-container">$L$</span> of length <span class="math-conta... | habedi/stack-exchange-dataset |
102,073 | Is the language $(a^n)^mb^n$ context free? | <p><span class="math-container">$(a^n)^mb^n$</span> for <span class="math-container">$m,n\ge 1$</span><br>
This can be rewritten as <span class="math-container">$a^{nm}b^n $</span>
<br>i.e. number of <span class="math-container">$a$</span>'s is a multiple of number of <span class="math-container">$b$</span>'... | context free pushdown automata | 1 | Is the language $(a^n)^mb^n$ context free? -- (context free pushdown automata)
<p><span class="math-container">$(a^n)^mb^n$</span> for <span class="math-container">$m,n\ge 1$</span><br>
This can be rewritten as <span class="math-container">$a^{nm}b^n $</span>
<br>i.e. number of <span class="math-container">$... | habedi/stack-exchange-dataset |
102,074 | Why $2R\sigma\sqrt{T+logT+1}=\tilde{{O}}(\sigma\sqrt{T})$? | <p>On page 17 on the paper <a href="https://arxiv.org/pdf/1208.3728.pdf" rel="nofollow noreferrer">Online Learning with Predictable Sequences</a>, we find a regret of an algorithm equal to</p>

<p><span class="math-container">$$
\text{Reg}_T=\frac{R^2}{\eta}+\frac{\eta}{2}\sigma^2(T+logT+1)
$$</span>&#x... | asymptotics | 1 | Why $2R\sigma\sqrt{T+logT+1}=\tilde{{O}}(\sigma\sqrt{T})$? -- (asymptotics)
<p>On page 17 on the paper <a href="https://arxiv.org/pdf/1208.3728.pdf" rel="nofollow noreferrer">Online Learning with Predictable Sequences</a>, we find a regret of an algorithm equal to</p>

<p><span class="math-container">$$
\te... | habedi/stack-exchange-dataset |
102,086 | Given a bitstring generate all bitstring with n flipped bits | <p>For an algorithm I need to be able to iterate over all bit strings where <span class="math-container">$k$</span> bits are flipped given a bit string with length <span class="math-container">$n$</span> and <span class="math-container">$n \geq k$</span>. For instance let's say I have the bit string <span class="math-c... | algorithms combinatorics bit manipulation | 1 | Given a bitstring generate all bitstring with n flipped bits -- (algorithms combinatorics bit manipulation)
<p>For an algorithm I need to be able to iterate over all bit strings where <span class="math-container">$k$</span> bits are flipped given a bit string with length <span class="math-container">$n$</span> and <spa... | habedi/stack-exchange-dataset |
102,092 | How to make an unambigous grammar of a programming language | <p>We know that the decision problem of whether an arbitrary context-free grammar is ambiguous is undecidable. My question is how are made the unambigous grammar of programming language? My guessing is that maybe starting from a simple grammar, which is easy to prove that is not ambigous, then adding some rules for whi... | context free programming languages ambiguity | 1 | How to make an unambigous grammar of a programming language -- (context free programming languages ambiguity)
<p>We know that the decision problem of whether an arbitrary context-free grammar is ambiguous is undecidable. My question is how are made the unambigous grammar of programming language? My guessing is that may... | habedi/stack-exchange-dataset |
102,094 | How do you find set of keywords present in set of words in linear time or log time? | <p>I am trying to optimize a program, where I need to know whether a given set of keywords present in the set of words. I believe using the dictionary is the <strong>only</strong> way to optimize it. Any other technique so that I can get better time complexity? The below python script is my version of the code, this wo... | algorithms complexity theory runtime analysis | 1 | How do you find set of keywords present in set of words in linear time or log time? -- (algorithms complexity theory runtime analysis)
<p>I am trying to optimize a program, where I need to know whether a given set of keywords present in the set of words. I believe using the dictionary is the <strong>only</strong> way t... | habedi/stack-exchange-dataset |
102,114 | What's the theoretical difference between class and type? | <p>This question stems from my effort trying to learn ASN.1. </p>

<p>After I went through the PKCS#1 standard for RSA cryptosystem and X.680~X.683 side-by-side, I noticed that, they've defined </p>

<ol>
<li><p><code>ALGORITHM-IDENTIFIER</code> as a class, and</p></li>
<li><p><code>AlgorithmIde... | terminology | 1 | What's the theoretical difference between class and type? -- (terminology)
<p>This question stems from my effort trying to learn ASN.1. </p>

<p>After I went through the PKCS#1 standard for RSA cryptosystem and X.680~X.683 side-by-side, I noticed that, they've defined </p>

<ol>
<li><p><code>ALGORIT... | habedi/stack-exchange-dataset |
102,119 | Missing part of the proof of Master Theorem's case 2 (with ceilings and floors) in CLRS? | <p>I am trying to go through the proof of the Master Theorem in Introduction to Algorithms of Cormen, Leiserson, Rivest, Stein (CLRS). The theorem providers an asymptotic analysis for recurrence relations <span class="math-container">$T(n)=aT(n/b)+f(n)$</span> where <span class="math-container">$a\geq 1, b > 1$</spa... | asymptotics master theorem | 1 | Missing part of the proof of Master Theorem's case 2 (with ceilings and floors) in CLRS? -- (asymptotics master theorem)
<p>I am trying to go through the proof of the Master Theorem in Introduction to Algorithms of Cormen, Leiserson, Rivest, Stein (CLRS). The theorem providers an asymptotic analysis for recurrence rela... | habedi/stack-exchange-dataset |
102,121 | Algorithm to solve $L_1$ optimization of $\sum_i ||\mathbf{A_i x} - \mathbf{b_i}||_1$ | <p>Is there is an efficient algorithm to solve the following optimization:</p>

<p><span class="math-container">$\mathbf{x}^* = \arg\min_\mathbf{x}\sum_i ||\mathbf{A_i x} - \mathbf{b_i}||_1$</span></p>

<p>for given <span class="math-container">$\mathbf{b_i}, \mathbf{A_i}\ \forall i$</span>, where <span... | optimization linear algebra | 1 | Algorithm to solve $L_1$ optimization of $\sum_i ||\mathbf{A_i x} - \mathbf{b_i}||_1$ -- (optimization linear algebra)
<p>Is there is an efficient algorithm to solve the following optimization:</p>

<p><span class="math-container">$\mathbf{x}^* = \arg\min_\mathbf{x}\sum_i ||\mathbf{A_i x} - \mathbf{b_i}||_1$</s... | habedi/stack-exchange-dataset |
102,123 | why is the max number of Nodes mod(N/m) + mod(N/m^2) + 1 in R-tree? | <p>I am going through Antonin Guttman's paper on R-tree. It mentions the max no of nodes given N index records in an R-tree is <code>|N/m| + |N/m^2| + 1</code>.</p>

<p>If there are N index records and if we choose to have minimum number of entries (m) in each node, wouldn't we just need N/m nodes at max? Why d... | algorithms algorithm analysis | 1 | why is the max number of Nodes mod(N/m) + mod(N/m^2) + 1 in R-tree? -- (algorithms algorithm analysis)
<p>I am going through Antonin Guttman's paper on R-tree. It mentions the max no of nodes given N index records in an R-tree is <code>|N/m| + |N/m^2| + 1</code>.</p>

<p>If there are N index records and if we c... | habedi/stack-exchange-dataset |
102,130 | "Process functions" in iterative and recursive depth-first search | <p>I was reading <em>The Algorithm Design Manual</em> by Steven Skiena, and I noticed his use of "process functions" in depth-first search and breadth-first search. Consider the following pseudocode for depth-first search:</p>

<pre><code>DFS(G,u)
 state[u] = "discovered"
 process_vertex_early(u)&... | graphs graph traversal | 1 | "Process functions" in iterative and recursive depth-first search -- (graphs graph traversal)
<p>I was reading <em>The Algorithm Design Manual</em> by Steven Skiena, and I noticed his use of "process functions" in depth-first search and breadth-first search. Consider the following pseudocode for depth-first search:</p>... | habedi/stack-exchange-dataset |
102,135 | How literally is "optimization" or "optimization algorithm" used in CS? | <p>I have been confronted with two meanings of the term "optimization" or "optimization algorithm":</p>

<ol>
<li><p>to find the <strong>absolute maximum</strong> in a set <span class="math-container">$X$</span> according to some criterion <span class="math-container">$f:X\to \mathbb R$</span></p></li>
... | optimization terminology | 1 | How literally is "optimization" or "optimization algorithm" used in CS? -- (optimization terminology)
<p>I have been confronted with two meanings of the term "optimization" or "optimization algorithm":</p>

<ol>
<li><p>to find the <strong>absolute maximum</strong> in a set <span class="math-container">$X$</... | habedi/stack-exchange-dataset |
102,137 | Find a lambda term satisfying two equations | <p>I'm just looking for the general idea on how to approach the following problem:</p>

<p>Find a term <span class="math-container">$\Delta=\lambda x.xUV$</span> such that:</p>

<ol>
<li><span class="math-container">$\Delta\Delta=K$</span></li>
<li><span class="math-container">$\Delta K=S$</span... | lambda calculus combinatory logic | 1 | Find a lambda term satisfying two equations -- (lambda calculus combinatory logic)
<p>I'm just looking for the general idea on how to approach the following problem:</p>

<p>Find a term <span class="math-container">$\Delta=\lambda x.xUV$</span> such that:</p>

<ol>
<li><span class="math-container">$... | habedi/stack-exchange-dataset |
102,141 | Proof Idea: There are irrational numbers whose decimal expansion cannot be computed | <p>The online lecture I am watching stated a proof idea: </p>

<p>The set of all possible programs is countably infinite, yet
the set of irrational numbers is uncountably infinite.</p>

<p>I don't think this is sufficient, it assumes one program can only return one irrational number. 
How to sho... | turing machines computability | 1 | Proof Idea: There are irrational numbers whose decimal expansion cannot be computed -- (turing machines computability)
<p>The online lecture I am watching stated a proof idea: </p>

<p>The set of all possible programs is countably infinite, yet
the set of irrational numbers is uncountably infinite.</p>
... | habedi/stack-exchange-dataset |
102,154 | Regular expression or automata for language with odd number of 0's and odd number of 1's | <p>Let <span class="math-container">$\Sigma=\{0,1\}$</span> and <span class="math-container">$L=\{u \in \Sigma^* : u \text{ has odd number of 0's and odd number of 1's}\}$</span>. How can I build a regular expression or an automaton for this language? I have no idea, and I guess <span class="math-container">$L$</span> ... | automata regular languages regular expressions | 1 | Regular expression or automata for language with odd number of 0's and odd number of 1's -- (automata regular languages regular expressions)
<p>Let <span class="math-container">$\Sigma=\{0,1\}$</span> and <span class="math-container">$L=\{u \in \Sigma^* : u \text{ has odd number of 0's and odd number of 1's}\}$</span>.... | habedi/stack-exchange-dataset |
102,158 | Show that $A_\mathrm{LBA}$ is PSPACE-Complete? | <p>I want to show that <span class="math-container">$A_\mathrm{LBA}$</span> is PSPACE-Compelte. </p>

<p>Say we proved it is in PSPACE. Now for PSPACE-HARD:</p>

<p>I had an idea, which was very similar to some solution i found on the web- say we have a TM M which decides some language <code>A</code> in... | complexity theory turing machines reductions space complexity linear bounded automata | 1 | Show that $A_\mathrm{LBA}$ is PSPACE-Complete? -- (complexity theory turing machines reductions space complexity linear bounded automata)
<p>I want to show that <span class="math-container">$A_\mathrm{LBA}$</span> is PSPACE-Compelte. </p>

<p>Say we proved it is in PSPACE. Now for PSPACE-HARD:</p>

<p>I... | habedi/stack-exchange-dataset |
102,165 | Solving " Tricolor Arrangement " Efficiently | <p>A rectangular board with three rows and <span class="math-container">$n$</span> columns is filled with <span class="math-container">$3n$</span> counters, of which <span class="math-container">$n$</span> are red, <span class="math-container">$n$</span> are white, and <span class="math-container">$n$</span> are blue. ... | algorithms complexity theory | 1 | Solving " Tricolor Arrangement " Efficiently -- (algorithms complexity theory)
<p>A rectangular board with three rows and <span class="math-container">$n$</span> columns is filled with <span class="math-container">$3n$</span> counters, of which <span class="math-container">$n$</span> are red, <span class="math-containe... | habedi/stack-exchange-dataset |
102,174 | Proving correctness of inefficient algorithm - Path between two vertices | <p>Consider the following inefficient algorithm that decides if there is a path between two vertices s and t of a directed graph G. Show that the algorithm is correct. In addition, analyze its complexity and compare it with the other path between two vertices algorithms (Dijsktra, Bellman-Ford Algorithm, etc.) and expl... | algorithms graphs algorithm analysis time complexity correctness proof | 1 | Proving correctness of inefficient algorithm - Path between two vertices -- (algorithms graphs algorithm analysis time complexity correctness proof)
<p>Consider the following inefficient algorithm that decides if there is a path between two vertices s and t of a directed graph G. Show that the algorithm is correct. In ... | habedi/stack-exchange-dataset |
102,186 | Is $O(T+\log T)= O(T\log T)$? | <p>Is <span class="math-container">$O(T+\log T)= O(T\log T)$</span>?</p>

<p>I think this is true but I do not know how to show it mathematically?</p>

<p>Please show it using the definition.</p>

<p>Also, if it is true, is the following true?</p>

<p><span class="math-container">$O((T+\... | asymptotics | 1 | Is $O(T+\log T)= O(T\log T)$? -- (asymptotics)
<p>Is <span class="math-container">$O(T+\log T)= O(T\log T)$</span>?</p>

<p>I think this is true but I do not know how to show it mathematically?</p>

<p>Please show it using the definition.</p>

<p>Also, if it is true, is the following true?</p>&#... | habedi/stack-exchange-dataset |
102,187 | Polynomial time algorithm - Matching pairs of vertices | <p>Let T be a tree with root r and S a set with an even number of vertices of T. Design a polynomial time algorithm that finds |S|/2 simple and disjoint paths in edges matching pairs of vertices in S. The following figure shows an example in which S consists of the six vertices enclosed in circles and three paths (deno... | algorithms graphs algorithm analysis trees recursion | 1 | Polynomial time algorithm - Matching pairs of vertices -- (algorithms graphs algorithm analysis trees recursion)
<p>Let T be a tree with root r and S a set with an even number of vertices of T. Design a polynomial time algorithm that finds |S|/2 simple and disjoint paths in edges matching pairs of vertices in S. The fo... | habedi/stack-exchange-dataset |
102,189 | Generating a random minimum spanning tree | <p>I am tring to find the simplest method of generating a random minimum spanning tree.</p>

<p>My intention is to randomly generate a Level in a game where there are n amount of fixed sized rooms existing on a grid which all connect together in a random way. </p>

<p>One method I have come across is t... | algorithms graphs weighted graphs minimum spanning tree | 1 | Generating a random minimum spanning tree -- (algorithms graphs weighted graphs minimum spanning tree)
<p>I am tring to find the simplest method of generating a random minimum spanning tree.</p>

<p>My intention is to randomly generate a Level in a game where there are n amount of fixed sized rooms existing on ... | habedi/stack-exchange-dataset |
102,190 | Why $xx^TM$ requires $O(dk)$ operations? | <p>Suppose <span class="math-container">$x \in \mathbb{R}^d$</span> and <span class="math-container">$M \in \mathbb{R}^{d \times k}$</span>.</p>

<p>Why <span class="math-container">$xx^TM$</span> requires <span class="math-container">$O(dk)$</span> operations?</p>
 | complexity theory time complexity runtime analysis | 1 | Why $xx^TM$ requires $O(dk)$ operations? -- (complexity theory time complexity runtime analysis)
<p>Suppose <span class="math-container">$x \in \mathbb{R}^d$</span> and <span class="math-container">$M \in \mathbb{R}^{d \times k}$</span>.</p>

<p>Why <span class="math-container">$xx^TM$</span> requires <span cla... | habedi/stack-exchange-dataset |
102,195 | Given a set $A$ of sets find a minimal set $B$ of pair-wise disjoint sets such that each set in $A$ can be expressed as a union of sets in $B$ | <p>I recently thought of the following problem:</p>

<p>Given a set <span class="math-container">$A$</span> of sets find a minimal set <span class="math-container">$B$</span> of pair-wise disjoint sets such that each set in <span class="math-container">$A$</span> can be expressed as a union of sets in <span cla... | algorithms complexity theory sets | 1 | Given a set $A$ of sets find a minimal set $B$ of pair-wise disjoint sets such that each set in $A$ can be expressed as a union of sets in $B$ -- (algorithms complexity theory sets)
<p>I recently thought of the following problem:</p>

<p>Given a set <span class="math-container">$A$</span> of sets find a minimal... | habedi/stack-exchange-dataset |
102,200 | Algorithm to find sets of vertices connected to at most one incoming and one outgoing vertex outside the set | <p>I have a directed graph with vertices <span class="math-container">$V$</span>, and I need to find a strict subset <span class="math-container">$U$</span> of its vertices such that:</p>

<ol>
<li><span class="math-container">$U$</span> contains at least two vertices, and <span class="math-container">$U \n... | algorithms graphs | 1 | Algorithm to find sets of vertices connected to at most one incoming and one outgoing vertex outside the set -- (algorithms graphs)
<p>I have a directed graph with vertices <span class="math-container">$V$</span>, and I need to find a strict subset <span class="math-container">$U$</span> of its vertices such that:</p>&... | habedi/stack-exchange-dataset |
102,203 | Check if one condition includes another | <p>I have two conditions A and B in a form of "ast tree".
How can I check that B is more strict than A?
I.e. if B is true then A is always true.</p>

<p>Example</p>

<p>A: 
x = 1 and (b = 2 or c = d)</p>

<p>B:
y = 5 and x = 1 and (b = 2 or c = d)</p>

<p>Does B include A... | logic | 1 | Check if one condition includes another -- (logic)
<p>I have two conditions A and B in a form of "ast tree".
How can I check that B is more strict than A?
I.e. if B is true then A is always true.</p>

<p>Example</p>

<p>A: 
x = 1 and (b = 2 or c = d)</p>

<p>B:
y = 5 and x = 1 an... | habedi/stack-exchange-dataset |
102,205 | Replace 1's with -1's and vice versa in a matix | <p>Assume that we have an anti-symmetric matrix that consists of 1's and -1's and 0's. All the elements of the main diagonal are 0 and each row and each column has exactly one 1, and one -1. Design an algorithm that replaces all 1's with -1's and vice versa only by swapping some rows and some columns.</p>
 | algorithms matrix | 1 | Replace 1's with -1's and vice versa in a matix -- (algorithms matrix)
<p>Assume that we have an anti-symmetric matrix that consists of 1's and -1's and 0's. All the elements of the main diagonal are 0 and each row and each column has exactly one 1, and one -1. Design an algorithm that replaces all 1's with -1's and vi... | habedi/stack-exchange-dataset |
102,206 | How do you detect if an algorithm is running at O(nlogn)? | <p>Given only input and output(e.g. runtime), how do you know if an algorithm is running at O(nlogn) time complexity? </p>

<p>For example, how does LeetCode detect my code is running at O(nlogn)?
<a href="https://leetcode.com/problems/sort-list/description/" rel="nofollow noreferrer">https://leetcode.com/... | algorithms time complexity | 1 | How do you detect if an algorithm is running at O(nlogn)? -- (algorithms time complexity)
<p>Given only input and output(e.g. runtime), how do you know if an algorithm is running at O(nlogn) time complexity? </p>

<p>For example, how does LeetCode detect my code is running at O(nlogn)?
<a href="https://lee... | habedi/stack-exchange-dataset |
102,208 | Data Hazard in Pipelining | <p>To be precise I am here for RAW hazard.
Consider a 5 stage pipeline .
 <img src="https://i.stack.imgur.com/BcEi1.jpg" alt="enter image description here"></p>

<p>In case of <span class="math-container">$I_4-I_1$</span> dependency , I am not sure if it is an <span class="math-container">$RAW$</span> ... | cpu pipelines | 1 | Data Hazard in Pipelining -- (cpu pipelines)
<p>To be precise I am here for RAW hazard.
Consider a 5 stage pipeline .
 <img src="https://i.stack.imgur.com/BcEi1.jpg" alt="enter image description here"></p>

<p>In case of <span class="math-container">$I_4-I_1$</span> dependency , I am not sure if it is a... | habedi/stack-exchange-dataset |
102,209 | Point rank in 2D plane time complexity? | <p>I'm reading about the algorithm of finding the ranks of all points in a 2D plane, I don't understand the time complexity formula for it. It has four steps:</p>

<ol>
<li>Compute the median of x-coordinates of all point, and divide the plane into two half Left, and Right.</li>
<li>Recursively do 1. th... | algorithms time complexity computational geometry | 1 | Point rank in 2D plane time complexity? -- (algorithms time complexity computational geometry)
<p>I'm reading about the algorithm of finding the ranks of all points in a 2D plane, I don't understand the time complexity formula for it. It has four steps:</p>

<ol>
<li>Compute the median of x-coordinates of a... | habedi/stack-exchange-dataset |
102,213 | So if a problem is more difficult the language it represents is smaller? | <p>I'm reading the definition of polynomial time reducible:</p>

<blockquote>
 <p>Let <span class="math-container">$L_1, L_2$</span> be two language. If <span class="math-container">$L_1$</span> is polynomial time reducible to <span class="math-container">$L_2$</span> then exists <span class="math-containe... | np complete reductions decision problem | 1 | So if a problem is more difficult the language it represents is smaller? -- (np complete reductions decision problem)
<p>I'm reading the definition of polynomial time reducible:</p>

<blockquote>
 <p>Let <span class="math-container">$L_1, L_2$</span> be two language. If <span class="math-container">$L_1$</... | habedi/stack-exchange-dataset |
102,231 | How this proof of fractional knapsack works? | <p>I don't understand a step in my book proving the fractional knapsack problem:</p>
<blockquote>
<p>Let value of items <span class="math-container">$v_1\ge v_2\ge \dots\ge v_n$</span>, and assume <span class="math-container">$X=\langle x_1, \dots,x_n\rangle$</span> are the solution by greedy, where <span class... | algorithms correctness proof greedy algorithms | 1 | How this proof of fractional knapsack works? -- (algorithms correctness proof greedy algorithms)
<p>I don't understand a step in my book proving the fractional knapsack problem:</p>
<blockquote>
<p>Let value of items <span class="math-container">$v_1\ge v_2\ge \dots\ge v_n$</span>, and assume <span class="math-... | habedi/stack-exchange-dataset |
102,232 | How to solve the following left recursion? | <p>A common left recursion: </p>

<pre><code>A -> Aa | B
</code></pre>

<p>can be solve by transforming it into:</p>

<pre><code>A -> BA'
A' -> aA' | E
</code></pre>

<p>However, I face another similar yet different left recursion when I'm writing my compiler:</p>&#... | formal grammars compilers parsers | 1 | How to solve the following left recursion? -- (formal grammars compilers parsers)
<p>A common left recursion: </p>

<pre><code>A -> Aa | B
</code></pre>

<p>can be solve by transforming it into:</p>

<pre><code>A -> BA'
A' -> aA' | E
</code></pre>

<p>However, I fac... | habedi/stack-exchange-dataset |
102,244 | Why any problem can be reduced to SAT is NP-Complete? | <p>I have a book statement says the title, I don't understand it. From my current understanding if a problem A can be reduced to a problem B then it only means B is at least as difficult as A.</p>
 | complexity theory np complete p vs np | 1 | Why any problem can be reduced to SAT is NP-Complete? -- (complexity theory np complete p vs np)
<p>I have a book statement says the title, I don't understand it. From my current understanding if a problem A can be reduced to a problem B then it only means B is at least as difficult as A.</p>
 | habedi/stack-exchange-dataset |
102,245 | Can Deterministic Context free Grammars be ambiguous? | <p>I know that DCFL are unambiguous languages and DCFL languages have one-to-one correspondence with LR grammars.</p>

<p>But I wanted to know if there can be an instance that deterministic context free grammar is ambiguous.</p>
 | formal languages context free formal grammars | 1 | Can Deterministic Context free Grammars be ambiguous? -- (formal languages context free formal grammars)
<p>I know that DCFL are unambiguous languages and DCFL languages have one-to-one correspondence with LR grammars.</p>

<p>But I wanted to know if there can be an instance that deterministic context free gram... | habedi/stack-exchange-dataset |
102,252 | Confusing notation in concatenation of error correcting codes | <p>Define an <span class="math-container">$(m,q,d,k)$</span>-(block) code <span class="math-container">$C$</span> to be a code with block size <span class="math-container">$m$</span>, alphabet <span class="math-container">$0\ldots ,q-1$</span>, and (non-relative) rate <span class="math-container">$k$</span>. Meaning: <... | error correcting codes | 1 | Confusing notation in concatenation of error correcting codes -- (error correcting codes)
<p>Define an <span class="math-container">$(m,q,d,k)$</span>-(block) code <span class="math-container">$C$</span> to be a code with block size <span class="math-container">$m$</span>, alphabet <span class="math-container">$0\ldots... | habedi/stack-exchange-dataset |
102,253 | Divide and Conquer Algorithm to calculate $a^n$ | <p>I am attempting to create an algorithm which given the value of <span class="math-container">$a \in \mathbb{R}$</span> and <span class="math-container">$b \in \mathbb{N}$</span>, calculate <span class="math-container">$a^n$</span>.</p>

<p>So for example, using the Java language pattern, the algorithm will b... | algorithms divide and conquer pseudocode | 1 | Divide and Conquer Algorithm to calculate $a^n$ -- (algorithms divide and conquer pseudocode)
<p>I am attempting to create an algorithm which given the value of <span class="math-container">$a \in \mathbb{R}$</span> and <span class="math-container">$b \in \mathbb{N}$</span>, calculate <span class="math-container">$a^n$... | habedi/stack-exchange-dataset |
102,254 | Flow value over edges in Max flow/Min Cut Ford Fulkerson | <p>Is it true that if a given edge e is in the min cut of a graph that there exists a max flow of the graph that has e with its full capacity?</p>
 | ford fulkerson | 1 | Flow value over edges in Max flow/Min Cut Ford Fulkerson -- (ford fulkerson)
<p>Is it true that if a given edge e is in the min cut of a graph that there exists a max flow of the graph that has e with its full capacity?</p>
 | habedi/stack-exchange-dataset |
102,260 | If a non-deterministic Turing machine runs in f(n) space, then why does it run in 2^O(f(n)) time? | <p>Assuming that f(n) >= n.</p>

<p>If possible, I'd like a proof in terms of Turing machines. I understand the reason why with machines that run on binary, because each "tape cell" is a bit with either 0 or 1, but in Turing machines a tape cell could hold any number of symbols. I'm having trouble why the base ... | complexity theory turing machines | 1 | If a non-deterministic Turing machine runs in f(n) space, then why does it run in 2^O(f(n)) time? -- (complexity theory turing machines)
<p>Assuming that f(n) >= n.</p>

<p>If possible, I'd like a proof in terms of Turing machines. I understand the reason why with machines that run on binary, because each "tape... | habedi/stack-exchange-dataset |
102,284 | Reducing linear programming to positive linear programming | <p>Suppose we have an oracle that solves problems of the form</p>

<p><span class="math-container">\begin{align*}
\text{maximize} ~~ & c^T x
\\
\text{subject to} ~~ & A x = b, x\geq 0
\end{align*}</span></p>

<p>when <span class="math-container">$c\geq 0$</span> (all coefficients... | linear programming | 1 | Reducing linear programming to positive linear programming -- (linear programming)
<p>Suppose we have an oracle that solves problems of the form</p>

<p><span class="math-container">\begin{align*}
\text{maximize} ~~ & c^T x
\\
\text{subject to} ~~ & A x = b, x\geq 0
\end{align*}</span></... | habedi/stack-exchange-dataset |
102,290 | Why are there two not operators in lambda calculus? | <p>From <a href="https://en.wikipedia.org/w/index.php?title=Church_encoding&oldid=874761158#Church_Booleans" rel="nofollow noreferrer">Wikipedia</a>:</p>
<blockquote>
<p><span class="math-container">$\mathrm{true} = \lambda a. \lambda b. a$</span><br />
<span class="math-container">$\mathrm{false} = \la... | lambda calculus functional programming boolean algebra | 1 | Why are there two not operators in lambda calculus? -- (lambda calculus functional programming boolean algebra)
<p>From <a href="https://en.wikipedia.org/w/index.php?title=Church_encoding&oldid=874761158#Church_Booleans" rel="nofollow noreferrer">Wikipedia</a>:</p>
<blockquote>
<p><span class="math-containe... | habedi/stack-exchange-dataset |
102,296 | The definition of weakest precondition for a non-deterministic language | <p>In the classical IMP language, the definition of weakest precondition is:</p>

<pre><code>definition "wp c Q s ≡ ∃t. (c,s) ⇒ t ∧ Q t"
</code></pre>

<p>This is stating that from state s, after executing c we get to a state satisfying Q. My question comes when handling the IF FI construct in the l... | reference request nondeterminism semantics formal methods | 1 | The definition of weakest precondition for a non-deterministic language -- (reference request nondeterminism semantics formal methods)
<p>In the classical IMP language, the definition of weakest precondition is:</p>

<pre><code>definition "wp c Q s ≡ ∃t. (c,s) ⇒ t ∧ Q t"
</code></pre>

<p>This is st... | habedi/stack-exchange-dataset |
102,312 | Real RAM computational mode | <p>Given a real value <span class="math-container">$M>0$</span>, I want to compute the greatest value of <span class="math-container">$\epsilon$</span> strictly smaller than <span class="math-container">$M$</span>. Given the assumption that the computational model is Real-RAM, how to find a real number sufficiently ... | algorithms computational geometry mathematical analysis numerical analysis real numbers | 1 | Real RAM computational mode -- (algorithms computational geometry mathematical analysis numerical analysis real numbers)
<p>Given a real value <span class="math-container">$M>0$</span>, I want to compute the greatest value of <span class="math-container">$\epsilon$</span> strictly smaller than <span class="math-cont... | habedi/stack-exchange-dataset |
102,314 | Can 2-philosophers problem be analogous to dining philosophers problem? | <p>Two philosophers A and B, two forks numbered "1", "2"; A needs both "1" and "2" for eating, so does B.</p>

<p>Is this theoretical a dining philosopher problem? I'm questioning about the forks philosopher A needs all come from B. However, the DP problem usually gives an example of 5 philosophers, in which ca... | algorithms concurrency synchronization deadlocks | 1 | Can 2-philosophers problem be analogous to dining philosophers problem? -- (algorithms concurrency synchronization deadlocks)
<p>Two philosophers A and B, two forks numbered "1", "2"; A needs both "1" and "2" for eating, so does B.</p>

<p>Is this theoretical a dining philosopher problem? I'm questioning about ... | habedi/stack-exchange-dataset |
102,336 | Prooving by Pigeonhole principle | <p>I've been given a question to solve:</p>

<p><code>Given a set of non-negative distinct integers, and a value m, determine if there is a subset of the given set with sum divisible by m.</code></p>

<p>For this, I used the dynamic programming approach which is not optimized and takes <strong>O(m * m *... | algorithms dynamic programming proof techniques | 1 | Prooving by Pigeonhole principle -- (algorithms dynamic programming proof techniques)
<p>I've been given a question to solve:</p>

<p><code>Given a set of non-negative distinct integers, and a value m, determine if there is a subset of the given set with sum divisible by m.</code></p>

<p>For this, I us... | habedi/stack-exchange-dataset |
102,340 | Technique for converting recursive DP to iterative DP | <p>I'm new to Dynamic Programming and before this, I used to solve most of the problems using recursion(if needed). </p>

<p>But, I'm unable to convert my <code>recursive code</code> to <code>DP code</code>. </p>

<p>For eg, below is the <strong>pseudo-code</strong> for <code>Finding longest common-sub... | algorithms dynamic programming recursion | 1 | Technique for converting recursive DP to iterative DP -- (algorithms dynamic programming recursion)
<p>I'm new to Dynamic Programming and before this, I used to solve most of the problems using recursion(if needed). </p>

<p>But, I'm unable to convert my <code>recursive code</code> to <code>DP code</code>. </p... | habedi/stack-exchange-dataset |
102,363 | How many pairs of brackets are sufficient to make Brainfuck Turing complete? | <p>Brainfuck is a Turing complete programming language that uses only 8 symbols (6 if you ignore I/O).</p>

<p>The two most notable ones that push it to Turing completeness are <code>[</code>and <code>]</code>, essentially Brainfuck's label and goto.</p>

<p>Normally, programs in Brainfuck use multiple ... | turing completeness | 1 | How many pairs of brackets are sufficient to make Brainfuck Turing complete? -- (turing completeness)
<p>Brainfuck is a Turing complete programming language that uses only 8 symbols (6 if you ignore I/O).</p>

<p>The two most notable ones that push it to Turing completeness are <code>[</code>and <code>]</code>,... | habedi/stack-exchange-dataset |
102,368 | Will MST find the shortest path for each pair $(r,v)$? | <p>Will local best choice will lead to global best choice? In other words, I'm thinking about whether it's possible that the MST has to put its branch location in the middle of two far nodes <code>A</code>,<code>B</code> and thus would make the path from root to <code>A</code> and <code>B</code> respectively not the gl... | algorithms graphs shortest path minimum spanning tree | 1 | Will MST find the shortest path for each pair $(r,v)$? -- (algorithms graphs shortest path minimum spanning tree)
<p>Will local best choice will lead to global best choice? In other words, I'm thinking about whether it's possible that the MST has to put its branch location in the middle of two far nodes <code>A</code>,... | habedi/stack-exchange-dataset |
102,370 | What's the usage of $S$ in Dijkstra shortest path algorithm in the book Introduction to Algorithms? | <p>I don't understand how the <span class="math-container">$S$</span> is needed in dijkstra shortest path algorithm. For each node <span class="math-container">$v$</span> in <span class="math-container">$G.V$</span>, the <span class="math-container">$v.\pi = previous\_node$</span> is used to denote it previous node in ... | algorithms graphs shortest path minimum spanning tree | 1 | What's the usage of $S$ in Dijkstra shortest path algorithm in the book Introduction to Algorithms? -- (algorithms graphs shortest path minimum spanning tree)
<p>I don't understand how the <span class="math-container">$S$</span> is needed in dijkstra shortest path algorithm. For each node <span class="math-container">$... | habedi/stack-exchange-dataset |
102,383 | Binary 2s Compliment Applied Twice Gives Original - How? | <p>At the moment the maths behind binary 2s compliment seems like voodoo to me.</p>

<p>If I take 0011 (+3) and "flip and add 1", I get 1101 (-3)</p>

<p>If I apply the same process to 1101, ("flip and add 1"), I get back to the original positive value.</p>

<p>How is this so?</p>
 | binary numeral representations | 1 | Binary 2s Compliment Applied Twice Gives Original - How? -- (binary numeral representations)
<p>At the moment the maths behind binary 2s compliment seems like voodoo to me.</p>

<p>If I take 0011 (+3) and "flip and add 1", I get 1101 (-3)</p>

<p>If I apply the same process to 1101, ("flip and add 1"), ... | habedi/stack-exchange-dataset |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.