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
115,507
show that if L is a regular, then drop(L) is a regular
<p>I am trying to prove the following problem, but honestly I don't know what "proof" is considered a good proof.</p>&#xA;&#xA;<p><a href="https://i.stack.imgur.com/HfoPS.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/HfoPS.png" alt="enter image description here"></a></p>&#xA;&#xA;<p>I tried to prov...
formal languages automata regular languages regular expressions
1
show that if L is a regular, then drop(L) is a regular -- (formal languages automata regular languages regular expressions) <p>I am trying to prove the following problem, but honestly I don't know what "proof" is considered a good proof.</p>&#xA;&#xA;<p><a href="https://i.stack.imgur.com/HfoPS.png" rel="nofollow norefe...
habedi/stack-exchange-dataset
115,510
Showing the following language is decidable
<p>Let <span class="math-container">$BAL_{DFA} = \{&lt;M&gt; \mid M \text{ is a DFA that accepts some string containing an equal number of 0's and 1's } \}$</span> Show that <span class="math-container">$BAL_{DFA}$</span> is decidable.</p>&#xA;&#xA;<p>Generally such questions seem to be solved by constructing a DFA tha...
complexity theory turing machines computability automata computation models
1
Showing the following language is decidable -- (complexity theory turing machines computability automata computation models) <p>Let <span class="math-container">$BAL_{DFA} = \{&lt;M&gt; \mid M \text{ is a DFA that accepts some string containing an equal number of 0's and 1's } \}$</span> Show that <span class="math-con...
habedi/stack-exchange-dataset
115,517
Algorithm for dividing items into buckets while minimizing total weight
<p>Let's say I have two buckets coloured red and blue, both of which can hold two rocks. I need to divide a set of <span class="math-container">$n$</span> weighted rocks into these buckets in such a way as to minimize the total weight of the rocks in the buckets, while filling each bucket to its capacity.</p>&#xA;&#xA;...
algorithms optimization
1
Algorithm for dividing items into buckets while minimizing total weight -- (algorithms optimization) <p>Let's say I have two buckets coloured red and blue, both of which can hold two rocks. I need to divide a set of <span class="math-container">$n$</span> weighted rocks into these buckets in such a way as to minimize t...
habedi/stack-exchange-dataset
115,518
Sampling a uniform distribution of fixed size strings containing no forbidden substrings
<p>Given a list of "forbidden" words (substrings), an alphabet, and a desired output string length, how would I efficiently sample output strings containing no forbidden word?</p>&#xA;&#xA;<p>For short output strings with few forbidden words, I would use simple rejection sampling. Pick a string (uniformly) with the spe...
strings substrings sampling random number generator
1
Sampling a uniform distribution of fixed size strings containing no forbidden substrings -- (strings substrings sampling random number generator) <p>Given a list of "forbidden" words (substrings), an alphabet, and a desired output string length, how would I efficiently sample output strings containing no forbidden word...
habedi/stack-exchange-dataset
115,521
How does the slow All-pairs-shortest-paths algorithm work?
<p>I am trying to fully understand the following algorithm from CLRS book:</p>&#xA;&#xA;<p><a href="https://i.stack.imgur.com/L8cRG.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/L8cRG.png" alt="enter image description here"></a>&#xA;<a href="https://i.stack.imgur.com/PAYZW.png" rel="nofollow norefe...
algorithms graphs shortest path
1
How does the slow All-pairs-shortest-paths algorithm work? -- (algorithms graphs shortest path) <p>I am trying to fully understand the following algorithm from CLRS book:</p>&#xA;&#xA;<p><a href="https://i.stack.imgur.com/L8cRG.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/L8cRG.png" alt="enter ima...
habedi/stack-exchange-dataset
115,530
3-heap max heap
<p>I have this 3 heap max heap that I need to write the array for it, but I'm not sure how. Would it just be</p>&#xA;&#xA;<p>20,18,13,15,11,12,16,10,9,11,13,2,9? </p>&#xA;&#xA;<p><a href="https://i.stack.imgur.com/fLgJh.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/fLgJh.png" alt="enter image descr...
heaps
1
3-heap max heap -- (heaps) <p>I have this 3 heap max heap that I need to write the array for it, but I'm not sure how. Would it just be</p>&#xA;&#xA;<p>20,18,13,15,11,12,16,10,9,11,13,2,9? </p>&#xA;&#xA;<p><a href="https://i.stack.imgur.com/fLgJh.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/fLgJh....
habedi/stack-exchange-dataset
115,532
What is minimum cost perfect matching problem for general graph?
<p>It does make sense when we talk about perfect matching in bipartite graphs because there are two sets of points, for example, one set may be jobs and other set may contain different machines. But when we talk about minimum cost perfect matching in general graphs, it is not making any sense for me, what are the nodes...
graphs
1
What is minimum cost perfect matching problem for general graph? -- (graphs) <p>It does make sense when we talk about perfect matching in bipartite graphs because there are two sets of points, for example, one set may be jobs and other set may contain different machines. But when we talk about minimum cost perfect matc...
habedi/stack-exchange-dataset
115,533
reverse string to pattern matching
<p>I have a list of patterns, and I need to find the pattern that matches an input string the most. I.e.:</p>&#xA;&#xA;<p>Patterns:</p>&#xA;&#xA;<pre><code>[&#xA; 'AB1XXX',&#xA; 'AB2XXX',&#xA; 'ABXXXX-0080',&#xA; 'BC1XXX',&#xA; 'BC15XX'&#xA;]&#xA;</code></pre>&#xA;&#xA;<p>The <code>X</code> character in ...
algorithms search algorithms pattern recognition string matching
1
reverse string to pattern matching -- (algorithms search algorithms pattern recognition string matching) <p>I have a list of patterns, and I need to find the pattern that matches an input string the most. I.e.:</p>&#xA;&#xA;<p>Patterns:</p>&#xA;&#xA;<pre><code>[&#xA; 'AB1XXX',&#xA; 'AB2XXX',&#xA; 'ABXXXX-0080'...
habedi/stack-exchange-dataset
115,535
How to correctly negate a predicate bounded by some quantifiers?
<p>this is a problem which was asked in GATE CS 2010.<br></p>&#xA;&#xA;<p><strong>This is question statement:<br>&#xA;Q:</strong> Suppose the predicate F(x, y, t) is used to represent the statement that person x can fool person y at time t. which one of the statements below expresses best the meaning of the formula ∀x∃...
logic first order logic propositional logic predicate logic
1
How to correctly negate a predicate bounded by some quantifiers? -- (logic first order logic propositional logic predicate logic) <p>this is a problem which was asked in GATE CS 2010.<br></p>&#xA;&#xA;<p><strong>This is question statement:<br>&#xA;Q:</strong> Suppose the predicate F(x, y, t) is used to represent the st...
habedi/stack-exchange-dataset
115,545
How do I "apply" a loop invariant?
<p>A homework problem I have asks that I "state" a loop invariant, then "prove" it, then "apply" it. I get state and prove, but my textbook doesn't explicitly state how to "apply" a loop invariant.</p>&#xA;
loop invariants
1
How do I "apply" a loop invariant? -- (loop invariants) <p>A homework problem I have asks that I "state" a loop invariant, then "prove" it, then "apply" it. I get state and prove, but my textbook doesn't explicitly state how to "apply" a loop invariant.</p>&#xA;
habedi/stack-exchange-dataset
115,550
$A$ nonregular language, is $A\cup B$ nonregular?
<p>I was reading <a href="https://cs.stackexchange.com/questions/55632/is-the-union-of-a-non-regular-and-a-regular-language-regular/55635">this question</a>; regarding whether <span class="math-container">$L=A\cup B$</span> is nonregular if <span class="math-container">$A$</span> is. As is rightly pointed out in that a...
formal languages regular languages
1
$A$ nonregular language, is $A\cup B$ nonregular? -- (formal languages regular languages) <p>I was reading <a href="https://cs.stackexchange.com/questions/55632/is-the-union-of-a-non-regular-and-a-regular-language-regular/55635">this question</a>; regarding whether <span class="math-container">$L=A\cup B$</span> is non...
habedi/stack-exchange-dataset
115,553
Is it possible for a Turing machine to halt without reading the complete input string?
<p>Is it possible for a Turing machine to halt without reading the complete input string. Suppose there is a string "adc" preceded and succeeded by infinite number of blanks. Can a Turing machine halt after reading just "a" and never touching "dc" or any of the blanks. If yes, will this string be accepted or rejected?<...
turing machines
1
Is it possible for a Turing machine to halt without reading the complete input string? -- (turing machines) <p>Is it possible for a Turing machine to halt without reading the complete input string. Suppose there is a string "adc" preceded and succeeded by infinite number of blanks. Can a Turing machine halt after readi...
habedi/stack-exchange-dataset
115,563
An underestimated tradeoff between Memory and the Effectivity of Computation?
<p>Is there a theorem / single formula, that describes the often necessary <strong>tradeoff between memoiziation</strong> (for example that of a certain variable x) and <strong>effective computation</strong> as written in any common form such as runtime? </p>&#xA;&#xA;<p>(A good purely theoretical startig point to work...
algorithms algorithm analysis memoization
1
An underestimated tradeoff between Memory and the Effectivity of Computation? -- (algorithms algorithm analysis memoization) <p>Is there a theorem / single formula, that describes the often necessary <strong>tradeoff between memoiziation</strong> (for example that of a certain variable x) and <strong>effective computat...
habedi/stack-exchange-dataset
115,566
Compare log^k(n) with n^(1/2)
<p>I'm trying to prove or disprove that <span class="math-container">$\log^{k}(n) \in O(\sqrt{n}), \ \forall k &gt; 0$</span>. By using the free version of wolfram and testing some increasing values of <span class="math-container">$k$</span> I get that: </p>&#xA;&#xA;<p><span class="math-container">$$\lim_{n \rightarro...
complexity theory asymptotics big o notation
1
Compare log^k(n) with n^(1/2) -- (complexity theory asymptotics big o notation) <p>I'm trying to prove or disprove that <span class="math-container">$\log^{k}(n) \in O(\sqrt{n}), \ \forall k &gt; 0$</span>. By using the free version of wolfram and testing some increasing values of <span class="math-container">$k$</span...
habedi/stack-exchange-dataset
115,570
Two Generals Problems - What's wrong with my approach?
<p>Some time ago, I've come across the <em>Two Generals Problem</em> and that it cannot be resolved. Now, recently, I've had an idea how to approach it. IMHO, it is a very obvious way to handle it but I haven't found this way to handle it anywhere and therefore assume my idea is flawed but I can't find the error.</p>&#...
computer networks
1
Two Generals Problems - What's wrong with my approach? -- (computer networks) <p>Some time ago, I've come across the <em>Two Generals Problem</em> and that it cannot be resolved. Now, recently, I've had an idea how to approach it. IMHO, it is a very obvious way to handle it but I haven't found this way to handle it any...
habedi/stack-exchange-dataset
115,573
How to show that A is not regular?
<p>Let Σ = {0, 1, ⊕, =} and define a language A as follows: A = {x = y ⊕ z | x, y, z are binary integers, and x is the XOR of y and z}. For example string “1011 = 1111 ⊕ 0100” is in A, whereas string “1011 = 1011 ⊕ 1011” is not</p>&#xA;&#xA;<p>How can I show that A is not regular? How should I have the string?</p>&#xA;...
regular languages context free
1
How to show that A is not regular? -- (regular languages context free) <p>Let Σ = {0, 1, ⊕, =} and define a language A as follows: A = {x = y ⊕ z | x, y, z are binary integers, and x is the XOR of y and z}. For example string “1011 = 1111 ⊕ 0100” is in A, whereas string “1011 = 1011 ⊕ 1011” is not</p>&#xA;&#xA;<p>How c...
habedi/stack-exchange-dataset
115,575
I want to solve this question for algorithm, please
<p>Write an algorithm that calculates the monthly payment of a bank loan with&#xA;a fixed interest-rate. Given the principal amount, the fixed interest rate, the number of&#xA;years to pay the loan, you can calculate the monthly payment as:&#xA;ℎ =(××#+)/#ℎ&#xA;Your program should print the required monthly payment of ...
algorithms complexity theory formal languages computability data structures
1
I want to solve this question for algorithm, please -- (algorithms complexity theory formal languages computability data structures) <p>Write an algorithm that calculates the monthly payment of a bank loan with&#xA;a fixed interest-rate. Given the principal amount, the fixed interest rate, the number of&#xA;years to pa...
habedi/stack-exchange-dataset
115,579
Is monoid the category for untyped lambda calculus?
<p>If cartesian closed categories are the model for simply typed lambda calculus, then can it be said that a monoid is a categorical model for untyped lambda calculus?</p>&#xA;
lambda calculus category theory
1
Is monoid the category for untyped lambda calculus? -- (lambda calculus category theory) <p>If cartesian closed categories are the model for simply typed lambda calculus, then can it be said that a monoid is a categorical model for untyped lambda calculus?</p>&#xA;
habedi/stack-exchange-dataset
115,580
Will a node with no incoming arc or no out coming arc affect the maximum flow?
<p>So in a maximum flow question, say if we have a node which is not <span class="math-container">$s$</span> nor <span class="math-container">$t$</span>, if it has no incoming arc, can we delete it without affecting the maximum flow? What if it has no output arc? How so?</p>&#xA;
network flow
1
Will a node with no incoming arc or no out coming arc affect the maximum flow? -- (network flow) <p>So in a maximum flow question, say if we have a node which is not <span class="math-container">$s$</span> nor <span class="math-container">$t$</span>, if it has no incoming arc, can we delete it without affecting the max...
habedi/stack-exchange-dataset
115,581
$\epsilon$-transitions in NFAs
<p>I am reading "Introduction to the Theory of Computation" (2ed) by Michael Sipser. In Example 1.35, it says the NFA accepts <span class="math-container">$\epsilon$</span>, which I understand, since the state can stay at <span class="math-container">$q_1$</span> upon input of <span class="math-container">$\epsilon$</s...
automata
1
$\epsilon$-transitions in NFAs -- (automata) <p>I am reading "Introduction to the Theory of Computation" (2ed) by Michael Sipser. In Example 1.35, it says the NFA accepts <span class="math-container">$\epsilon$</span>, which I understand, since the state can stay at <span class="math-container">$q_1$</span> upon input ...
habedi/stack-exchange-dataset
115,584
Prove, a^2+b^2=c^2,there exists only 1 case such that a,b,c are consecutive non negative integers(3,4,5)
<p>I want to prove, <span class="math-container">$a^2+b^2=c^2$</span>,there exists only 1 case such that a,b,c are consecutive non-negative integers(3,4,5).</p>&#xA;&#xA;<p>I have no clue to prove this lemma. Please help me to prove this lemma. </p>&#xA;
discrete mathematics number theory
1
Prove, a^2+b^2=c^2,there exists only 1 case such that a,b,c are consecutive non negative integers(3,4,5) -- (discrete mathematics number theory) <p>I want to prove, <span class="math-container">$a^2+b^2=c^2$</span>,there exists only 1 case such that a,b,c are consecutive non-negative integers(3,4,5).</p>&#xA;&#xA;<p>I ...
habedi/stack-exchange-dataset
115,590
LL(k) language and not LL(k) grammar
<p>I have nonambiguous and not LL(k) grammar which defines some language. How can I prove that I can't build some LL(k) grammar for this language?</p>&#xA;&#xA;<p>Grammar:</p>&#xA;&#xA;<p>S -> a b X c d | a X f</p>&#xA;&#xA;<p>X -> b X c | ε </p>&#xA;
formal grammars
1
LL(k) language and not LL(k) grammar -- (formal grammars) <p>I have nonambiguous and not LL(k) grammar which defines some language. How can I prove that I can't build some LL(k) grammar for this language?</p>&#xA;&#xA;<p>Grammar:</p>&#xA;&#xA;<p>S -> a b X c d | a X f</p>&#xA;&#xA;<p>X -> b X c | ε </p>&#xA;
habedi/stack-exchange-dataset
115,595
Range Query with conditions
<p>Suppose I have an <span class="math-container">$N$</span> length integer array of pairs of the type <span class="math-container">$[value, key]$</span>. Now, I need to query for range sum. Query is of the type : <span class="math-container">$l, N, x$</span> meaning I have to sum up all the <span class="math-container...
algorithms data structures search trees
1
Range Query with conditions -- (algorithms data structures search trees) <p>Suppose I have an <span class="math-container">$N$</span> length integer array of pairs of the type <span class="math-container">$[value, key]$</span>. Now, I need to query for range sum. Query is of the type : <span class="math-container">$l, ...
habedi/stack-exchange-dataset
115,605
Calculating probability of reaching state in DTMC
<p>Consider a highly-connected graph of states &amp; transitions where each transition is marked with a weight (representing probability of occurring) and the graph satisfies the Discrete Time Markov Chain (DTMC) property: for each state the outflow transition weights are reals (or just rationals, if that makes a diffe...
probability theory model checking markov chains
1
Calculating probability of reaching state in DTMC -- (probability theory model checking markov chains) <p>Consider a highly-connected graph of states &amp; transitions where each transition is marked with a weight (representing probability of occurring) and the graph satisfies the Discrete Time Markov Chain (DTMC) prop...
habedi/stack-exchange-dataset
115,609
I want to design a context free grammar for the following
<p>This below language</p>&#xA;&#xA;<p><span class="math-container">$$L = \{ w \in \{a, b\}^n : \lvert w\rvert \text{ mod } 3 = 0 \}$$</span>&#xA;where <span class="math-container">$n \geq0$</span>.</p>&#xA;
context free formal grammars
1
I want to design a context free grammar for the following -- (context free formal grammars) <p>This below language</p>&#xA;&#xA;<p><span class="math-container">$$L = \{ w \in \{a, b\}^n : \lvert w\rvert \text{ mod } 3 = 0 \}$$</span>&#xA;where <span class="math-container">$n \geq0$</span>.</p>&#xA;
habedi/stack-exchange-dataset
115,649
How does this recursive algorithm work?
<p>One question from the Grokking Algorithms book:</p>&#xA;&#xA;<p>Implement a <code>max([]int)</code> function, returning the biggest element in the array.</p>&#xA;&#xA;<p>Here's my solution in Golang (adapted from the Python solution in the book):</p>&#xA;&#xA;<pre><code>func maxNumber(arr []int) (r int) {&#xA; //...
recursion
1
How does this recursive algorithm work? -- (recursion) <p>One question from the Grokking Algorithms book:</p>&#xA;&#xA;<p>Implement a <code>max([]int)</code> function, returning the biggest element in the array.</p>&#xA;&#xA;<p>Here's my solution in Golang (adapted from the Python solution in the book):</p>&#xA;&#xA;<p...
habedi/stack-exchange-dataset
115,655
How to answer multiple queries efficiently?
<p>I am given a <span class="math-container">$N$</span>-length integer array. For each integer, I am given 4 values:</p>&#xA;&#xA;<p><span class="math-container">$$[\mathit{left},\mathit{right},t,\mathit{value}]$$</span>&#xA;<span class="math-container">$$1\leq \mathit{left},\mathit{right},t\leq N$$</span></p>&#xA;&#xA...
algorithms arrays
1
How to answer multiple queries efficiently? -- (algorithms arrays) <p>I am given a <span class="math-container">$N$</span>-length integer array. For each integer, I am given 4 values:</p>&#xA;&#xA;<p><span class="math-container">$$[\mathit{left},\mathit{right},t,\mathit{value}]$$</span>&#xA;<span class="math-container"...
habedi/stack-exchange-dataset
115,666
complexity of a variant of the subset sum problem
<p>We have a set of positive integers <span class="math-container">$N=\{a_1,...,a_n\}$</span>, we want to select a subset <span class="math-container">$N'$</span> of <span class="math-container">$N$</span> with maximum total sum of integers such that this sum should not exceed a given integer <span class="math-containe...
algorithms complexity theory np complete np hard subset sum
1
complexity of a variant of the subset sum problem -- (algorithms complexity theory np complete np hard subset sum) <p>We have a set of positive integers <span class="math-container">$N=\{a_1,...,a_n\}$</span>, we want to select a subset <span class="math-container">$N'$</span> of <span class="math-container">$N$</span>...
habedi/stack-exchange-dataset
115,670
Matching each unique pokemon with a unique move
<p><strong>Background:</strong> </p>&#xA;&#xA;<ul>&#xA;<li>There are 832 unique Pokemon in the Pokemon universe, and </li>&#xA;<li>There are 728 fighting moves that the Pokemon can collectively learn.</li>&#xA;<li>No Pokemon can learn to do every fighting move, and some Pokemon can only learn one.</li>&#xA;<li>The aver...
graphs matching
1
Matching each unique pokemon with a unique move -- (graphs matching) <p><strong>Background:</strong> </p>&#xA;&#xA;<ul>&#xA;<li>There are 832 unique Pokemon in the Pokemon universe, and </li>&#xA;<li>There are 728 fighting moves that the Pokemon can collectively learn.</li>&#xA;<li>No Pokemon can learn to do every figh...
habedi/stack-exchange-dataset
115,682
Practical hard 3-sat instances
<p>The <span class="math-container">$3-SAT$</span> problem is known to be NP-complete problem. Which means that (as far as I understand), unless <span class="math-container">$P \neq NP$</span>, for every algorithm <span class="math-container">$A$</span> which decides <span class="math-container">$3-SAT$</span>, <span c...
complexity theory time complexity satisfiability sat solvers
1
Practical hard 3-sat instances -- (complexity theory time complexity satisfiability sat solvers) <p>The <span class="math-container">$3-SAT$</span> problem is known to be NP-complete problem. Which means that (as far as I understand), unless <span class="math-container">$P \neq NP$</span>, for every algorithm <span cla...
habedi/stack-exchange-dataset
115,692
Finite / Infinite Languages True/False and why?
<p>Just doing some work on Finite and infinite languages. And came across some statements I know the answer to but not sure how to explain why. </p>&#xA;&#xA;<ol>&#xA;<li><p>There are finitely many finite languages. &#xA;-This is false right? Since there are technically infinitely many finite languages</p></li>&#xA;<li...
regular languages finite automata
1
Finite / Infinite Languages True/False and why? -- (regular languages finite automata) <p>Just doing some work on Finite and infinite languages. And came across some statements I know the answer to but not sure how to explain why. </p>&#xA;&#xA;<ol>&#xA;<li><p>There are finitely many finite languages. &#xA;-This is fal...
habedi/stack-exchange-dataset
115,699
Why does this triple loop code have a running time of 1.5lnN * N^2
<p><a href="https://i.stack.imgur.com/DPFyj.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/DPFyj.png" alt="r"></a>&#xA;Hi all, I'm currently going through the Princeton Algorithms course on coursera, and I'm having trouble understanding the answer to this quiz. I think I understand where the <span c...
time complexity runtime analysis
1
Why does this triple loop code have a running time of 1.5lnN * N^2 -- (time complexity runtime analysis) <p><a href="https://i.stack.imgur.com/DPFyj.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/DPFyj.png" alt="r"></a>&#xA;Hi all, I'm currently going through the Princeton Algorithms course on cours...
habedi/stack-exchange-dataset
115,726
All languages are regular, as unions of singleton languages
<p>We know that singleton languages (languages containing exactly one word) are regular. We also know that a finite union of regular languages is also regular.</p>&#xA;&#xA;<p>Suppose there is a non-regular language <span class="math-container">$L$</span>. For every finite subset <span class="math-container">$\{x_1,x_2...
formal languages regular languages finite automata
1
All languages are regular, as unions of singleton languages -- (formal languages regular languages finite automata) <p>We know that singleton languages (languages containing exactly one word) are regular. We also know that a finite union of regular languages is also regular.</p>&#xA;&#xA;<p>Suppose there is a non-regul...
habedi/stack-exchange-dataset
115,727
Proof with induction even number of letter
<p>I have to proof that in a word <span class="math-container">$w$</span> the number of the letter d is always even.</p>&#xA;<p>Let <span class="math-container">$L \subsetneq \Sigma^*$</span> be a language over the alphabet <span class="math-container">$\Sigma = \{a,b,c,d\}$</span>&#xA;such that a word <span class="mat...
formal languages
1
Proof with induction even number of letter -- (formal languages) <p>I have to proof that in a word <span class="math-container">$w$</span> the number of the letter d is always even.</p>&#xA;<p>Let <span class="math-container">$L \subsetneq \Sigma^*$</span> be a language over the alphabet <span class="math-container">$\...
habedi/stack-exchange-dataset
115,732
How does the function to curry and uncurrying another function work?
<p>The following is the code to curry or uncurry a function in Haskell:</p>&#xA;&#xA;<pre><code>curry :: ((a, b) -&gt; c) -&gt; a -&gt; b -&gt; c&#xA;curry f a b = f (a, b)&#xA;&#xA;uncurry :: (a -&gt; b -&gt; c) -&gt; (a, b) -&gt; c&#xA;uncurry f (a, b) = f a b&#xA;</code></pre>&#xA;&#xA;<p>I can understand the type s...
lambda calculus functional programming haskell
1
How does the function to curry and uncurrying another function work? -- (lambda calculus functional programming haskell) <p>The following is the code to curry or uncurry a function in Haskell:</p>&#xA;&#xA;<pre><code>curry :: ((a, b) -&gt; c) -&gt; a -&gt; b -&gt; c&#xA;curry f a b = f (a, b)&#xA;&#xA;uncurry :: (a -&g...
habedi/stack-exchange-dataset
115,734
How to split a context-free language into three sub-languages?
<p>I try to split the language&#xA;<span class="math-container">$$&#xA;L = \{a^ib^j \mid i \neq 2j, i \neq 3j\}&#xA;$$</span>&#xA;into three languages&#xA;<span class="math-container">\begin{align}&#xA;L_1 &amp;= \{a^ib^j \mid i &lt; 2j\} \\&#xA;L_2 &amp;= \{a^ib^j \mid 2j &lt; i &lt; 3j\} \\&#xA;L_3 &amp;= \{a^ib^j \m...
formal languages context free formal grammars
1
How to split a context-free language into three sub-languages? -- (formal languages context free formal grammars) <p>I try to split the language&#xA;<span class="math-container">$$&#xA;L = \{a^ib^j \mid i \neq 2j, i \neq 3j\}&#xA;$$</span>&#xA;into three languages&#xA;<span class="math-container">\begin{align}&#xA;L_1 ...
habedi/stack-exchange-dataset
115,738
Why does higher-order abstract syntax need an inverse to define catamorphisms?
<p>In the introduction to the colorfully-named <a href="https://www.seas.upenn.edu/~sweirich/papers/itabox/icfp-published-version.pdf" rel="noreferrer">Boxes Go Bananas: Encoding Higher-Order Abstract Syntax with Parametric Polymorphism</a>, Washburn and Weirich describe a problem in traditional formulations of higher-...
programming languages functional programming haskell
1
Why does higher-order abstract syntax need an inverse to define catamorphisms? -- (programming languages functional programming haskell) <p>In the introduction to the colorfully-named <a href="https://www.seas.upenn.edu/~sweirich/papers/itabox/icfp-published-version.pdf" rel="noreferrer">Boxes Go Bananas: Encoding High...
habedi/stack-exchange-dataset
115,739
Algorithm to Minimize a Regular Expression
<p>I am referring to regular expressions with alphabet {<span class="math-container">$0$</span>, <span class="math-container">$1$</span>}. We want to minimize them so that they have the least possible number of symbols and operators. Is there an algorithm to do this?</p>&#xA;&#xA;<p>For instance, what is done on this p...
regular expressions
1
Algorithm to Minimize a Regular Expression -- (regular expressions) <p>I am referring to regular expressions with alphabet {<span class="math-container">$0$</span>, <span class="math-container">$1$</span>}. We want to minimize them so that they have the least possible number of symbols and operators. Is there an algori...
habedi/stack-exchange-dataset
115,744
What will be the pictorial diagram of this transition table?
<p>I was doing my homework and I am confused on what I'm doing, it can't be that straightforward. I'm making a mistake somewhere. I tried looking for practice problems but they don't cover my issue either, I'm still confused. What will be the pictorial diagram for the following transition table?</p>&#xA;&#xA;<p><a href...
finite automata
1
What will be the pictorial diagram of this transition table? -- (finite automata) <p>I was doing my homework and I am confused on what I'm doing, it can't be that straightforward. I'm making a mistake somewhere. I tried looking for practice problems but they don't cover my issue either, I'm still confused. What will be...
habedi/stack-exchange-dataset
115,751
Context-free grammar how to have unequal number of a's on either side of b
<p>I have been trying to create a CFG for the set&#xA;<span class="math-container">$\{w=a^iba^j \mid i \neq j\}$</span>.</p>&#xA;&#xA;<p>To my understanding, there are essentially 2 scenarios, one where there are more <span class="math-container">$a$</span>s on the left side of <span class="math-container">$b$</span>, ...
formal languages context free formal grammars
1
Context-free grammar how to have unequal number of a's on either side of b -- (formal languages context free formal grammars) <p>I have been trying to create a CFG for the set&#xA;<span class="math-container">$\{w=a^iba^j \mid i \neq j\}$</span>.</p>&#xA;&#xA;<p>To my understanding, there are essentially 2 scenarios, o...
habedi/stack-exchange-dataset
115,755
Context-free grammar how to have same number of variables within a language
<p>I am trying to get a CFG for the language:</p>&#xA;&#xA;<blockquote>&#xA; <p>The set <span class="math-container">$A$</span> of odd-length strings in <span class="math-container">$\{a,b\}^*$</span> whose first, middle and last symbols are all the same.</p>&#xA;</blockquote>&#xA;&#xA;<p>(some example of correct answ...
context free
1
Context-free grammar how to have same number of variables within a language -- (context free) <p>I am trying to get a CFG for the language:</p>&#xA;&#xA;<blockquote>&#xA; <p>The set <span class="math-container">$A$</span> of odd-length strings in <span class="math-container">$\{a,b\}^*$</span> whose first, middle and ...
habedi/stack-exchange-dataset
115,759
Is {a^n: n is a product of exactly two primes} regular?
<p>I am struggling to prove the following question.</p>&#xA;&#xA;<blockquote>&#xA; <p><span class="math-container">$L_1 = \{a^n: n \text{ is a product of exactly two primes}\}$</span></p>&#xA;</blockquote>&#xA;&#xA;<p>I feel like the language is not regular but I am having trouble proving it. I tried using pumping lem...
formal languages regular languages proof techniques pumping lemma
1
Is {a^n: n is a product of exactly two primes} regular? -- (formal languages regular languages proof techniques pumping lemma) <p>I am struggling to prove the following question.</p>&#xA;&#xA;<blockquote>&#xA; <p><span class="math-container">$L_1 = \{a^n: n \text{ is a product of exactly two primes}\}$</span></p>&#xA;...
habedi/stack-exchange-dataset
115,761
Simplifying the Boolean expression $A + \bar{A}\bar{B}$?
<p>So I'm trying to simplify the Boolean expression (1) <span class="math-container">$A + \bar{A}\bar{B}$</span>.</p>&#xA;&#xA;<p>I noticed that by Karnaugh maps this is equivalent to <span class="math-container">$A+\bar{B}$</span>, and I also noticed that if I take the complement of (1), I get ~(1)= <span class="math-...
boolean algebra
1
Simplifying the Boolean expression $A + \bar{A}\bar{B}$? -- (boolean algebra) <p>So I'm trying to simplify the Boolean expression (1) <span class="math-container">$A + \bar{A}\bar{B}$</span>.</p>&#xA;&#xA;<p>I noticed that by Karnaugh maps this is equivalent to <span class="math-container">$A+\bar{B}$</span>, and I als...
habedi/stack-exchange-dataset
115,774
Why companies that create native mobile apps are forced to make duplicate versions on other platforms?
<p>I am not computer savvy, so forgive me for asking why companies that create native mobile apps are forced to make duplicate versions on other platforms. "Duplicate" means the "same", so it means those companies don't have to modify the original version of the native mobile app for other platforms. I am guessing "oth...
applications
1
Why companies that create native mobile apps are forced to make duplicate versions on other platforms? -- (applications) <p>I am not computer savvy, so forgive me for asking why companies that create native mobile apps are forced to make duplicate versions on other platforms. "Duplicate" means the "same", so it means t...
habedi/stack-exchange-dataset
115,782
Arithmetic operators and regex
<p>Let <span class="math-container">$L$</span> be the language over the alphabet <span class="math-container">$\{0, 1, 2, 3, (,), +, -, *, /\}$</span>, <span class="math-container">$L$</span> is the set of operations with correctly formatted natural numbers. A single number is considered to belong to <span class="math-...
regular expressions
1
Arithmetic operators and regex -- (regular expressions) <p>Let <span class="math-container">$L$</span> be the language over the alphabet <span class="math-container">$\{0, 1, 2, 3, (,), +, -, *, /\}$</span>, <span class="math-container">$L$</span> is the set of operations with correctly formatted natural numbers. A sin...
habedi/stack-exchange-dataset
115,791
Does there exist any unrelativized separation between a quantum complexity class and a classical one?
<p>I'm familiar with results of relativized separation for BPP-BQP, BQP-PH and NPC-BQP. I'm also aware that while e.g. Factoring is not believed to be in BPP, it hasn't been proven and so we're not quite near proving BQP!=BPP.</p>&#xA;&#xA;<p>My question is, do we have any certain, theoretical, unrelativized proof that...
complexity theory quantum computing oracle machines
1
Does there exist any unrelativized separation between a quantum complexity class and a classical one? -- (complexity theory quantum computing oracle machines) <p>I'm familiar with results of relativized separation for BPP-BQP, BQP-PH and NPC-BQP. I'm also aware that while e.g. Factoring is not believed to be in BPP, it...
habedi/stack-exchange-dataset
115,793
Existence of d-regular subgraphs in a k-regular graph
<p>The claim is as follows:&#xA;Let's say we have a <span class="math-container">$k$</span>-regular simple undirected graph <span class="math-container">$G$</span> on <span class="math-container">$n$</span> vertices. Then, does <span class="math-container">$G$</span> then always have a <span class="math-container">$d$<...
graphs
1
Existence of d-regular subgraphs in a k-regular graph -- (graphs) <p>The claim is as follows:&#xA;Let's say we have a <span class="math-container">$k$</span>-regular simple undirected graph <span class="math-container">$G$</span> on <span class="math-container">$n$</span> vertices. Then, does <span class="math-containe...
habedi/stack-exchange-dataset
115,797
Remove x last elements of an array and reinsert them before position y
<p>I am looking for an algorithm to move a subarray in before an element (which is not part of that subarray) in the same array where the last element of the subarray is the last element of the array with O(1) extra space and O(n) runtime.</p>&#xA;&#xA;<p>e.g. where *p1 = 5 and *p2 = 3:</p>&#xA;&#xA;<p>1 2 5 6 7 3 4</p...
algorithms arrays
1
Remove x last elements of an array and reinsert them before position y -- (algorithms arrays) <p>I am looking for an algorithm to move a subarray in before an element (which is not part of that subarray) in the same array where the last element of the subarray is the last element of the array with O(1) extra space and ...
habedi/stack-exchange-dataset
115,806
Modifies Dijkstra’s Algorithm to find the maximum cost path
<p>In a DAG and all weights are larger than 0. Is it possible to use a max heap to get the maximum cost? </p>&#xA;
graphs shortest path
1
Modifies Dijkstra’s Algorithm to find the maximum cost path -- (graphs shortest path) <p>In a DAG and all weights are larger than 0. Is it possible to use a max heap to get the maximum cost? </p>&#xA;
habedi/stack-exchange-dataset
115,812
Pushdown Automata - can you have multiple transition functions options between 2 states?
<p>I was wondering if you have 2 states, lets say q0 and q1. Are you allowed to have multiple options to transition between these 2 states?</p>&#xA;&#xA;<p>For example,</p>&#xA;&#xA;<pre><code> - if you have a 1 and the stack is empty, push it on the stack, and transition to q1&#xA; - if you have a 0 and the stack is e...
pushdown automata
1
Pushdown Automata - can you have multiple transition functions options between 2 states? -- (pushdown automata) <p>I was wondering if you have 2 states, lets say q0 and q1. Are you allowed to have multiple options to transition between these 2 states?</p>&#xA;&#xA;<p>For example,</p>&#xA;&#xA;<pre><code> - if you have ...
habedi/stack-exchange-dataset
115,819
nested boxes algorithm
<p>I am given a set of 3D boxes {<span class="math-container">$B_1$</span>, <span class="math-container">$B_2$</span>...<span class="math-container">$B_n$</span>} and each box have length, width and height. But these values are interchangeable since I can rotate the box. I need to find out the maximum sequence of neste...
algorithms data structures
1
nested boxes algorithm -- (algorithms data structures) <p>I am given a set of 3D boxes {<span class="math-container">$B_1$</span>, <span class="math-container">$B_2$</span>...<span class="math-container">$B_n$</span>} and each box have length, width and height. But these values are interchangeable since I can rotate th...
habedi/stack-exchange-dataset
115,832
Find the minimal tank capacity to be able to travel from any city to any other
<p>There are <span class="math-container">$n$</span> cities in the country. The car can go from any city <span class="math-container">$u$</span> to city <span class="math-container">$v$</span>, On this road it spends <span class="math-container">$w_{u,v} &gt; 0$</span> fuel. At the same <span class="math-container">$w_...
algorithms graphs dynamic programming graph traversal weighted graphs
1
Find the minimal tank capacity to be able to travel from any city to any other -- (algorithms graphs dynamic programming graph traversal weighted graphs) <p>There are <span class="math-container">$n$</span> cities in the country. The car can go from any city <span class="math-container">$u$</span> to city <span class="...
habedi/stack-exchange-dataset
115,845
How to deal with parallel edges between two vertices in cycle detection using BFS in an undirected graph?
<p>I am new to Programming and learning Algorithms and was studying BFS when I read that BFS could be used for cycle detection. I tried to implement the same on an undirected graph G with Adjacency List Representation.&#xA;What I did is as follows:</p>&#xA;<blockquote>&#xA;<p>• Do a simple BFS Traversal using a Queue w...
graphs graph traversal
1
How to deal with parallel edges between two vertices in cycle detection using BFS in an undirected graph? -- (graphs graph traversal) <p>I am new to Programming and learning Algorithms and was studying BFS when I read that BFS could be used for cycle detection. I tried to implement the same on an undirected graph G wit...
habedi/stack-exchange-dataset
115,846
Are SAT problems with at most one false clause NP-complete?
<p>Is the problem of deciding whether a <a href="https://en.wikipedia.org/wiki/Boolean_satisfiability_problem" rel="nofollow noreferrer">SAT</a> instance, where at most one clause is false (that is, any given variable assignment will either lead to all clauses being true, or all but one), is satisfiable solvable in pol...
complexity theory np complete satisfiability
1
Are SAT problems with at most one false clause NP-complete? -- (complexity theory np complete satisfiability) <p>Is the problem of deciding whether a <a href="https://en.wikipedia.org/wiki/Boolean_satisfiability_problem" rel="nofollow noreferrer">SAT</a> instance, where at most one clause is false (that is, any given v...
habedi/stack-exchange-dataset
115,857
Understanding addition overflows when performing full, signed multiplication of two 64-bit numbers
<p>I am close to solving question 3.59 from Computer Systems: A Programmer's Perspective 3rd Editionby Randal E. Bryant and David R. O'Hallaron, however I am having difficulties with understanding the result.</p>&#xA;&#xA;<p>Question 3.59 asks you to examine a sample of C and x86_64 assembly code that performs a full, ...
algorithms multiplication assembly
1
Understanding addition overflows when performing full, signed multiplication of two 64-bit numbers -- (algorithms multiplication assembly) <p>I am close to solving question 3.59 from Computer Systems: A Programmer's Perspective 3rd Editionby Randal E. Bryant and David R. O'Hallaron, however I am having difficulties wit...
habedi/stack-exchange-dataset
115,860
Bubble sort: how to calculate amount of comparisons and swaps
<p>For a given sequence 1, N ,2 ,N −1 ,3, N −2, ... I want to calculate the number of comparisons and swaps for bubble sort. How can I accomplish that using <span class="math-container">$\theta ()$</span> notation? I would know how to do it for any sequence, but not for a given one.</p>&#xA;
asymptotics sorting
1
Bubble sort: how to calculate amount of comparisons and swaps -- (asymptotics sorting) <p>For a given sequence 1, N ,2 ,N −1 ,3, N −2, ... I want to calculate the number of comparisons and swaps for bubble sort. How can I accomplish that using <span class="math-container">$\theta ()$</span> notation? I would know how t...
habedi/stack-exchange-dataset
115,862
If R is a regular language, is $R^3= R \circ R \circ R$ also regular?
<p>My understanding of a regular language is that for a language to be formal, it must be able to be represented by a DFA or NFA. To prove a language is not regular you can use the pumping lemma to get a contradiction.</p>&#xA;&#xA;<p>I am trying to figure out whether <span class="math-container">$R^3$</span> or <span ...
regular languages
1
If R is a regular language, is $R^3= R \circ R \circ R$ also regular? -- (regular languages) <p>My understanding of a regular language is that for a language to be formal, it must be able to be represented by a DFA or NFA. To prove a language is not regular you can use the pumping lemma to get a contradiction.</p>&#xA;...
habedi/stack-exchange-dataset
115,865
Prove that there isn't a DFA characterized by (a*)+(b*) for which |Q| = 3
<blockquote>&#xA; <p>Let <span class="math-container">$R=(a*)+(b*)$</span> be a regular expression. Prove that there cannot exist any DFA <span class="math-container">$M=(Q,\Sigma,\delta , q0, A)$</span> such that <span class="math-container">$|Q| = 3$</span> and <span class="math-container">$L(M)=L(R)$</span>.</p>&#x...
automata regular languages
1
Prove that there isn't a DFA characterized by (a*)+(b*) for which |Q| = 3 -- (automata regular languages) <blockquote>&#xA; <p>Let <span class="math-container">$R=(a*)+(b*)$</span> be a regular expression. Prove that there cannot exist any DFA <span class="math-container">$M=(Q,\Sigma,\delta , q0, A)$</span> such that...
habedi/stack-exchange-dataset
115,877
Why does Min-Max algorithm delays a good move indefinitely?
<p>Consider a simple chess example:</p>&#xA;&#xA;<p>Q is white Queen.</p>&#xA;&#xA;<p>K, R is black King and black Rook respectively.</p>&#xA;&#xA;<pre><code> A B&#xA;1 . Q&#xA;2 . .&#xA;3 K .&#xA;4 . .&#xA;5 . .&#xA;6 R .&#xA;7 . .&#xA;8 . R&#xA;</code></pre>&#xA;&#xA;<p>1,2...8 is the rank and A and B are the files ...
algorithms game theory minmax algorithm minimax
1
Why does Min-Max algorithm delays a good move indefinitely? -- (algorithms game theory minmax algorithm minimax) <p>Consider a simple chess example:</p>&#xA;&#xA;<p>Q is white Queen.</p>&#xA;&#xA;<p>K, R is black King and black Rook respectively.</p>&#xA;&#xA;<pre><code> A B&#xA;1 . Q&#xA;2 . .&#xA;3 K .&#xA;4 . .&#xA...
habedi/stack-exchange-dataset
115,881
How does one simulate continuous gravity using a discrete timestep?
<p>While gravity in real life is continuous, computers are limited to discrete calculations.</p>&#xA;&#xA;<p>Therefore, a seemingly correct projectile simulation inevitably drifts off.</p>&#xA;&#xA;<p>For example:</p>&#xA;&#xA;<pre><code>// Repeat once per frame&#xA;position += velocity * deltaTime;&#xA;velocity += gra...
discrete mathematics physics
1
How does one simulate continuous gravity using a discrete timestep? -- (discrete mathematics physics) <p>While gravity in real life is continuous, computers are limited to discrete calculations.</p>&#xA;&#xA;<p>Therefore, a seemingly correct projectile simulation inevitably drifts off.</p>&#xA;&#xA;<p>For example:</p>&...
habedi/stack-exchange-dataset
115,883
How can a 32bit CPU have an addressable memory size of 16TB?
<p>Frequently, on a 32-bit CPU, each page-table entry is 4 bytes long, but that&#xA;size can vary as well.</p>&#xA;&#xA;<p>A 32-bit entry can point to one of <span class="math-container">$2^{32}$</span> physical page frames.</p>&#xA;&#xA;<p>If frame size is 4 KB (212), then a system with 4-byte entries can address <spa...
operating systems
1
How can a 32bit CPU have an addressable memory size of 16TB? -- (operating systems) <p>Frequently, on a 32-bit CPU, each page-table entry is 4 bytes long, but that&#xA;size can vary as well.</p>&#xA;&#xA;<p>A 32-bit entry can point to one of <span class="math-container">$2^{32}$</span> physical page frames.</p>&#xA;&#x...
habedi/stack-exchange-dataset
115,908
Show that,with the array representation for sorting an n-element heap, the leaves are the nodes indexed by n⌊n/2⌋+1,⌊n/2⌋+2,…,n
<p>The Question of the CLRS <span class="math-container">$6.1-7$</span> exercise reads as:</p>&#xA;&#xA;<blockquote>&#xA; <blockquote>&#xA; <p>Show that, with the array representation for sorting an n-element heap, the leaves are the nodes indexed by <span class="math-container">$\lfloor n / 2 \rfloor + 1, \lfloor ...
algorithms heap sort
1
Show that,with the array representation for sorting an n-element heap, the leaves are the nodes indexed by n⌊n/2⌋+1,⌊n/2⌋+2,…,n -- (algorithms heap sort) <p>The Question of the CLRS <span class="math-container">$6.1-7$</span> exercise reads as:</p>&#xA;&#xA;<blockquote>&#xA; <blockquote>&#xA; <p>Show that, with the...
habedi/stack-exchange-dataset
115,927
A problem on sets
<p>Given a collection C of sets, with union U, find a choice function which chooses a distinct element from each of the sets such that the union of the singleton distinct elements is U.</p>&#xA;&#xA;<p>As an example, if we have the collection {1,2,3,4},{0,2,3,4},{0,1,3,4},{0,1,2,4} and {0,1,2,3} we can choose 1,0,3,4,2...
algorithms sets
1
A problem on sets -- (algorithms sets) <p>Given a collection C of sets, with union U, find a choice function which chooses a distinct element from each of the sets such that the union of the singleton distinct elements is U.</p>&#xA;&#xA;<p>As an example, if we have the collection {1,2,3,4},{0,2,3,4},{0,1,3,4},{0,1,2,4...
habedi/stack-exchange-dataset
115,930
Grokking pseudo-code for solution to gas station problem
<p>I'm trying to grok the pseudo-code for the gas station problem (which I think we should start calling the charging station problem but that's a different story) given as Fill-Row in Fig. 1 in <em><a href="http://www.cs.umd.edu/users/samir/grant/gas-j.pdf" rel="nofollow noreferrer">To Fill or not to Fill: The Gas Sta...
algorithms graphs optimization dynamic programming recurrence relation
1
Grokking pseudo-code for solution to gas station problem -- (algorithms graphs optimization dynamic programming recurrence relation) <p>I'm trying to grok the pseudo-code for the gas station problem (which I think we should start calling the charging station problem but that's a different story) given as Fill-Row in Fi...
habedi/stack-exchange-dataset
115,931
$L=\{a^ib^i|i\geq0\}$, cfg for $L^2$
<p><span class="math-container">$L=\{a^ib^i|i\geq0\}$</span>, cfg for <span class="math-container">$L^2$</span></p>&#xA;&#xA;<p>can you write cfg for <span class="math-container">$L^2$</span> where <span class="math-container">$L=\{a^ib^i|i\geq0\}$</span>?</p>&#xA;&#xA;<p>the professor's answer sheet says it's <span cl...
automata context free
1
$L=\{a^ib^i|i\geq0\}$, cfg for $L^2$ -- (automata context free) <p><span class="math-container">$L=\{a^ib^i|i\geq0\}$</span>, cfg for <span class="math-container">$L^2$</span></p>&#xA;&#xA;<p>can you write cfg for <span class="math-container">$L^2$</span> where <span class="math-container">$L=\{a^ib^i|i\geq0\}$</span>?...
habedi/stack-exchange-dataset
115,934
Constructing a DFA of strings that are in A but not in B
<p>I am tasked with creating a DFA for the regular language L = A/B, which are the strings that are in A but not in B. The alphabet is Σ = {a,b,c}</p>&#xA;&#xA;<p>I am not really sure where to even start with this one, so any hints or suggestions would be much appreciated. I have never really encountered anything like ...
formal languages regular languages finite automata formal grammars regular expressions
1
Constructing a DFA of strings that are in A but not in B -- (formal languages regular languages finite automata formal grammars regular expressions) <p>I am tasked with creating a DFA for the regular language L = A/B, which are the strings that are in A but not in B. The alphabet is Σ = {a,b,c}</p>&#xA;&#xA;<p>I am not...
habedi/stack-exchange-dataset
115,935
Finding the shortest time to go from one stop to another stop in a train system with many train lines with connection stations
<p>So I was thinking after discussing with my friend the other day, how would I use something like breadth-first or depth-first search to find the fastest time to go from one station to another station if there are a number of different train lines in a subway system. They may cross over each other, maybe multiple time...
search algorithms search trees
1
Finding the shortest time to go from one stop to another stop in a train system with many train lines with connection stations -- (search algorithms search trees) <p>So I was thinking after discussing with my friend the other day, how would I use something like breadth-first or depth-first search to find the fastest ti...
habedi/stack-exchange-dataset
115,945
How do we formally regard a function that takes a lookup set as a parameter?
<p>I have a function that takes a set as a parameter. The function <span class="math-container">$\phi$</span> maps a general <span class="math-container">$x \in R$</span>, where <span class="math-container">$R$</span> is a commutative ring with <span class="math-container">$1$</span>, to a <span class="math-container"...
formal languages formal grammars
1
How do we formally regard a function that takes a lookup set as a parameter? -- (formal languages formal grammars) <p>I have a function that takes a set as a parameter. The function <span class="math-container">$\phi$</span> maps a general <span class="math-container">$x \in R$</span>, where <span class="math-containe...
habedi/stack-exchange-dataset
115,950
How to show that every quadratic, asymptotically nonnegative function $\in \Theta(n^2)$
<p>In the book CLRS the authors say that every quadratic, asymptotically nonnegative function <span class="math-container">$f(n) = an^2 + bn + c$</span> is an element of <span class="math-container">$\Theta(n^2)$</span>. Using the following definition</p>&#xA;&#xA;<blockquote>&#xA; <p><span class="math-container">\beg...
complexity theory asymptotics
1
How to show that every quadratic, asymptotically nonnegative function $\in \Theta(n^2)$ -- (complexity theory asymptotics) <p>In the book CLRS the authors say that every quadratic, asymptotically nonnegative function <span class="math-container">$f(n) = an^2 + bn + c$</span> is an element of <span class="math-container...
habedi/stack-exchange-dataset
115,952
Find a truth assignment of 2SAT that has the most number of true variables?
<p>Given a 2SAT instance in CNF where each clause has at most two literals. Let <span class="math-container">$m$</span> be the number of clauses and <span class="math-container">$n$</span> be the number of variables et let <span class="math-container">$k$</span> be a positive number.</p>&#xA;&#xA;<p>Question: Is there ...
complexity theory np complete satisfiability
1
Find a truth assignment of 2SAT that has the most number of true variables? -- (complexity theory np complete satisfiability) <p>Given a 2SAT instance in CNF where each clause has at most two literals. Let <span class="math-container">$m$</span> be the number of clauses and <span class="math-container">$n$</span> be th...
habedi/stack-exchange-dataset
115,963
Efficient algorithm for finding optimal sum from both arrays
<p>I have two arrays(A,B) and a sum M. I need to find one number from each array that makes the sum M. If there is no two elements that form sum M, then nearest and less than M sum is the solution. See examples below. What is the efficient way to find the solution for this? </p>&#xA;&#xA;<pre><code>eg1: &#xA;A =[200,3...
algorithms arrays
1
Efficient algorithm for finding optimal sum from both arrays -- (algorithms arrays) <p>I have two arrays(A,B) and a sum M. I need to find one number from each array that makes the sum M. If there is no two elements that form sum M, then nearest and less than M sum is the solution. See examples below. What is the effici...
habedi/stack-exchange-dataset
115,969
Prove, that $A^+\subseteq A^*$ where $A$ is a formal language
<blockquote>&#xA; <p>Prove, that <span class="math-container">$A^+\subseteq A^*$</span>, where <span class="math-container">$A$</span> is a formal language.</p>&#xA;</blockquote>&#xA;&#xA;<p>The definition of <span class="math-container">$A^+$</span> is <span class="math-container">$\bigcup_{i\in\mathbb{N}\setminus \{...
formal languages kleene star
1
Prove, that $A^+\subseteq A^*$ where $A$ is a formal language -- (formal languages kleene star) <blockquote>&#xA; <p>Prove, that <span class="math-container">$A^+\subseteq A^*$</span>, where <span class="math-container">$A$</span> is a formal language.</p>&#xA;</blockquote>&#xA;&#xA;<p>The definition of <span class="m...
habedi/stack-exchange-dataset
115,976
Numerical issues in solving linear systems
<p>There was an exam in the class. The course is &quot;High Performance Scientific Computing&quot;. One of the question in the exam is as follows:</p>&#xA;<blockquote>&#xA;<p>Consider the linear system</p>&#xA;<p><span class="math-container">$$ \begin{bmatrix} a &amp; b \\ b &amp; a \end{bmatrix} \times \begin{bmatrix}...
numerical analysis error estimation matrix
1
Numerical issues in solving linear systems -- (numerical analysis error estimation matrix) <p>There was an exam in the class. The course is &quot;High Performance Scientific Computing&quot;. One of the question in the exam is as follows:</p>&#xA;<blockquote>&#xA;<p>Consider the linear system</p>&#xA;<p><span class="mat...
habedi/stack-exchange-dataset
115,992
How do I solve these questions regarding homomorphism?
<p><a href="https://i.stack.imgur.com/mZ7Md.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/mZ7Md.png" alt="enter image description here"></a>&#xA;Questions: </p>&#xA;&#xA;<ol>&#xA;<li>Give an example of a homomorphism, using the same alphabet, Σ, for both languages A and B.</li>&#xA;<li>Now, give a ...
formal languages regular languages finite automata regular expressions
1
How do I solve these questions regarding homomorphism? -- (formal languages regular languages finite automata regular expressions) <p><a href="https://i.stack.imgur.com/mZ7Md.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/mZ7Md.png" alt="enter image description here"></a>&#xA;Questions: </p>&#xA;&#x...
habedi/stack-exchange-dataset
115,994
What is google docs solution to handling multiple users editing and reading at the same time?
<p>I have always been curious as to how google solved the solution of real time collaboration in their google docs product where they allow multiple users to edit and read the same document in real time.</p>&#xA;&#xA;<p>I believe this is very similar to the well known readers and writers problem.</p>&#xA;&#xA;<p>In som...
algorithms concurrency
1
What is google docs solution to handling multiple users editing and reading at the same time? -- (algorithms concurrency) <p>I have always been curious as to how google solved the solution of real time collaboration in their google docs product where they allow multiple users to edit and read the same document in real ...
habedi/stack-exchange-dataset
115,995
Trivial solution to the Continuous Knapsack problem
<p>I am a bit puzzled as to why the continuous knapsack problem is a non-trivial problem </p>&#xA;&#xA;<p><a href="https://en.m.wikipedia.org/wiki/Continuous_knapsack_problem" rel="nofollow noreferrer">https://en.m.wikipedia.org/wiki/Continuous_knapsack_problem</a></p>&#xA;&#xA;<p>Using the terminology in the Wikipedia...
greedy algorithms
1
Trivial solution to the Continuous Knapsack problem -- (greedy algorithms) <p>I am a bit puzzled as to why the continuous knapsack problem is a non-trivial problem </p>&#xA;&#xA;<p><a href="https://en.m.wikipedia.org/wiki/Continuous_knapsack_problem" rel="nofollow noreferrer">https://en.m.wikipedia.org/wiki/Continuous_...
habedi/stack-exchange-dataset
116,017
Modeling a set of probabilistic concurrent processes
<p>I'm looking into discrete-time Markov chains (DTMCs) for use in analyzing a probabilistic consensus protocol. One basic thing I haven't been able to figure out is how to model a set of independent processes: consider <span class="math-container">$N$</span> processes. These processes will concurrently execute a serie...
formal methods model checking markov chains
1
Modeling a set of probabilistic concurrent processes -- (formal methods model checking markov chains) <p>I'm looking into discrete-time Markov chains (DTMCs) for use in analyzing a probabilistic consensus protocol. One basic thing I haven't been able to figure out is how to model a set of independent processes: conside...
habedi/stack-exchange-dataset
116,020
What is a GPU year?
<p>I am reading papers in machine learning and they say things like, "This computation took <span class="math-container">$x$</span> number of GPU years".</p>&#xA;&#xA;<p>What is a GPU year? How long is that?</p>&#xA;
computer architecture operating systems cpu
1
What is a GPU year? -- (computer architecture operating systems cpu) <p>I am reading papers in machine learning and they say things like, "This computation took <span class="math-container">$x$</span> number of GPU years".</p>&#xA;&#xA;<p>What is a GPU year? How long is that?</p>&#xA;
habedi/stack-exchange-dataset
116,024
Turing Machine to return all prime numbers
<p>My task is to design Turing Machine that ignores its input and returns all the prime numbers. I have some basic idea how to do that but I am not completely sure whether my approach is correct or not.</p>&#xA;&#xA;<p>So no matter what the input is, we should ignore it. I think it would be sufficient to add another ta...
turing machines computability
1
Turing Machine to return all prime numbers -- (turing machines computability) <p>My task is to design Turing Machine that ignores its input and returns all the prime numbers. I have some basic idea how to do that but I am not completely sure whether my approach is correct or not.</p>&#xA;&#xA;<p>So no matter what the i...
habedi/stack-exchange-dataset
116,032
Optimal solution for Weighted points problem
<p>Problem:</p>&#xA;&#xA;<blockquote>&#xA; <p>Fix a constant <span class="math-container">$k$</span>. Given a set of <span class="math-container">$2d$</span>-dimensional points <span class="math-container">$N = \{N_1, N_2, N_3, \dots, N_n\}$</span>, each associated with an arbitrary weight, find a set of points <span ...
algorithms approximation greedy algorithms
1
Optimal solution for Weighted points problem -- (algorithms approximation greedy algorithms) <p>Problem:</p>&#xA;&#xA;<blockquote>&#xA; <p>Fix a constant <span class="math-container">$k$</span>. Given a set of <span class="math-container">$2d$</span>-dimensional points <span class="math-container">$N = \{N_1, N_2, N_3...
habedi/stack-exchange-dataset
116,050
Conditional lower bounds on the running time of the single source shortest path problem
<p>Just out of curiosity, I was wondering whether there is a conditional lower-bound on the running time of an algorithm for the Single Source Shortest Path Problem (on directed or undirected graphs). I found papers with lower-bounds on some special models of computing such as PRAM or distributed systems but I was wond...
graphs shortest path polynomial time lower bounds fine grained analysis
1
Conditional lower bounds on the running time of the single source shortest path problem -- (graphs shortest path polynomial time lower bounds fine grained analysis) <p>Just out of curiosity, I was wondering whether there is a conditional lower-bound on the running time of an algorithm for the Single Source Shortest Pat...
habedi/stack-exchange-dataset
116,051
Reducing the halting problem for a language with strings that include at least one 1
<p><span class="math-container">$L_1$</span> = A sequence of <span class="math-container">$0$</span> or <span class="math-container">$1$</span>'s such that at least one <span class="math-container">$1$</span> is in the sequence</p>&#xA;&#xA;<p><span class="math-container">$L_2$</span> = Turing machines that decide <spa...
turing machines undecidability
1
Reducing the halting problem for a language with strings that include at least one 1 -- (turing machines undecidability) <p><span class="math-container">$L_1$</span> = A sequence of <span class="math-container">$0$</span> or <span class="math-container">$1$</span>'s such that at least one <span class="math-container">$...
habedi/stack-exchange-dataset
116,058
Does topological sort exist for any complete directed acyclic graph?
<p>Let's assume that DAG is complete: there is directed edge among every to nodes. Does topological sort of vertices exist for any such graph? I.e. is it possible to make linear list of nodes in which the left node has edge into the right node. Maybe this is the question about existence of Hamiltonian path in every com...
graphs sorting dag hamiltonian path
1
Does topological sort exist for any complete directed acyclic graph? -- (graphs sorting dag hamiltonian path) <p>Let's assume that DAG is complete: there is directed edge among every to nodes. Does topological sort of vertices exist for any such graph? I.e. is it possible to make linear list of nodes in which the left ...
habedi/stack-exchange-dataset
116,064
How can I prove the minimum pumping length of finite language?
<blockquote>&#xA; <p>Let L be the set of all strings over {0, 1} whose lengths are at most three. Since L is regular, the pumping lemma holds for L, and thus there is a pumping length p associated with L. What is the smallest possible pumping length associated with L?</p>&#xA;</blockquote>&#xA;&#xA;<p>For this problem...
pumping lemma
1
How can I prove the minimum pumping length of finite language? -- (pumping lemma) <blockquote>&#xA; <p>Let L be the set of all strings over {0, 1} whose lengths are at most three. Since L is regular, the pumping lemma holds for L, and thus there is a pumping length p associated with L. What is the smallest possible pu...
habedi/stack-exchange-dataset
116,065
How to compute total number of subsequences of length k from a word of length N?
<p>A subsequence of a word is obtained by dropping some letters from it. The letters&#xA;that are dropped need not be consecutive. For instance, ba, bna and banaa are all&#xA;subsequences of the word banana.&#xA;We are interested in counting the number of distinct subsequences of a fixed length of&#xA;a given word. For...
dynamic programming combinatorics combinatory logic
1
How to compute total number of subsequences of length k from a word of length N? -- (dynamic programming combinatorics combinatory logic) <p>A subsequence of a word is obtained by dropping some letters from it. The letters&#xA;that are dropped need not be consecutive. For instance, ba, bna and banaa are all&#xA;subsequ...
habedi/stack-exchange-dataset
116,086
checking '<' for two binary numbers in a cnf-formula
<p>I want to check whether a arbitrary binary number is less or equal to another binary number in a cnf-formula. I can already construct a formula, which is not in cnf:</p>&#xA;&#xA;<p>Lets say n and m are two-digit binary numbers:</p>&#xA;&#xA;<p><span class="math-container">$n = n_2 + n_1$</span></p>&#xA;&#xA;<p><spa...
data structures logic satisfiability binary
1
checking '<' for two binary numbers in a cnf-formula -- (data structures logic satisfiability binary) <p>I want to check whether a arbitrary binary number is less or equal to another binary number in a cnf-formula. I can already construct a formula, which is not in cnf:</p>&#xA;&#xA;<p>Lets say n and m are two-digit bi...
habedi/stack-exchange-dataset
116,092
How complete directed graph with n-vertices is connected to the n-dimensional simplex and its triangulation?
<p>Answer <a href="https://stackoverflow.com/a/26151549/1375882">https://stackoverflow.com/a/26151549/1375882</a> suggests that Sperner's lemma can be used to prove the existence of index for the search Hamiltonian path in complete directed graph. But Sperner's lemma is about simplex, its triangulation and colouring. H...
graphs hamiltonian path
1
How complete directed graph with n-vertices is connected to the n-dimensional simplex and its triangulation? -- (graphs hamiltonian path) <p>Answer <a href="https://stackoverflow.com/a/26151549/1375882">https://stackoverflow.com/a/26151549/1375882</a> suggests that Sperner's lemma can be used to prove the existence of ...
habedi/stack-exchange-dataset
116,099
Multiple choice knapsack dynamic programming
<p>Giving a the following:</p>&#xA;&#xA;<p>A list of a store items <span class="math-container">$T=\{t_1, t_2,...,t_n\}$</span>.</p>&#xA;&#xA;<p>A list of prices of each item <span class="math-container">$P=\{p_1, p_2,...,p_n\}$</span>.</p>&#xA;&#xA;<p>A list of quantities of each item <span class="math-container">$Q=\...
algorithms algorithm analysis dynamic programming knapsack problems
1
Multiple choice knapsack dynamic programming -- (algorithms algorithm analysis dynamic programming knapsack problems) <p>Giving a the following:</p>&#xA;&#xA;<p>A list of a store items <span class="math-container">$T=\{t_1, t_2,...,t_n\}$</span>.</p>&#xA;&#xA;<p>A list of prices of each item <span class="math-container...
habedi/stack-exchange-dataset
116,102
Hitting Set Problem with non-minimal Greedy Algorithm
<p>The Hitting Set Problem is defined as having a universal set <span class="math-container">$\mathfrak{U}$</span>, and nonempty sets <span class="math-container">$S_i \subseteq \mathfrak{U}$</span> for <span class="math-container">$1 \leq i \leq n$</span>, and finding a set <span class="math-container">$\mathcal{H} \s...
graphs np hard sets greedy algorithms set cover
1
Hitting Set Problem with non-minimal Greedy Algorithm -- (graphs np hard sets greedy algorithms set cover) <p>The Hitting Set Problem is defined as having a universal set <span class="math-container">$\mathfrak{U}$</span>, and nonempty sets <span class="math-container">$S_i \subseteq \mathfrak{U}$</span> for <span clas...
habedi/stack-exchange-dataset
116,109
Efficiently compute the sum of edge weights product of all possible path in a DAG
<p>I thought of using Depth First Search (DFS) to find all possible paths in O(|V|+|E|). However, computing the product of all the edge weights for a path is O(2^N). Is there any way to compute this more efficiently?</p>&#xA;
graphs graph traversal
1
Efficiently compute the sum of edge weights product of all possible path in a DAG -- (graphs graph traversal) <p>I thought of using Depth First Search (DFS) to find all possible paths in O(|V|+|E|). However, computing the product of all the edge weights for a path is O(2^N). Is there any way to compute this more effici...
habedi/stack-exchange-dataset
116,115
Chinese room test vs Turing Test
<p>So, I took up a new course (AI) in my uni and came across these two test &#xA;<span class="math-container">$TURING$</span> <span class="math-container">$TEST$</span> and <span class="math-container">$CHINESE$</span> <span class="math-container">$ROOM$</span> <span class="math-container">$TEST$</span>. But I am not a...
artificial intelligence
1
Chinese room test vs Turing Test -- (artificial intelligence) <p>So, I took up a new course (AI) in my uni and came across these two test &#xA;<span class="math-container">$TURING$</span> <span class="math-container">$TEST$</span> and <span class="math-container">$CHINESE$</span> <span class="math-container">$ROOM$</sp...
habedi/stack-exchange-dataset
116,129
Diffie-Hellman and its disadvantage with large primes
<p>I was reading our university slide on the Diffie-Hellman where it is mentioned that one of the disadvantages of D-H is that <strong>For large prime, <span class="math-container">$p-1$</span> is an even number so, <span class="math-container">$\mathbb{Z}^*_p$</span> will have a subgroup of order 2</strong> </p>&#xA;&...
computer networks cryptography
1
Diffie-Hellman and its disadvantage with large primes -- (computer networks cryptography) <p>I was reading our university slide on the Diffie-Hellman where it is mentioned that one of the disadvantages of D-H is that <strong>For large prime, <span class="math-container">$p-1$</span> is an even number so, <span class="m...
habedi/stack-exchange-dataset
116,130
For arbitrary RR(1) grammar $G$, is there an equivalent LL(1) grammar $G'$?
<p>Failed to find similar term, here I coin the noun <strong>RR</strong>(Right-to-left, Rightmost derivation) as an opposite concept of LL.</p>&#xA;&#xA;<p>The question is inspired by an interesting example grammar <span class="math-container">$G$</span>:&#xA;<span class="math-container">$$S \rightarrow S S + | a$$</sp...
formal languages
1
For arbitrary RR(1) grammar $G$, is there an equivalent LL(1) grammar $G'$? -- (formal languages) <p>Failed to find similar term, here I coin the noun <strong>RR</strong>(Right-to-left, Rightmost derivation) as an opposite concept of LL.</p>&#xA;&#xA;<p>The question is inspired by an interesting example grammar <span c...
habedi/stack-exchange-dataset
116,136
Cryptography: Play Fair cipher
<p>In our university, we were taught that since all 26 letters cant be placed together in a <span class="math-container">$5*5$</span> square matrix we must put <span class="math-container">$i/j$</span> together like this represented in the below diagram. Here our key is <span class="math-container">$monarchy$</span>, n...
cryptography
1
Cryptography: Play Fair cipher -- (cryptography) <p>In our university, we were taught that since all 26 letters cant be placed together in a <span class="math-container">$5*5$</span> square matrix we must put <span class="math-container">$i/j$</span> together like this represented in the below diagram. Here our key is ...
habedi/stack-exchange-dataset
116,137
What are Surnames' dataset usages?
<p>I have found a <a href="https://github.com/SajjadPourali/Surnames" rel="nofollow noreferrer">dataset</a> which involves surnames dispersion around the world that sorted by population which I use it for a name recommender system.</p>&#xA;&#xA;<p>Its readme page caught my attention because it has mentioned that suitab...
machine learning security
1
What are Surnames' dataset usages? -- (machine learning security) <p>I have found a <a href="https://github.com/SajjadPourali/Surnames" rel="nofollow noreferrer">dataset</a> which involves surnames dispersion around the world that sorted by population which I use it for a name recommender system.</p>&#xA;&#xA;<p>Its re...
habedi/stack-exchange-dataset
116,139
If current time in milliseconds is considered good enough random seed for a pseudorandom number generator, why not just use that time directly?
<p>I was reading about <a href="https://en.wikipedia.org/wiki/Pseudorandom_number_generator" rel="nofollow noreferrer">pseudorandom number generators</a> and how they need a seed and how that seed is usually current system time in milliseconds. One of the most common algorithms is the <a href="https://en.wikipedia.org/...
cryptography randomness pseudo random generators real time
1
If current time in milliseconds is considered good enough random seed for a pseudorandom number generator, why not just use that time directly? -- (cryptography randomness pseudo random generators real time) <p>I was reading about <a href="https://en.wikipedia.org/wiki/Pseudorandom_number_generator" rel="nofollow noref...
habedi/stack-exchange-dataset
116,148
Significance of quantifier ordering in quantified boolean formulas (kQBF vs. QBF)
<p>I am studying solvers of quantified boolean formulas (QBF) as a generalization of SAT solving. The standard DIMACS format of SAT specification is extended to QDIMACS, which adds "a ..." and "e&#xA;..." lines denoting which variables are to be existentially quantified and which variables are to be universally quantif...
satisfiability boolean algebra propositional logic
1
Significance of quantifier ordering in quantified boolean formulas (kQBF vs. QBF) -- (satisfiability boolean algebra propositional logic) <p>I am studying solvers of quantified boolean formulas (QBF) as a generalization of SAT solving. The standard DIMACS format of SAT specification is extended to QDIMACS, which adds "...
habedi/stack-exchange-dataset
116,156
How is $\text{PCP}[O(\log n),O(1)]$ NOT P?
<p>As a prover, we just try to convince the verifier that it's correct, no matter whether it is or not. So we can just analyze every possible route.</p>&#xA;&#xA;<p>For <span class="math-container">$\text{PCP}[O(\log n),O(1)]$</span>, won't there just be polynomial many possible routes, and checking all just cost polyn...
complexity theory p vs np
1
How is $\text{PCP}[O(\log n),O(1)]$ NOT P? -- (complexity theory p vs np) <p>As a prover, we just try to convince the verifier that it's correct, no matter whether it is or not. So we can just analyze every possible route.</p>&#xA;&#xA;<p>For <span class="math-container">$\text{PCP}[O(\log n),O(1)]$</span>, won't there...
habedi/stack-exchange-dataset
116,164
How to show all false outputs in a circuit?
<p>I have 3 input variables and the output for all 8 possible combinations is 0 (false). When making a circuit, how would I show this using gates or no gates at all? Thanks!</p>&#xA;
logic discrete mathematics circuits
1
How to show all false outputs in a circuit? -- (logic discrete mathematics circuits) <p>I have 3 input variables and the output for all 8 possible combinations is 0 (false). When making a circuit, how would I show this using gates or no gates at all? Thanks!</p>&#xA;
habedi/stack-exchange-dataset
116,177
How to solve the minimum-cost flow problem on a complete graph, with a concave cost function of flow for each edge?
<p>Here is the problem:</p>&#xA;&#xA;<p>Input:</p>&#xA;&#xA;<ul>&#xA;<li><p>A series of source/sink nodes at fixed positions with given outwards/inwards flow </p></li>&#xA;<li><p>Edges are NOT specified. The edges can connect any nodes.</p></li>&#xA;<li><p>The total source and sink flow match</p></li>&#xA;<li><p>A con...
graphs optimization network flow network topology topology
1
How to solve the minimum-cost flow problem on a complete graph, with a concave cost function of flow for each edge? -- (graphs optimization network flow network topology topology) <p>Here is the problem:</p>&#xA;&#xA;<p>Input:</p>&#xA;&#xA;<ul>&#xA;<li><p>A series of source/sink nodes at fixed positions with given outw...
habedi/stack-exchange-dataset