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 |
|---|---|---|---|---|---|---|
52,080 | Why can't we find shortest paths with negative weights by just adding a constant so that all weights are positive? | <p>I'm currently reading introduction to algorithms and came by Johnson’s algorithm that depends on making sure that all paths are positive.</p>

<p>the algo depends on finding a new weight function (w') that is positive for all edges and keeps the correctness of the shortest paths relations.</p>

<p>It... | algorithms graphs shortest path | 1 | Why can't we find shortest paths with negative weights by just adding a constant so that all weights are positive? -- (algorithms graphs shortest path)
<p>I'm currently reading introduction to algorithms and came by Johnson’s algorithm that depends on making sure that all paths are positive.</p>

<p>the algo de... | habedi/stack-exchange-dataset |
52,093 | If a machine recognizes language L, can it also recognize L*? | <p>This is a homework question. Suppose the only accept state is the start state. My rationale for this is that L* is just the concatenations of L, so if all strings in L are accepted, then all strings in L* will be accepted as well. One problem I see with this is that a machine can only accept one language, so it migh... | formal languages regular languages finite automata | 1 | If a machine recognizes language L, can it also recognize L*? -- (formal languages regular languages finite automata)
<p>This is a homework question. Suppose the only accept state is the start state. My rationale for this is that L* is just the concatenations of L, so if all strings in L are accepted, then all strings ... | habedi/stack-exchange-dataset |
52,097 | Implementing regular expression matching using Brzozowski derivatives | <p>I have been taking a language theory class, and we learned about Brzozowski derivatives recently. At class it occurred to me that they could be used to implement a simple regular expression matcher. If you take the derivative of a regular expression with respect to a given string and the resulting expression matches... | formal languages regular expressions | 1 | Implementing regular expression matching using Brzozowski derivatives -- (formal languages regular expressions)
<p>I have been taking a language theory class, and we learned about Brzozowski derivatives recently. At class it occurred to me that they could be used to implement a simple regular expression matcher. If you... | habedi/stack-exchange-dataset |
52,108 | Shortest path in divisors graph | <p>There is a graph with N vertices numbered from 1 to N. Edge between a and b exists if and only if a|b or b|a. If a|b then the weight of the edge is b/a. If b|a then the weight of the edge is a/b. Given two vertices u and v, I want to find the length of the shortest path between them. I think that the shortest path s... | graphs combinatorics number theory | 1 | Shortest path in divisors graph -- (graphs combinatorics number theory)
<p>There is a graph with N vertices numbered from 1 to N. Edge between a and b exists if and only if a|b or b|a. If a|b then the weight of the edge is b/a. If b|a then the weight of the edge is a/b. Given two vertices u and v, I want to find the le... | habedi/stack-exchange-dataset |
52,111 | Why is $L=wxw^R|w,x\in\{0,1\}^+$ regular? | <p>I was taught that if you can create a DFA to accept a language, then the grammar that is generating the language is regular.</p>

<p><strong>AND</strong></p>

<p>A DFA is a finite automata that accepts a language and also <strong><em>rejects</em></strong> the strings that aren't a part of the languag... | formal languages regular languages finite automata formal grammars | 1 | Why is $L=wxw^R|w,x\in\{0,1\}^+$ regular? -- (formal languages regular languages finite automata formal grammars)
<p>I was taught that if you can create a DFA to accept a language, then the grammar that is generating the language is regular.</p>

<p><strong>AND</strong></p>

<p>A DFA is a finite automat... | habedi/stack-exchange-dataset |
52,116 | Computer cache - data removing | <p>I am programming <strong>CPU cache simulator</strong> and I am supposed to implement removing of entries. I will not use LRU but just random.</p>

<p>I am not really clear, when should I call the removing function? When cache <em>(2 or 4 caches)</em> are full and CPU wants to write into cache where all <em>(... | terminology computer architecture cpu cache memory hardware | 1 | Computer cache - data removing -- (terminology computer architecture cpu cache memory hardware)
<p>I am programming <strong>CPU cache simulator</strong> and I am supposed to implement removing of entries. I will not use LRU but just random.</p>

<p>I am not really clear, when should I call the removing function... | habedi/stack-exchange-dataset |
52,127 | Efficient algorithm to generate undirected graph edges from 3D distribution of nodes based on distance | <p>I have a set of nodes where each node $n_i$ is associated with a cartesian coordinate $\vec r_i$ and a radius $\sigma_i$. I want to generate a graph data structure where nodes $n_i$ and $n_j$ are connected by an undirected edge if $|r_{ij}| < \sigma_i + \sigma_j$. This is not my field and I am interested in effic... | graphs | 1 | Efficient algorithm to generate undirected graph edges from 3D distribution of nodes based on distance -- (graphs)
<p>I have a set of nodes where each node $n_i$ is associated with a cartesian coordinate $\vec r_i$ and a radius $\sigma_i$. I want to generate a graph data structure where nodes $n_i$ and $n_j$ are connec... | habedi/stack-exchange-dataset |
52,130 | Proof that this problem is in NP | <p>I have to prove the following problem is in NP (and define verifier as well as the certificate/witness): </p>

<p>The input is a set of $n$ boxes with weights $w_{1},\ldots,w_{n}$ and two numbers $s$ and $t$ (all natural numbers).
Can the boxes be loaded onto $s$ trucks if each truck can only carry a tot... | complexity theory np | 1 | Proof that this problem is in NP -- (complexity theory np)
<p>I have to prove the following problem is in NP (and define verifier as well as the certificate/witness): </p>

<p>The input is a set of $n$ boxes with weights $w_{1},\ldots,w_{n}$ and two numbers $s$ and $t$ (all natural numbers).
Can the boxes b... | habedi/stack-exchange-dataset |
52,137 | Finding a certain prefix of a string | <p>Let $\Sigma = \{ \sigma_1 , ..., \sigma_t \}$ and let $S$ be a string from $\Sigma^*$. Denote: $n=|S|$, that is $S$ has $n$ letters. I'd like to find the <strong>shortest</strong> prefix $T$ of $S$ such that $S$ is a prefix of $T^n$ ($T^n= T \cdot .... \cdot T$, $n$ times).</p>

<p>I tried to build the suffi... | algorithms optimization strings substrings suffix trees | 1 | Finding a certain prefix of a string -- (algorithms optimization strings substrings suffix trees)
<p>Let $\Sigma = \{ \sigma_1 , ..., \sigma_t \}$ and let $S$ be a string from $\Sigma^*$. Denote: $n=|S|$, that is $S$ has $n$ letters. I'd like to find the <strong>shortest</strong> prefix $T$ of $S$ such that $S$ is a pr... | habedi/stack-exchange-dataset |
52,141 | IF A is reduced to B and B belongs to NPC then where does A belongs to? | <p>i came across a question with no proper explnation.
IF A is reduced to B and B belongs to NPC then we cant say anything about A since it can be as harder a NPH and as easier as P.
i know why it is as harder as NHP but i am not able to figure out about P class.</p>

<p>according to me if A > B(A polyn... | complexity theory np complete reductions | 1 | IF A is reduced to B and B belongs to NPC then where does A belongs to? -- (complexity theory np complete reductions)
<p>i came across a question with no proper explnation.
IF A is reduced to B and B belongs to NPC then we cant say anything about A since it can be as harder a NPH and as easier as P.
i know why ... | habedi/stack-exchange-dataset |
52,154 | Learning parameters of noise and filter coefficients from data where data and noise both have Gaussian distributions | <p>Assume $X$ and $N$ are two sets of vectors (observations) from a normal distribution, where $X$ represents clean data and $N$ represents noise; and $A$ a projection matrix of a filter. The scenario is that our clean data was corrupted by a multiplicative noise via matrix $A$ and an additive noise of $N$: </p>
&#... | statistics error estimation | 1 | Learning parameters of noise and filter coefficients from data where data and noise both have Gaussian distributions -- (statistics error estimation)
<p>Assume $X$ and $N$ are two sets of vectors (observations) from a normal distribution, where $X$ represents clean data and $N$ represents noise; and $A$ a projection ma... | habedi/stack-exchange-dataset |
52,161 | DPDA for $L_1 = \{0^i1^j2^k3^m | i,j,k\ge 0,m = i+j+k\}$ according to empty stack criterion | <p>I'm having some trouble with the following language:</p>

<p>$L_1 = \{0^i1^j2^k3^m | i,j,k\ge 0,m = i+j+k\}$</p>

<p>with alphabet $A=\{0,1,2,3\}$</p>

<p>I'd like to find a deterministic pushdown automata to recognise it according to the empty stack criterion. </p>

<p>I built the de... | context free pushdown automata | 1 | DPDA for $L_1 = \{0^i1^j2^k3^m | i,j,k\ge 0,m = i+j+k\}$ according to empty stack criterion -- (context free pushdown automata)
<p>I'm having some trouble with the following language:</p>

<p>$L_1 = \{0^i1^j2^k3^m | i,j,k\ge 0,m = i+j+k\}$</p>

<p>with alphabet $A=\{0,1,2,3\}$</p>

<p>I'd like t... | habedi/stack-exchange-dataset |
52,167 | checking if string is generated by regular grammar | <p>How do I check wether a string is generated by given regular grammar?
I know you can check for it in O(N), what is the algorithm called?</p>
 | regular languages | 1 | checking if string is generated by regular grammar -- (regular languages)
<p>How do I check wether a string is generated by given regular grammar?
I know you can check for it in O(N), what is the algorithm called?</p>
 | habedi/stack-exchange-dataset |
52,169 | From NFA to DFA (basics) | <p>I am trying to learn NFA to DFA.</p>

<p>This is the original image
<a href="https://i.stack.imgur.com/rXvO8.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/rXvO8.png" alt="NFA"></a></p>

<p>To begin the process of converting to DFA, I started off with the start state and notic... | finite automata | 1 | From NFA to DFA (basics) -- (finite automata)
<p>I am trying to learn NFA to DFA.</p>

<p>This is the original image
<a href="https://i.stack.imgur.com/rXvO8.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/rXvO8.png" alt="NFA"></a></p>

<p>To begin the process of converting to DFA... | habedi/stack-exchange-dataset |
52,176 | primitive recursion in the lambda calculus | <p>I am having trouble finding out what a primitive subset of the lambda calculus would look like. I reference primitive recursion as shown here: "<a href="https://en.wikipedia.org/wiki/Primitive_recursive_function" rel="nofollow">https://en.wikipedia.org/wiki/Primitive_recursive_function</a>".</p>

<p>These ar... | recursion lambda calculus primitive recursion | 1 | primitive recursion in the lambda calculus -- (recursion lambda calculus primitive recursion)
<p>I am having trouble finding out what a primitive subset of the lambda calculus would look like. I reference primitive recursion as shown here: "<a href="https://en.wikipedia.org/wiki/Primitive_recursive_function" rel="nofol... | habedi/stack-exchange-dataset |
52,181 | Ways to implement a decision making process involving complex rules | <p>I'm investigating different solutions for solving what looks like a decision making problem. Although the domain I'm working on is different, for the problem at hand, it's quite easy explaining with an example of online shopping cart.</p>

<p>Suppose you have a shopping cart like you have in every online ret... | algorithms data structures | 1 | Ways to implement a decision making process involving complex rules -- (algorithms data structures)
<p>I'm investigating different solutions for solving what looks like a decision making problem. Although the domain I'm working on is different, for the problem at hand, it's quite easy explaining with an example of onli... | habedi/stack-exchange-dataset |
52,186 | Are these three subset sum problems hard? How to solve them? | <p>After asking <a href="https://cs.stackexchange.com/questions/52150/how-to-select-a-subset-of-items-in-two-different-sets-such-that-their-product-is">this question</a> I was thinking about some variants of subset sum problem (SSP).</p>

<p>The usual subset problem is the following.</p>

<ul>
<li><... | algorithms np complete | 1 | Are these three subset sum problems hard? How to solve them? -- (algorithms np complete)
<p>After asking <a href="https://cs.stackexchange.com/questions/52150/how-to-select-a-subset-of-items-in-two-different-sets-such-that-their-product-is">this question</a> I was thinking about some variants of subset sum problem (SSP... | habedi/stack-exchange-dataset |
52,188 | What do you call a function from symbols of alphabet to languages? | <p>Speaking of context-free (and maybe regular? or just any?) languages, what do you call a function defined as follows:</p>

<p>Let $\Sigma$ be the alphabet of $L$, $\forall \sigma \in \Sigma: f(\sigma) = L'$, where $L'$ is some language. I also met this definition: $f:\Sigma \to 2^{\Delta^*}$.</p>

<p... | formal languages terminology strings | 1 | What do you call a function from symbols of alphabet to languages? -- (formal languages terminology strings)
<p>Speaking of context-free (and maybe regular? or just any?) languages, what do you call a function defined as follows:</p>

<p>Let $\Sigma$ be the alphabet of $L$, $\forall \sigma \in \Sigma: f(\sigma)... | habedi/stack-exchange-dataset |
52,193 | Prove correctness of recursive algorithm | <p>I have this java function:</p>

<pre><code>public int foo(ArrayList l, int n)
{
 if(n <= 1)
 return l.get(0);

 if(l.get(0) < l.get(1))
 l.remove(1);
 else
 l.remove(0);

 foo(l, n-1);
}
</code></pre>

<p>So I figure to show that the ... | algorithms algorithm analysis proof techniques induction | 1 | Prove correctness of recursive algorithm -- (algorithms algorithm analysis proof techniques induction)
<p>I have this java function:</p>

<pre><code>public int foo(ArrayList l, int n)
{
 if(n <= 1)
 return l.get(0);

 if(l.get(0) < l.get(1))
 l.remove(1);
 else
 ... | habedi/stack-exchange-dataset |
52,194 | Indexing billion domain names / strings | <p>I am trying to find any datastructure/algorithm suitable to index & retrieve domain names & its associated documents.</p>

<p>The records that need indexing will typically be like:</p>

<pre><code>www.facebook.com, 123
stackoverflow.com, 1231
www.facebook.com, 124
stackoverflow.co... | algorithms data structures | 1 | Indexing billion domain names / strings -- (algorithms data structures)
<p>I am trying to find any datastructure/algorithm suitable to index & retrieve domain names & its associated documents.</p>

<p>The records that need indexing will typically be like:</p>

<pre><code>www.facebook.com, 123&#x... | habedi/stack-exchange-dataset |
52,197 | recursively enumerable sets closed under concatenation | <p>I'm trying to show the set of all recursively enumerable sets is closed under concatenation. I'm trying to use the definition of recursively enumerable sets to construct the argument. I believe that I must consider the Cartesian product $S_1\times S_2$ of two recursively enumerable sets $S_1$ and $S_2$. Then I cons... | computability | 1 | recursively enumerable sets closed under concatenation -- (computability)
<p>I'm trying to show the set of all recursively enumerable sets is closed under concatenation. I'm trying to use the definition of recursively enumerable sets to construct the argument. I believe that I must consider the Cartesian product $S_1\... | habedi/stack-exchange-dataset |
52,201 | An online algorithm to find the Pareto frontier elements | <p>I'm looking for an online algorithm that takes a stream of elements and preserves the elements that are on the <a href="https://en.wikipedia.org/wiki/Pareto_efficiency#Pareto_frontier" rel="nofollow">Pareto frontier</a> (e.g. all non-dominated elements).</p>

<p>For instance. Given the following inputs, the ... | algorithms search algorithms | 1 | An online algorithm to find the Pareto frontier elements -- (algorithms search algorithms)
<p>I'm looking for an online algorithm that takes a stream of elements and preserves the elements that are on the <a href="https://en.wikipedia.org/wiki/Pareto_efficiency#Pareto_frontier" rel="nofollow">Pareto frontier</a> (e.g. ... | habedi/stack-exchange-dataset |
52,214 | Solving the recurrence $T(n)=T(n-1)*T(n-2)$ | <p>I have been trying to solve the following recurrence: </p>

<p>$$T(n)=T(n-1)*T(n-2)$$ 
The initial conditions are $n \ge 2$ and $T(0) = 2$ and $T(1) = 4$.</p>

<p>I started by taking the $\log_{2}$ of both sides to get</p>

<p>$$\log(T(n)) = \log(T(n-1)) + \log(T(n-2))$$</p>

<p>w... | recurrence relation | 1 | Solving the recurrence $T(n)=T(n-1)*T(n-2)$ -- (recurrence relation)
<p>I have been trying to solve the following recurrence: </p>

<p>$$T(n)=T(n-1)*T(n-2)$$ 
The initial conditions are $n \ge 2$ and $T(0) = 2$ and $T(1) = 4$.</p>

<p>I started by taking the $\log_{2}$ of both sides to get</p>
&... | habedi/stack-exchange-dataset |
52,217 | How to prove the following language is not in R | <p>Let $c\in \mathbb{N}$. Denote: $L _c= \{ \langle M \rangle \mid \exists _{U \subseteq \Sigma ^* }$ s.t. $|U| $ is infinite and for each $w\in U $ the TM $M$ accepts $w$ within no more than $c$ steps $\} $. </p>

<p>I would like to prove that for any given $c$ the language $L_c \notin R $.</p>

<p>I w... | computability reductions undecidability | 1 | How to prove the following language is not in R -- (computability reductions undecidability)
<p>Let $c\in \mathbb{N}$. Denote: $L _c= \{ \langle M \rangle \mid \exists _{U \subseteq \Sigma ^* }$ s.t. $|U| $ is infinite and for each $w\in U $ the TM $M$ accepts $w$ within no more than $c$ steps $\} $. </p>

<p>I... | habedi/stack-exchange-dataset |
52,220 | How can another process call $signal()$ when one process is executing $wait()$ in its busy waiting loop? | <p>A semaphore is a variable that, apart from initialization is accessed through only two standard atomic operations wait(s) and signal(s).</p>

<pre><code>wait(S){
 while S <= 0
 ; //no-op
 s--;
}

signal(S){
 s++;
}
</code></pre>

<p>The function $wai... | operating systems concurrency | 1 | How can another process call $signal()$ when one process is executing $wait()$ in its busy waiting loop? -- (operating systems concurrency)
<p>A semaphore is a variable that, apart from initialization is accessed through only two standard atomic operations wait(s) and signal(s).</p>

<pre><code>wait(S){
 ... | habedi/stack-exchange-dataset |
52,222 | Computing farthest pair of points in d dimensions | <p>Question: Given $n$ points in metric space, find a pair of points with the largest distance between them. </p>

<p>If we restrict ourselves to $d$-dimensional Euclidean space then, a naive algorithm of finding distances between all pairs of points in a space of dimension $d$ and selecting the maximum require... | algorithms computational geometry | 1 | Computing farthest pair of points in d dimensions -- (algorithms computational geometry)
<p>Question: Given $n$ points in metric space, find a pair of points with the largest distance between them. </p>

<p>If we restrict ourselves to $d$-dimensional Euclidean space then, a naive algorithm of finding distances ... | habedi/stack-exchange-dataset |
52,229 | Using the Master theorem on a recurrence with non-constant a | <p>I am trying to solve the following equation using master's theorem.</p>

<p>$T(n) = 3^n T(\frac{n} 3) + O(1)$</p>

<p>Extracting the b and $f(n)$ values makes sense they are $b=3$ and $f(n)=1$. I am not sure what my $a$ value is I don't think its just 3.</p>
 | asymptotics recurrence relation master theorem | 1 | Using the Master theorem on a recurrence with non-constant a -- (asymptotics recurrence relation master theorem)
<p>I am trying to solve the following equation using master's theorem.</p>

<p>$T(n) = 3^n T(\frac{n} 3) + O(1)$</p>

<p>Extracting the b and $f(n)$ values makes sense they are $b=3$ and $f(... | habedi/stack-exchange-dataset |
52,232 | How to argue about semi-decidability of a problem? | <p>I have the following problem, and I try to prove that it is semi-decidable, but I have a hard time arguing about it.</p>

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

<p>I know th... | complexity theory semi decidability | 1 | How to argue about semi-decidability of a problem? -- (complexity theory semi decidability)
<p>I have the following problem, and I try to prove that it is semi-decidable, but I have a hard time arguing about it.</p>

<p><a href="https://i.stack.imgur.com/q8VFT.png" rel="nofollow noreferrer"><img src="https://i.... | habedi/stack-exchange-dataset |
52,233 | Minimum variable size if the information are coded in non-binary system | <p>A typical HDD would represent information as either 1 (e.g. spin up) or 0 (e.g. spin down). Let's assume you want to represent the information physically in a hex system with 16 states, and assume this is possible with using some physical form (maybe the same spin).</p>

<p>What is the minimum physical size ... | knowledge representation | 1 | Minimum variable size if the information are coded in non-binary system -- (knowledge representation)
<p>A typical HDD would represent information as either 1 (e.g. spin up) or 0 (e.g. spin down). Let's assume you want to represent the information physically in a hex system with 16 states, and assume this is possible w... | habedi/stack-exchange-dataset |
52,245 | Find Big O using Iteration | <p>I am trying to find Big O of this formula: $T(n)=T(n-1)+2n$ by using iteration however I am stuck on a step.</p>

<p>$T(n)=T(n-1)+2n$ I then plugged $T(n-1)$ into the equation so $T(n-1)=T(n-1-1)+2(n-1)$ which then I got $T(n)=T(n-2)+2(n-1)+2n$. $T(n-2)$ gives $T(n-3)+2(n-3)$ which plugging it back in gives ... | recurrence relation landau notation | 1 | Find Big O using Iteration -- (recurrence relation landau notation)
<p>I am trying to find Big O of this formula: $T(n)=T(n-1)+2n$ by using iteration however I am stuck on a step.</p>

<p>$T(n)=T(n-1)+2n$ I then plugged $T(n-1)$ into the equation so $T(n-1)=T(n-1-1)+2(n-1)$ which then I got $T(n)=T(n-2)+2(n-1)+... | habedi/stack-exchange-dataset |
52,258 | Recognizing primitive recursion | <p>I am trying to write a program to recognize if a given lambda calculus expression is primitive recursive. I believe that a general algorithm to do this does not exist, but I am interested in the most general algorithm. This is a subset of the primitive recursive functions in the LC. </p>

<p>Primitive recurs... | lambda calculus primitive recursion church numerals static analysis | 1 | Recognizing primitive recursion -- (lambda calculus primitive recursion church numerals static analysis)
<p>I am trying to write a program to recognize if a given lambda calculus expression is primitive recursive. I believe that a general algorithm to do this does not exist, but I am interested in the most general algo... | habedi/stack-exchange-dataset |
52,270 | Expected number of independent sets of size $k$ in random graph $G(n,p)$ | <p>I am looking for a formula for determining the expected number of independent sets of size $k$ (for arbitrary $k$) in a random graph $G(n,p)$. Here $n$ is the number of vertices and each edge is included with independent probability $p$. I would like to be able to calculate this for arbitrary $p$ if possible.</p>&#x... | graphs clique | 1 | Expected number of independent sets of size $k$ in random graph $G(n,p)$ -- (graphs clique)
<p>I am looking for a formula for determining the expected number of independent sets of size $k$ (for arbitrary $k$) in a random graph $G(n,p)$. Here $n$ is the number of vertices and each edge is included with independent prob... | habedi/stack-exchange-dataset |
52,275 | How to show that a problem is easy? | <p>Let $P$ be a problem that you need to study its difficulty, i.e., NP-hard, Polynomial-time solvable, etc.</p>

<blockquote>
 <p>My question is: If I reduce a known polynomial time problem (say,
 maximum matching in bipartite graph) to $P$, why I can say that $P$ is an
 easy problem?</p>
</... | complexity theory reductions | 1 | How to show that a problem is easy? -- (complexity theory reductions)
<p>Let $P$ be a problem that you need to study its difficulty, i.e., NP-hard, Polynomial-time solvable, etc.</p>

<blockquote>
 <p>My question is: If I reduce a known polynomial time problem (say,
 maximum matching in bipartite grap... | habedi/stack-exchange-dataset |
52,280 | Does exponentiation reduce to multiplication or the other way around? | <p>Is is more accurate to say that in complexity theory:</p>

<p>$$\text{exponentiation} \leq_p \text{multiplication}$$</p>

<p>or</p>

<p>$$\text{multiplication} \leq_p \text{exponentiation}$$</p>

<p>I understand that if we know how to do multiplication, then we can run multiplication ... | complexity theory reductions | 1 | Does exponentiation reduce to multiplication or the other way around? -- (complexity theory reductions)
<p>Is is more accurate to say that in complexity theory:</p>

<p>$$\text{exponentiation} \leq_p \text{multiplication}$$</p>

<p>or</p>

<p>$$\text{multiplication} \leq_p \text{exponentiation}$... | habedi/stack-exchange-dataset |
52,292 | What happens to uninterpreted predicates in Ackermann's reduction? | <p>I know the procedure to apply the Ackermann's reduction to a formula that doesn't involve uninterpreted predicates. But, how do we treat the uninterpreted boolean predicates? Nearly all the examples I have seen, usually just assume there are no uninterpreted predicates, and give examples of simpler reductions, but i... | satisfiability boolean algebra automated theorem proving | 1 | What happens to uninterpreted predicates in Ackermann's reduction? -- (satisfiability boolean algebra automated theorem proving)
<p>I know the procedure to apply the Ackermann's reduction to a formula that doesn't involve uninterpreted predicates. But, how do we treat the uninterpreted boolean predicates? Nearly all th... | habedi/stack-exchange-dataset |
52,294 | NP-Completeness: A question about reduction and hardness | <p>I am trying to understand the definition / meaning of reduction.</p>

<ol>
<li><p>Is it correct to say that the statement "Problem $A$ reduces to Problem $B$ in $x$-time" is the same as writing $A \leq_{x} B$? For example $\text{SAT} \leq_{polynomial} \text{3-SAT}$.</p></li>
<li><p>If we are reducing... | complexity theory np complete | 1 | NP-Completeness: A question about reduction and hardness -- (complexity theory np complete)
<p>I am trying to understand the definition / meaning of reduction.</p>

<ol>
<li><p>Is it correct to say that the statement "Problem $A$ reduces to Problem $B$ in $x$-time" is the same as writing $A \leq_{x} B$? For... | habedi/stack-exchange-dataset |
52,298 | Can I simplify the recurrence T(n) = 2T((n+1)/2) + c by ignoring the "+1" part? | <p>I have written a recurrence relation to describe a recursive algorithm finding the maximum element in an array. The algorthim has an overlap, meaning both of the subarrays that are recurred on contain the middle element of the array.</p>

<p>$T(n) = 2T((n+1)/2) + c$</p>

<p>However, I want to simplif... | asymptotics recurrence relation | 1 | Can I simplify the recurrence T(n) = 2T((n+1)/2) + c by ignoring the "+1" part? -- (asymptotics recurrence relation)
<p>I have written a recurrence relation to describe a recursive algorithm finding the maximum element in an array. The algorthim has an overlap, meaning both of the subarrays that are recurred on contain... | habedi/stack-exchange-dataset |
52,302 | Designing a DFA for binary strings having 1 as the fourth character from the end | <p>I came across someone else's old post here </p>

<p><a href="https://cs.stackexchange.com/questions/14008/designing-a-dfa-that-accepts-strings-such-that-nth-character-from-last-satisfies">Designing a DFA that accepts strings such that nth character from last satisfies condition</a></p>

<p>And decide... | regular languages automata finite automata | 1 | Designing a DFA for binary strings having 1 as the fourth character from the end -- (regular languages automata finite automata)
<p>I came across someone else's old post here </p>

<p><a href="https://cs.stackexchange.com/questions/14008/designing-a-dfa-that-accepts-strings-such-that-nth-character-from-last-sat... | habedi/stack-exchange-dataset |
52,305 | Proving that if A⊕B ∈ NP then NP = coNP | <p>I got this question:</p>

<blockquote>
 <p>Let $A \oplus B = (A\cap \bar{B})\cup(\bar{A}\cap B)$.</p>
 
 <p>Proof that $NP = coNP$ if and only if $A,B\in NP$ and $A \oplus B\in NP$.</p>
</blockquote>

<p>But I don't know how to proof the direction that if $A,B\in NP$ and $A \oplus ... | complexity theory time complexity | 1 | Proving that if A⊕B ∈ NP then NP = coNP -- (complexity theory time complexity)
<p>I got this question:</p>

<blockquote>
 <p>Let $A \oplus B = (A\cap \bar{B})\cup(\bar{A}\cap B)$.</p>
 
 <p>Proof that $NP = coNP$ if and only if $A,B\in NP$ and $A \oplus B\in NP$.</p>
</blockquote>

<p... | habedi/stack-exchange-dataset |
52,310 | Efficient formulation for binary integer linear programming | <p><strong>Problem</strong>:</p>

<p>There are two types of balls, big (B) and small (S), which need to packed into boxes. One box can contain either:</p>

<ol>
<li>nothing, or</li>
<li>1 S, or</li>
<li>1 B, or</li>
<li>2 S, or</li>
<li>2 B, or</li>
<li>1 B and 2 S</li>
</ol>... | efficiency linear programming integer programming modelling | 1 | Efficient formulation for binary integer linear programming -- (efficiency linear programming integer programming modelling)
<p><strong>Problem</strong>:</p>

<p>There are two types of balls, big (B) and small (S), which need to packed into boxes. One box can contain either:</p>

<ol>
<li>nothing, o... | habedi/stack-exchange-dataset |
52,314 | Universal/existential quantification? | <p>I'm struggling to understand the purpose of universal and existential quantification of types. I'm playing around with writing a toy language based on the <a href="https://en.wikipedia.org/wiki/Calculus_of_constructions">calculus of constructions</a>. I've been reading about <a href="https://hackage.haskell.org/pack... | lambda calculus type theory calculus of constructions | 1 | Universal/existential quantification? -- (lambda calculus type theory calculus of constructions)
<p>I'm struggling to understand the purpose of universal and existential quantification of types. I'm playing around with writing a toy language based on the <a href="https://en.wikipedia.org/wiki/Calculus_of_constructions"... | habedi/stack-exchange-dataset |
52,321 | Can we use reductions to design approximation algorithms for NP-hard problems? | <p>Let us say that I have a problem $P(n)$ that I need to solve (where $n$ is the size of the input of problem $P$). I used a polynomial-time reduction from a known NP-hard problem $Q(m)$ (where $m$ is the size of the input of problem $Q$) to $P(n)$ and showed that $P(n)$ is NP-hard. The time complexity of the reductio... | reductions np hard approximation polynomial time | 1 | Can we use reductions to design approximation algorithms for NP-hard problems? -- (reductions np hard approximation polynomial time)
<p>Let us say that I have a problem $P(n)$ that I need to solve (where $n$ is the size of the input of problem $P$). I used a polynomial-time reduction from a known NP-hard problem $Q(m)$... | habedi/stack-exchange-dataset |
52,324 | Language of words that begin and end with same symbol and have equal numbers of a's and b's | <p>I wish to find the CFG for a language on two symbols (say <em>a</em> and <em>b</em>) whose words begin and terminate with the same symbol, and have equal quantities of <em>a</em>'s and <em>b</em>'s. What is the thought process I should use for finding such a grammar? What is the most natural or simplest grammar fo... | formal languages context free formal grammars | 1 | Language of words that begin and end with same symbol and have equal numbers of a's and b's -- (formal languages context free formal grammars)
<p>I wish to find the CFG for a language on two symbols (say <em>a</em> and <em>b</em>) whose words begin and terminate with the same symbol, and have equal quantities of <em>a<... | habedi/stack-exchange-dataset |
52,329 | The language of machines that accepts all palindromes is not Turing recognizable | <p>I have this question:</p>

<blockquote>
 <p>$L = \{\langle M \rangle | M$ is TM that accepts every palindrome over
 its alphabet $\}$</p>
 
 <p>Proof that $L$ is not Turing-recognizable by showing reduction from other non Turing-recognizable language.</p>
</blockquote>

<p>Wha... | computability semi decidability | 1 | The language of machines that accepts all palindromes is not Turing recognizable -- (computability semi decidability)
<p>I have this question:</p>

<blockquote>
 <p>$L = \{\langle M \rangle | M$ is TM that accepts every palindrome over
 its alphabet $\}$</p>
 
 <p>Proof that $L$ is not Turin... | habedi/stack-exchange-dataset |
52,332 | Anotation rules for while rule in deductive verification | <p>I have been studying deductive verification of software lately, with weakest precondition, strongest postcondition, annotation calculus, and etc.</p>
<p>I came across the following rules for the while sentence:</p>
<p><a href="https://i.stack.imgur.com/yV4qU.png" rel="nofollow noreferrer"><img src="https://i... | formal methods software verification | 1 | Anotation rules for while rule in deductive verification -- (formal methods software verification)
<p>I have been studying deductive verification of software lately, with weakest precondition, strongest postcondition, annotation calculus, and etc.</p>
<p>I came across the following rules for the while sentence:</p>... | habedi/stack-exchange-dataset |
52,341 | Oblivious RAM write protection | <p>I'm trying to understand how oblivious RAM works, specifically
<a href="https://eprint.iacr.org/2013/280.pdf" rel="nofollow">path oblivious RAM</a>. While I understand how this technique offers protection when reading data - multiple randomly distributed reads obfuscate the access pattern of the data actually re... | security | 1 | Oblivious RAM write protection -- (security)
<p>I'm trying to understand how oblivious RAM works, specifically
<a href="https://eprint.iacr.org/2013/280.pdf" rel="nofollow">path oblivious RAM</a>. While I understand how this technique offers protection when reading data - multiple randomly distributed reads obfusca... | habedi/stack-exchange-dataset |
52,342 | Will the Ford-Fulkerson algorithm always find the max flow if we start from a valid flow? | <p>I stumbled across this question and answer (<a href="https://www.cs.duke.edu/courses/summer11/cps130/files/practice-final.pdf" rel="noreferrer">source</a>):</p>

<blockquote>
 <p>Question: Suppose someone presents you with a solution to a max-flow problem on some network. Give a linear
 time algori... | algorithms network flow ford fulkerson | 1 | Will the Ford-Fulkerson algorithm always find the max flow if we start from a valid flow? -- (algorithms network flow ford fulkerson)
<p>I stumbled across this question and answer (<a href="https://www.cs.duke.edu/courses/summer11/cps130/files/practice-final.pdf" rel="noreferrer">source</a>):</p>

<blockquote>&... | habedi/stack-exchange-dataset |
52,347 | Counterexample for LTL - CTL equivalence | <p>I have to find an example of a model where the LTL-formula $F G p \wedge F q$ is valid and the CTL-formula $EF AG p \wedge AF q$ is not valid. I found this example, but I'm not completely sure whether it's correct: </p>

<p><a href="https://i.stack.imgur.com/VRiem.png" rel="nofollow noreferrer"><img src="htt... | linear temporal logic temporal logic | 1 | Counterexample for LTL - CTL equivalence -- (linear temporal logic temporal logic)
<p>I have to find an example of a model where the LTL-formula $F G p \wedge F q$ is valid and the CTL-formula $EF AG p \wedge AF q$ is not valid. I found this example, but I'm not completely sure whether it's correct: </p>

<p><a... | habedi/stack-exchange-dataset |
52,358 | How to determine if a regular language L* exists | <p>I'm trying to make sense of regular languages, operations on them, and Kleene operations. </p>

<p>Let's say I define a language with the alphabet {x, y}. Let's further say that I place the restriction that there can be no string in the language that contains the substring 'xx'. Thus, my language could be ex... | formal languages regular languages kleene star | 1 | How to determine if a regular language L* exists -- (formal languages regular languages kleene star)
<p>I'm trying to make sense of regular languages, operations on them, and Kleene operations. </p>

<p>Let's say I define a language with the alphabet {x, y}. Let's further say that I place the restriction that t... | habedi/stack-exchange-dataset |
52,359 | Iota combinator and implicational propositional calculus | <p>There is are two esoteric languages with <a href="https://en.wikipedia.org/wiki/Functional_completeness#Minimal_functionally_complete_operator_sets" rel="nofollow">minimally functionally complete</a> operators, <a href="http://esolangs.org/wiki/Iota" rel="nofollow">iota</a> and <a href="http://esolangs.org/wiki/jot"... | lambda calculus propositional logic combinatory logic | 1 | Iota combinator and implicational propositional calculus -- (lambda calculus propositional logic combinatory logic)
<p>There is are two esoteric languages with <a href="https://en.wikipedia.org/wiki/Functional_completeness#Minimal_functionally_complete_operator_sets" rel="nofollow">minimally functionally complete</a> o... | habedi/stack-exchange-dataset |
52,360 | From Guido's essays, how does this function avoid quadratic behavior in a string concatenation algorithm? | <p>I am reading one of Guido van Rossum's essays <a href="https://www.python.org/doc/essays/list2str/" rel="nofollow">on optimization in Python</a>. </p>

<p>We are interested in converting a Python list of integers to their character equivalents. Here's the straightforward algorithm. </p>

<pre><code>d... | algorithms strings efficiency arrays loops | 1 | From Guido's essays, how does this function avoid quadratic behavior in a string concatenation algorithm? -- (algorithms strings efficiency arrays loops)
<p>I am reading one of Guido van Rossum's essays <a href="https://www.python.org/doc/essays/list2str/" rel="nofollow">on optimization in Python</a>. </p>

<p>... | habedi/stack-exchange-dataset |
52,374 | Probability with an unusual pseudo-random generator | <p>I will preface this with the actual question taken from lecture:</p>

<blockquote>
 <p>An unusual pseudo-random generator outputs integers between 1 and 4, inclusive, in such a way that each value, v, occurs with a probability that is inversely proportional to v. For example, 4 is half as likely to occu... | pseudo random generators | 1 | Probability with an unusual pseudo-random generator -- (pseudo random generators)
<p>I will preface this with the actual question taken from lecture:</p>

<blockquote>
 <p>An unusual pseudo-random generator outputs integers between 1 and 4, inclusive, in such a way that each value, v, occurs with a probabi... | habedi/stack-exchange-dataset |
52,379 | Is the word problem for regular languages in ALogTime? | <p>Given a regular language (by a sparse or dense matrix describing the graph of the NFA) (initially the description was supposed to be a regular expression) and a word, can the problem whether the word belongs to the regular language be decided on a (<a href="https://en.wikipedia.org/wiki/Random-access_Turing_machine"... | complexity theory regular languages decision problem | 1 | Is the word problem for regular languages in ALogTime? -- (complexity theory regular languages decision problem)
<p>Given a regular language (by a sparse or dense matrix describing the graph of the NFA) (initially the description was supposed to be a regular expression) and a word, can the problem whether the word belo... | habedi/stack-exchange-dataset |
52,381 | Generate integer from 0 to 1 with equal probability | <p>I am trying to get around this problem of my own making. I want to generate 0 or 1 with another function(gr0_4()) which generates random number from 0 to 4.</p>

<p>I am wondering if I can approach this way:</p>

<p>a). if gr0_4() = 0 or 1 then I will use 0</p>

<p>b). if gr0_4() = 2 or 3 the... | algorithms pseudo random generators random number generator | 1 | Generate integer from 0 to 1 with equal probability -- (algorithms pseudo random generators random number generator)
<p>I am trying to get around this problem of my own making. I want to generate 0 or 1 with another function(gr0_4()) which generates random number from 0 to 4.</p>

<p>I am wondering if I can app... | habedi/stack-exchange-dataset |
52,390 | Why is my regular grammar for palindromes wrong? | <p>I've seen that people prove somehow that set of all palindromes isn't regular language by using a pumping lemma, which I am not familiar with.</p>

<p>I've created grammar which can generate all palindromes and that is why I wonder why it's wrong.</p>

<pre><code>A -> e
A -> a | b | ... | z... | regular languages formal grammars | 1 | Why is my regular grammar for palindromes wrong? -- (regular languages formal grammars)
<p>I've seen that people prove somehow that set of all palindromes isn't regular language by using a pumping lemma, which I am not familiar with.</p>

<p>I've created grammar which can generate all palindromes and that is wh... | habedi/stack-exchange-dataset |
52,405 | Why add a +1 to the constant proving an O(n) bound? | <p>I have calculated a running-time function $T(n) = 4 + 4n$, which is $O(n)$. </p>

<p>To determine the constant $C$ given by the relation $|T(n)| < C \cdot g(n)$,
we take </p>

<p>$\qquad\displaystyle \lim_{n \to \infty} T(n)/g(n)$ </p>

<p>which gives us </p>

<p>$\qquad\displa... | asymptotics proof techniques landau notation | 1 | Why add a +1 to the constant proving an O(n) bound? -- (asymptotics proof techniques landau notation)
<p>I have calculated a running-time function $T(n) = 4 + 4n$, which is $O(n)$. </p>

<p>To determine the constant $C$ given by the relation $|T(n)| < C \cdot g(n)$,
we take </p>

<p>$\qquad\displ... | habedi/stack-exchange-dataset |
52,411 | Would proving P≠NP be harder than proving P=NP? | <p>Consider two possibilities for the P vs. NP problem: P=NP and P$\neq$NP.</p>

<p>Let Q be one of known NP-hard problems.
To prove P=NP, we need to design a single polynomial time algorithm A for Q and
prove that A correctly solves Q.</p>

<p>To prove P$\neq$NP, we need to show that 
<em>n... | complexity theory p vs np | 1 | Would proving P≠NP be harder than proving P=NP? -- (complexity theory p vs np)
<p>Consider two possibilities for the P vs. NP problem: P=NP and P$\neq$NP.</p>

<p>Let Q be one of known NP-hard problems.
To prove P=NP, we need to design a single polynomial time algorithm A for Q and
prove that A correctl... | habedi/stack-exchange-dataset |
52,437 | Finding a small element in a changing array | <p>Consider having an integer array $A$ with $n$ elements, in addition to any data structure you like.</p>

<p>The array is initialized to zeros.</p>

<p>The goal to to support two operations:</p>

<ul>
<li><code>Update(k,v)</code> - sets $A[k]=v$. </li>
<li><code>Small()</code> - return... | algorithms data structures time complexity arrays lower bounds | 1 | Finding a small element in a changing array -- (algorithms data structures time complexity arrays lower bounds)
<p>Consider having an integer array $A$ with $n$ elements, in addition to any data structure you like.</p>

<p>The array is initialized to zeros.</p>

<p>The goal to to support two operations:... | habedi/stack-exchange-dataset |
52,440 | Is the following language recursively enumerable? | <p>Let $L =\{ <M> | $ the amount of words $w\in\Sigma^*$ that $M$ does <strong>not</strong> halt on is finite $\}$.</p>

<p>I would like to prove that $L\notin RE$. </p>

<p>I can show that $\overline{L}\notin RE $ that is $L\notin CoRE$. </p>

<p>I do this with showing a reduction: $\ove... | computability turing machines reductions undecidability | 1 | Is the following language recursively enumerable? -- (computability turing machines reductions undecidability)
<p>Let $L =\{ <M> | $ the amount of words $w\in\Sigma^*$ that $M$ does <strong>not</strong> halt on is finite $\}$.</p>

<p>I would like to prove that $L\notin RE$. </p>

<p>I can show t... | habedi/stack-exchange-dataset |
52,447 | Find set of non-overlapping rectangles in a 2D grid | <p>I have a $n \times m$ rectangular grid of cells, and a set $R$ of rectangles within this grid. Each rectangle is a subset of the cells. (Alternatively, you can think of them as axis-aligned rectangles where each of the four corners has integer coordinates.)</p>

<p>I want to find a subset $S$ of rectangles... | algorithms computational geometry np hard | 1 | Find set of non-overlapping rectangles in a 2D grid -- (algorithms computational geometry np hard)
<p>I have a $n \times m$ rectangular grid of cells, and a set $R$ of rectangles within this grid. Each rectangle is a subset of the cells. (Alternatively, you can think of them as axis-aligned rectangles where each of t... | habedi/stack-exchange-dataset |
52,450 | Approximation for vector bin packing | <p>I came across the following question. Given a 2-approximation for minimum bin packing problem, find a 2d-approximation for d-dimensional bin backing. </p>

<p>To clarify, inputs to the bin packing problem are real numbers $x_1,...,x_n\in [0,1]$, which should be divided into $k$ bins $S_1,...,S_k$ such that f... | algorithms approximation | 1 | Approximation for vector bin packing -- (algorithms approximation)
<p>I came across the following question. Given a 2-approximation for minimum bin packing problem, find a 2d-approximation for d-dimensional bin backing. </p>

<p>To clarify, inputs to the bin packing problem are real numbers $x_1,...,x_n\in [0,1... | habedi/stack-exchange-dataset |
52,462 | Count the number of Euler PATHs in directed graph? | <ul>
<li><strong>I would like to find all Euler PATHs in a directed graph.</strong></li>
<li><strong>Counting (instead of finding) all the Euler PATHs is sufficient.</strong></li>
<li><strong>Circuits are not good for me, only Paths.</strong></li>
</ul>

<p>I am doing a problem, that I have deri... | algorithms graphs counting eulerian paths | 1 | Count the number of Euler PATHs in directed graph? -- (algorithms graphs counting eulerian paths)
<ul>
<li><strong>I would like to find all Euler PATHs in a directed graph.</strong></li>
<li><strong>Counting (instead of finding) all the Euler PATHs is sufficient.</strong></li>
<li><strong>Circuits are not g... | habedi/stack-exchange-dataset |
52,464 | Virtual Address and Physical Address Space | <p>A machine has 48-bit virtual addresses and 32-bit physical addresses. Pages are 8K. How many entries are needed for a conventional page table ? </p>

<p>The answer is 2^35 entries</p>

<p>Why not (2^32) / (2^13) = 2^19 entries...?</p>

<p>My doubt here is why does the number of page table ent... | operating systems memory management virtual memory paging | 1 | Virtual Address and Physical Address Space -- (operating systems memory management virtual memory paging)
<p>A machine has 48-bit virtual addresses and 32-bit physical addresses. Pages are 8K. How many entries are needed for a conventional page table ? </p>

<p>The answer is 2^35 entries</p>

<p>Why not... | habedi/stack-exchange-dataset |
52,469 | Why does λz.zq reduce to q? | <p>The way I see it, it should not be further reducible. I'm thinking <code>λz.zq</code> is like </p>

<pre><code>lambda z: z(q) # Python, not lambda calc
</code></pre>

<p>and you do not know z nor q so it is not further reducible.</p>

<p>The below derivation (where I am wondering about th... | lambda calculus | 1 | Why does λz.zq reduce to q? -- (lambda calculus)
<p>The way I see it, it should not be further reducible. I'm thinking <code>λz.zq</code> is like </p>

<pre><code>lambda z: z(q) # Python, not lambda calc
</code></pre>

<p>and you do not know z nor q so it is not further reducible.</p>

<p>Th... | habedi/stack-exchange-dataset |
52,471 | Can $ \{A^nB^nA^nB^n \mid n \geq 0 \}$ be pumped using the pumping lemma? | <p>In order to show that $ \{A^nB^nA^nB^n \mid n \geq 0 \}$ isn't CFL, I was trying to use a pumping lemma this way: At first we assign $w= A^jB^jA^jB^j ,$ $(w^i=uv^ixy^iz), p<|vxy|, p<j.$ </p>

<ul>
<li>if $vy$ contains just $a$s we choose i=0 for $w^i$, so in this case the number of $a$s isn't equal... | formal languages pumping lemma | 1 | Can $ \{A^nB^nA^nB^n \mid n \geq 0 \}$ be pumped using the pumping lemma? -- (formal languages pumping lemma)
<p>In order to show that $ \{A^nB^nA^nB^n \mid n \geq 0 \}$ isn't CFL, I was trying to use a pumping lemma this way: At first we assign $w= A^jB^jA^jB^j ,$ $(w^i=uv^ixy^iz), p<|vxy|, p<j.$ </p>

<... | habedi/stack-exchange-dataset |
52,473 | How exactly does a Max 2 Sat reduce to a 3 Sat? | <p>I've been reading <a href="http://web.stanford.edu/~rrwill/williams-max2sat-encyc.pdf" rel="nofollow">this</a> article which tries and explains how the max 2 sat problem is essentially a 3-sat problem and is NP-hard. <br><br>However, if you see the article, I'm <em>not able to understand why</em>, after <code>ci</co... | complexity theory reductions np hard satisfiability decision problem | 1 | How exactly does a Max 2 Sat reduce to a 3 Sat? -- (complexity theory reductions np hard satisfiability decision problem)
<p>I've been reading <a href="http://web.stanford.edu/~rrwill/williams-max2sat-encyc.pdf" rel="nofollow">this</a> article which tries and explains how the max 2 sat problem is essentially a 3-sat pr... | habedi/stack-exchange-dataset |
52,481 | Prove by induction that the running time of recursive Fibonacci is exponential | <p>This example followed from a Fibonacci algorithm in class. The professor showed us how to compute $T(n) = T(n-1) + T(n-2) + 3$, but left this step for us to prove, so I decided to attempt to prove it! But I am finding it difficult to fully understand how to prove things involving lower and upper-bounds. After lookin... | recurrence relation lower bounds induction | 1 | Prove by induction that the running time of recursive Fibonacci is exponential -- (recurrence relation lower bounds induction)
<p>This example followed from a Fibonacci algorithm in class. The professor showed us how to compute $T(n) = T(n-1) + T(n-2) + 3$, but left this step for us to prove, so I decided to attempt to... | habedi/stack-exchange-dataset |
52,488 | Why is a (collision-less) hashtable lookup really O(1)? | <p>Disclaimer: I know there are similar sounding questions already here and on Stackoverflow. But they are all about collisions, which is not what I am asking for.</p>

<p>My question is: why is collision-<em>less</em> lookup <code>O(1)</code> in the first place?</p>

<p>Let's assume I have this hashtab... | complexity theory hash hash tables performance | 1 | Why is a (collision-less) hashtable lookup really O(1)? -- (complexity theory hash hash tables performance)
<p>Disclaimer: I know there are similar sounding questions already here and on Stackoverflow. But they are all about collisions, which is not what I am asking for.</p>

<p>My question is: why is collision... | habedi/stack-exchange-dataset |
52,491 | Finding a closed form for a discrete sum using generating functions | <p>Consider this sum: for context sake, the summand appears in the counting of the possible ways to have one cigarette box empty and the other having left N cigarettes when both boxes start with N cigarettes in the Banach cigarette problem ; so there is a combinatorial explanation which I do not consider here.</p>
... | combinatorics discrete mathematics | 1 | Finding a closed form for a discrete sum using generating functions -- (combinatorics discrete mathematics)
<p>Consider this sum: for context sake, the summand appears in the counting of the possible ways to have one cigarette box empty and the other having left N cigarettes when both boxes start with N cigarettes in t... | habedi/stack-exchange-dataset |
52,495 | How can I check that the language of one context-free grammar is a subset of a second context-free grammar? | <p>Could you explain me, how can I check, that the language of first context-free grammar (G1) is a subset of the language of second context-free grammar (G2).</p>

<p>G1 and G2 are two LL(1) grammars with identical alphabets:</p>

<pre><code>{a, b, c, d, f}
</code></pre>

<p>Production rule... | formal languages context free formal grammars parsers | 1 | How can I check that the language of one context-free grammar is a subset of a second context-free grammar? -- (formal languages context free formal grammars parsers)
<p>Could you explain me, how can I check, that the language of first context-free grammar (G1) is a subset of the language of second context-free grammar... | habedi/stack-exchange-dataset |
52,504 | Does the language $\{(1^n2^n)^t \mid t,n\ge0\}$ contain the string $121122$? | <p>Does the Context Free Language $\{(1^n2^n)^t \mid t,n\ge0\}$ contain the string $121122$? Does $t$ fix $n$? I think the string belongs to this language.</p>
 | formal languages context free | 1 | Does the language $\{(1^n2^n)^t \mid t,n\ge0\}$ contain the string $121122$? -- (formal languages context free)
<p>Does the Context Free Language $\{(1^n2^n)^t \mid t,n\ge0\}$ contain the string $121122$? Does $t$ fix $n$? I think the string belongs to this language.</p>
 | habedi/stack-exchange-dataset |
52,507 | Is it decidable whether a given context free grammar generates an infinite number of strings? | <p>Is the decision problem "Does a given context free grammar generate an infinite number of strings" decidable? In order to test whether a context free grammar generates an infinite number of strings or not, we can write a program that would test this but would not halt. So it should be undecidable. Is this so?</p>&#x... | computability context free formal grammars undecidability | 1 | Is it decidable whether a given context free grammar generates an infinite number of strings? -- (computability context free formal grammars undecidability)
<p>Is the decision problem "Does a given context free grammar generate an infinite number of strings" decidable? In order to test whether a context free grammar ge... | habedi/stack-exchange-dataset |
52,510 | How Can I Recognize When to Use ε-Transitions in an NFA? | <p>I am learning about finite automata for the first time. I am having trouble understanding the purpose of ε-transitions in an NFA, which seem to be crucial to counting the number of states in an NFA and therefore an equivalent DFA.</p>

<p>Here is an example question that confuses me: <em>What is the minimum... | automata finite automata nondeterminism | 1 | How Can I Recognize When to Use ε-Transitions in an NFA? -- (automata finite automata nondeterminism)
<p>I am learning about finite automata for the first time. I am having trouble understanding the purpose of ε-transitions in an NFA, which seem to be crucial to counting the number of states in an NFA and therefore an... | habedi/stack-exchange-dataset |
52,512 | What is the most efficient way to find bSmooth values in QS? | <p>The heaviest part of QS is to search for bSmooth numbers.</p>
<p>So far I thought about two algorithms for solving this.</p>
<ol>
<li>Trial division</li>
<li>
<ul>
<li>calculate <span class="math-container">$X$</span> as a product of all the values in the factor base</li>
<li>speed up the... | algorithms efficiency number theory factoring | 1 | What is the most efficient way to find bSmooth values in QS? -- (algorithms efficiency number theory factoring)
<p>The heaviest part of QS is to search for bSmooth numbers.</p>
<p>So far I thought about two algorithms for solving this.</p>
<ol>
<li>Trial division</li>
<li>
<ul>
<li>calculate <sp... | habedi/stack-exchange-dataset |
52,526 | Question about bigram model | <p>I am trying to build a bigram letter model.</p>

<p>I obtain a sequence of words in a form of ['hello','I','am','Johnny'].</p>

<p>Firstly, I lower all the words to obtain : ['hello','i','am','johnny'].</p>

<p>I am capable of building a bigram letter model, but I have read somewhere that you... | natural language processing | 1 | Question about bigram model -- (natural language processing)
<p>I am trying to build a bigram letter model.</p>

<p>I obtain a sequence of words in a form of ['hello','I','am','Johnny'].</p>

<p>Firstly, I lower all the words to obtain : ['hello','i','am','johnny'].</p>

<p>I am capable of build... | habedi/stack-exchange-dataset |
52,527 | Problem with understanding the lower bound of OPT in Greedy Set Cover approximation algorithm | <p>From what I know of analyzing and designing approximation algorithms, we need to find a lower bound on the optimum (in the case of minimization). For example if our solution is greedy ($SOL_G$) and if we find a lower bound $L_B$ on $OPT$ then $$L_B \leq OPT$$</p>

<p>and if we correctly analyze the following... | algorithms approximation set cover | 1 | Problem with understanding the lower bound of OPT in Greedy Set Cover approximation algorithm -- (algorithms approximation set cover)
<p>From what I know of analyzing and designing approximation algorithms, we need to find a lower bound on the optimum (in the case of minimization). For example if our solution is greedy... | habedi/stack-exchange-dataset |
52,529 | Travelling plan between two places | <p>There is a class of DP related problems where you have a set of consecutive steps, say $1 \ldots n$, and two places e.g. $A$ and $B$.</p>

<p>At each step $i$ there are two choices: stay where you are or change. Whatever you choose you pay a cost $A_i$ or $B_i$ depending on where you are, anyway if you chang... | algorithms optimization dynamic programming | 1 | Travelling plan between two places -- (algorithms optimization dynamic programming)
<p>There is a class of DP related problems where you have a set of consecutive steps, say $1 \ldots n$, and two places e.g. $A$ and $B$.</p>

<p>At each step $i$ there are two choices: stay where you are or change. Whatever you ... | habedi/stack-exchange-dataset |
52,530 | Efficiently generating a uniformly random list of unique integers in a range | <p>The problem:</p>

<ul>
<li>To generate a list of size $n$,</li>
<li>Containing <em>unique</em> integers,</li>
<li>Sampled uniformly in the range $\left[0,m\right)$,</li>
<li>In $O(n)$ time, except that:

<ul>
<li>Assuming $m$ is bounded by some word-size, $\left|m\right|$, the spe... | algorithms randomness sampling | 1 | Efficiently generating a uniformly random list of unique integers in a range -- (algorithms randomness sampling)
<p>The problem:</p>

<ul>
<li>To generate a list of size $n$,</li>
<li>Containing <em>unique</em> integers,</li>
<li>Sampled uniformly in the range $\left[0,m\right)$,</li>
<li>In $O(... | habedi/stack-exchange-dataset |
52,534 | Solving/Optimizing a linear system in a finite field (Z/2Z) | <p>I'm trying to solve the following optimization problem.</p>

<p>A is a rectangular matrix with coefficients in the finite field Z/2Z (size less than 1000 X 1000). I have a system of the form A.X = Y (X and Y are vectors). And I'm looking for X such that the Hamming weight of Y is maximal. </p>

<p>In... | algorithms optimization linear algebra | 1 | Solving/Optimizing a linear system in a finite field (Z/2Z) -- (algorithms optimization linear algebra)
<p>I'm trying to solve the following optimization problem.</p>

<p>A is a rectangular matrix with coefficients in the finite field Z/2Z (size less than 1000 X 1000). I have a system of the form A.X = Y (X and... | habedi/stack-exchange-dataset |
52,539 | Efficiently locating the maximum value in interval over large amounts of data points | <p>I have a set of $n$ two-dimensional data points $(x_i,y_i)$. I want to efficiently answer the following query: Given an arbitrary interval of $x$-values, find the highest and lowest points within that interval. In other words, for this query we are given an interval $[\ell,u]$, and we want to find the point $(x_i,... | algorithms data structures search problem intervals | 1 | Efficiently locating the maximum value in interval over large amounts of data points -- (algorithms data structures search problem intervals)
<p>I have a set of $n$ two-dimensional data points $(x_i,y_i)$. I want to efficiently answer the following query: Given an arbitrary interval of $x$-values, find the highest and... | habedi/stack-exchange-dataset |
52,549 | Flipping accept states DFA vs. NFA | <p>I realized that if a language L is recognized by a DFA, then <strong>flipping its accept and reject states</strong> (aka switching all the accept to reject states and all the reject states to accept) works to recognize the complement of L (which wold be L^c).</p>

<p>I was curious if that worked also with NF... | automata finite automata | 1 | Flipping accept states DFA vs. NFA -- (automata finite automata)
<p>I realized that if a language L is recognized by a DFA, then <strong>flipping its accept and reject states</strong> (aka switching all the accept to reject states and all the reject states to accept) works to recognize the complement of L (which wold b... | habedi/stack-exchange-dataset |
52,556 | Regular languages that can't be expressed with only 2 regex operations | <p>I thought all regular languages could be expressed with regular expressions (if a language is regular, it can be expressed with regex), but
I have been told that you need all three of the regular operations (concatenation, union, and star) for that to hold.</p>

<p>For example, I have been told that <str... | formal languages regular languages regular expressions kleene star | 1 | Regular languages that can't be expressed with only 2 regex operations -- (formal languages regular languages regular expressions kleene star)
<p>I thought all regular languages could be expressed with regular expressions (if a language is regular, it can be expressed with regex), but
I have been told that you need... | habedi/stack-exchange-dataset |
52,574 | Show that if d(n) is O( f (n)) and e(n) is O(g(n)), then d(n)−e(n) is not necessarily O( f (n)−g(n)) | <p>I have this question as an assignment in my Java Algorithms class, and i'm aware that d(n)+e(n) is the same as O(f(n)+g(n)). I dont know why the same doesnt apply to subtracting. Can someone help me? I'm lost..</p>
 | asymptotics landau notation | 1 | Show that if d(n) is O( f (n)) and e(n) is O(g(n)), then d(n)−e(n) is not necessarily O( f (n)−g(n)) -- (asymptotics landau notation)
<p>I have this question as an assignment in my Java Algorithms class, and i'm aware that d(n)+e(n) is the same as O(f(n)+g(n)). I dont know why the same doesnt apply to subtracting. Can... | habedi/stack-exchange-dataset |
52,577 | How to properly solve T(n) = T(n-1) + O(2^n)? | <p>I've been trying to solve this recurrence: <strong>T(n) = T(n-1) + O(2^n)</strong></p>

<p>My approach when writing everything out and solving the geometric series was: T(n) = O(2^n).</p>

<p>T(n) = c2^n * (1 + 1/2 + 1/4 + ...)</p>

<p>= c2^n * (1/2)^i for i from 0 to infinity</p>

<p... | recurrence relation | 1 | How to properly solve T(n) = T(n-1) + O(2^n)? -- (recurrence relation)
<p>I've been trying to solve this recurrence: <strong>T(n) = T(n-1) + O(2^n)</strong></p>

<p>My approach when writing everything out and solving the geometric series was: T(n) = O(2^n).</p>

<p>T(n) = c2^n * (1 + 1/2 + 1/4 + ...)</p... | habedi/stack-exchange-dataset |
52,582 | Is the empty string of even length? | <p>There is this example of regular expressions:</p>

<p>$$(\Sigma\Sigma)^*= \{w\mid |w|\text{ is even}\}\,.$$</p>

<p>From that I understand the empty string is valid as a string of even length. Is this true? </p>
 | formal languages regular expressions modular arithmetic | 1 | Is the empty string of even length? -- (formal languages regular expressions modular arithmetic)
<p>There is this example of regular expressions:</p>

<p>$$(\Sigma\Sigma)^*= \{w\mid |w|\text{ is even}\}\,.$$</p>

<p>From that I understand the empty string is valid as a string of even length. Is this tru... | habedi/stack-exchange-dataset |
52,587 | What's the difference between Process Context and Process Control Block? | <p>I know that Process Context is something that is stored when a process is preempted, containing all the necessary info to restart the process at a later time.</p>

<p>I also know that the Process Control Block(PCB) contains all the necessary attributes of the process.</p>

<p>So, does that mean that ... | operating systems | 1 | What's the difference between Process Context and Process Control Block? -- (operating systems)
<p>I know that Process Context is something that is stored when a process is preempted, containing all the necessary info to restart the process at a later time.</p>

<p>I also know that the Process Control Block(PCB... | habedi/stack-exchange-dataset |
52,590 | Proving that the language of satifiable CNF formulae with primes is NP-complete | <blockquote>
 <p>Given the following language:</p>
 
 <p>$$L=\left\{\langle\phi, n\rangle \ \middle|\ \begin{array}{l}\phi\text{ is a satisfiable Boolean formula}\\ \text{written as POS (in CNF form)}\\ \text{and $n$ is a prime number}\end{array}\right\},$$</p>
 
 <p>Prove that L is an NPC lan... | complexity theory time complexity np complete | 1 | Proving that the language of satifiable CNF formulae with primes is NP-complete -- (complexity theory time complexity np complete)
<blockquote>
 <p>Given the following language:</p>
 
 <p>$$L=\left\{\langle\phi, n\rangle \ \middle|\ \begin{array}{l}\phi\text{ is a satisfiable Boolean formula}\\ \text{wr... | habedi/stack-exchange-dataset |
52,600 | complement of a language-nfa | <p><a href="https://i.stack.imgur.com/jhzEH.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/jhzEH.png" alt="enter image description here"></a></p>

<p>hi i know that the question 5 is true because by definition w ∈ L if and only if δ*(q0,w)∩F ≠ ∅. Consequently, if δ∗ (q0,w)∩F = ∅, then w ∈ ... | regular languages automata | 1 | complement of a language-nfa -- (regular languages automata)
<p><a href="https://i.stack.imgur.com/jhzEH.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/jhzEH.png" alt="enter image description here"></a></p>

<p>hi i know that the question 5 is true because by definition w ∈ L if and only if... | habedi/stack-exchange-dataset |
52,605 | Generate random weighted graphs representing a road network | <p>in order to solve a DARP problem I created a Python class, that can generate random graphs. I attribute a random number to every edge which represents the cost to travel over that edge.
My current solution for connecting vertices (and so create an edge) looks like this:</p>

<pre class="lang-py prettypri... | graphs graph traversal weighted graphs | 1 | Generate random weighted graphs representing a road network -- (graphs graph traversal weighted graphs)
<p>in order to solve a DARP problem I created a Python class, that can generate random graphs. I attribute a random number to every edge which represents the cost to travel over that edge.
My current solution for... | habedi/stack-exchange-dataset |
52,606 | Sort a list of points to form a non-self-intersecting polygon | <p>Given a list (of arbitrary length) of 2-dimensional points, is there some algorithm that I can employ to sort this list of points into an order such that line segments sequentially drawn from $p_0 \rightarrow p_1 \rightarrow \ldots \rightarrow p_{n-1} \rightarrow p_n \rightarrow p_0$ would form a non-self-intersecti... | algorithms computational geometry sorting | 1 | Sort a list of points to form a non-self-intersecting polygon -- (algorithms computational geometry sorting)
<p>Given a list (of arbitrary length) of 2-dimensional points, is there some algorithm that I can employ to sort this list of points into an order such that line segments sequentially drawn from $p_0 \rightarrow... | habedi/stack-exchange-dataset |
52,618 | Complexity and Recurrence relation for Lowest Common Ancestor Binary Tree | <p>I have written this solution for finding the Lowest Common Ancestor in a Binary Tree. Now I wanted to find the time complexity of this problem by solving via recurrence relation. Can someone suggest if the approach is correct:</p>

<pre><code>public class Solution {
 public TreeNode lowestCommonAncestor(... | algorithms data structures recurrence relation binary trees recursion | 1 | Complexity and Recurrence relation for Lowest Common Ancestor Binary Tree -- (algorithms data structures recurrence relation binary trees recursion)
<p>I have written this solution for finding the Lowest Common Ancestor in a Binary Tree. Now I wanted to find the time complexity of this problem by solving via recurrence... | habedi/stack-exchange-dataset |
52,624 | About showing algorithmic gap instance for the Goemans-Williamson SDP | <p>Using usual notation we have,</p>

<p>$SDP(G) \geq OPT(G) \geq Alg_{GW}(G) \geq \alpha_{GW} SDP(G) \geq \alpha_{GW} OPT(G)$</p>

<p>where we mean, </p>

<p>$SDP(G)$ = The maximum value that the SDP finds of the objective function $\sum_{(u,v) \in E} w_{uv}( 1-\vec{y_u}.\vec{y_v})/2$ (one uni... | complexity theory time complexity approximation | 1 | About showing algorithmic gap instance for the Goemans-Williamson SDP -- (complexity theory time complexity approximation)
<p>Using usual notation we have,</p>

<p>$SDP(G) \geq OPT(G) \geq Alg_{GW}(G) \geq \alpha_{GW} SDP(G) \geq \alpha_{GW} OPT(G)$</p>

<p>where we mean, </p>

<p>$SDP(G)$ = The... | habedi/stack-exchange-dataset |
52,625 | Regex to NFA to complement | <p>So I've found out that a regular expression $n$ symbols long converts to an NFA with $O(n)$ states, it is linear.</p>

<p>Now to go from that NFA to the <strong>complement</strong> of the NFA, since I can't just flip accept and reject states, this means turning the NFA into a DFA.</p>

<p>If $n$ is t... | algorithm analysis automata finite automata regular expressions lower bounds | 1 | Regex to NFA to complement -- (algorithm analysis automata finite automata regular expressions lower bounds)
<p>So I've found out that a regular expression $n$ symbols long converts to an NFA with $O(n)$ states, it is linear.</p>

<p>Now to go from that NFA to the <strong>complement</strong> of the NFA, since I... | habedi/stack-exchange-dataset |
52,634 | Match students and teachers based on ranking | <p>I have a similar question to that of <a href="http://rosettacode.org/wiki/Stable_marriage_problem" rel="nofollow noreferrer">Stable Marriage Problem</a>.</p>

<p>This is the criteria<br>1) 1 Student must have 1 Teacher only.<br>2) 1 Teacher ideally should have 3-4 Students.</p>

<p>The spreadsheet is... | algorithms bipartite matching assignment problem | 1 | Match students and teachers based on ranking -- (algorithms bipartite matching assignment problem)
<p>I have a similar question to that of <a href="http://rosettacode.org/wiki/Stable_marriage_problem" rel="nofollow noreferrer">Stable Marriage Problem</a>.</p>

<p>This is the criteria<br>1) 1 Student must have 1... | habedi/stack-exchange-dataset |
52,635 | Is something more than Turing complete Turing complete? | <p>In complexity theory, we do not call a decision problem that is not in NP "NP-complete".</p>

<p>But in computability, do we call a machine model "Turing complete" if it can compute functions which Turing machines can not?</p>

<p>The definition from Wikipedia didn't address this problem explicitly, ... | computability terminology turing completeness | 1 | Is something more than Turing complete Turing complete? -- (computability terminology turing completeness)
<p>In complexity theory, we do not call a decision problem that is not in NP "NP-complete".</p>

<p>But in computability, do we call a machine model "Turing complete" if it can compute functions which Turi... | habedi/stack-exchange-dataset |
52,637 | Identifying system events affecting timing behavior of an application | <p><strong>Q:</strong> What are those events (system level and architecture level) that can cause an application to take longer to terminate and complete the job? </p>

<p>My question is purely in the context of <a href="https://en.wikipedia.org/wiki/Worst-case_execution_time" rel="nofollow">Worst Case Executio... | time complexity runtime analysis computer architecture cpu cache cpu pipelines | 1 | Identifying system events affecting timing behavior of an application -- (time complexity runtime analysis computer architecture cpu cache cpu pipelines)
<p><strong>Q:</strong> What are those events (system level and architecture level) that can cause an application to take longer to terminate and complete the job? </p... | habedi/stack-exchange-dataset |
52,639 | restricted sub-permutations check | <p>I am solving the following problem, motived by combinatorial optimization sampling proces.</p>

<p>I have restriction (0,1) matrix to restrict which item (column index) can be on current position (row index) at permutations. For example: 4x4 case (4 position permutations)</p>

<pre><code> 1 1 ... | algorithms decision problem permutations | 1 | restricted sub-permutations check -- (algorithms decision problem permutations)
<p>I am solving the following problem, motived by combinatorial optimization sampling proces.</p>

<p>I have restriction (0,1) matrix to restrict which item (column index) can be on current position (row index) at permutations. For ... | habedi/stack-exchange-dataset |
52,640 | Complexity of multiplication | <p>I've been reading around the area of complexity and arithmetic operations using logic gates; one thing that is confusing me is that 
\begin{equation}
\Theta (n^{2})
\end{equation}
is quoted as being the complexity for multiplication for iterative adition. But addition of a number requires \begin{equa... | complexity theory arithmetic | 1 | Complexity of multiplication -- (complexity theory arithmetic)
<p>I've been reading around the area of complexity and arithmetic operations using logic gates; one thing that is confusing me is that 
\begin{equation}
\Theta (n^{2})
\end{equation}
is quoted as being the complexity for multiplication for i... | habedi/stack-exchange-dataset |
52,641 | L closed under logspace reduction | <p>Given two languages $A$ and $B$ I have been asked to show that, if $B \in L$ and we have a logspace reduction $f$ from $A$ to $B$ then $A \in L$.</p>

<p>I read the proof that $L$ is closed under logspace reductions in Arora-Barak's textbook. The idea of the proof is, if I'm not getting wrong, to simulate th... | complexity theory reductions closure properties space complexity | 1 | L closed under logspace reduction -- (complexity theory reductions closure properties space complexity)
<p>Given two languages $A$ and $B$ I have been asked to show that, if $B \in L$ and we have a logspace reduction $f$ from $A$ to $B$ then $A \in L$.</p>

<p>I read the proof that $L$ is closed under logspace ... | habedi/stack-exchange-dataset |
52,645 | A facility location problem | <p>Consider the following scenario. There are N localities in a town where population for locality $L_i$ is denoted by $P_i$, $i \in {1,\ldots,n}$. We need to place K hospitals around the town in a way that the cost of accessing the hospital is minimized. </p>

<p>We are basically trying to 
$$\min_O(\sum_{... | algorithms optimization probability theory | 1 | A facility location problem -- (algorithms optimization probability theory)
<p>Consider the following scenario. There are N localities in a town where population for locality $L_i$ is denoted by $P_i$, $i \in {1,\ldots,n}$. We need to place K hospitals around the town in a way that the cost of accessing the hospital is... | habedi/stack-exchange-dataset |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.