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
99,790
Outputting numbers within a range that are not in a list
<p>How could you design an efficient algorithm that uses the least amount of memory space and outputs, in ascending order, the list of integers in the range 0..255 that are not in a randomly generated list of 100 integers?</p>&#xA;&#xA;<p>The aim is to output the number of such integers, and determine if the randomly g...
algorithms
1
Outputting numbers within a range that are not in a list -- (algorithms) <p>How could you design an efficient algorithm that uses the least amount of memory space and outputs, in ascending order, the list of integers in the range 0..255 that are not in a randomly generated list of 100 integers?</p>&#xA;&#xA;<p>The aim ...
habedi/stack-exchange-dataset
99,795
Design an algorithm for efficiently computing the k smallest numbers of the form a+b*sqrt(2)
<p>Full question: Numbers of the form <span class="math-container">$a+b\sqrt{q}$</span>, where <span class="math-container">$a$</span> and <span class="math-container">$b$</span> are nonnegative integers, and <span class="math-container">$q$</span> is an integer which is not he square of another integer, have special p...
algorithms discrete mathematics
1
Design an algorithm for efficiently computing the k smallest numbers of the form a+b*sqrt(2) -- (algorithms discrete mathematics) <p>Full question: Numbers of the form <span class="math-container">$a+b\sqrt{q}$</span>, where <span class="math-container">$a$</span> and <span class="math-container">$b$</span> are nonnega...
habedi/stack-exchange-dataset
99,804
Quick Sort with first element as pivot
<p>I'm studying Quick-Sort and I am confused as to how it works when the first element is chosen as the pivot point.</p>&#xA;&#xA;<p>I am trying to trace the first step in the Quick-Sort algorithm, to move the pivot S[1] (17) into its appropriate position. </p>&#xA;&#xA;<p>Example: [17, -10, 7, 19, 21, 23, -13, 31, 59]...
algorithms sorting quicksort
1
Quick Sort with first element as pivot -- (algorithms sorting quicksort) <p>I'm studying Quick-Sort and I am confused as to how it works when the first element is chosen as the pivot point.</p>&#xA;&#xA;<p>I am trying to trace the first step in the Quick-Sort algorithm, to move the pivot S[1] (17) into its appropriate ...
habedi/stack-exchange-dataset
99,806
How can a computer run an infinite loop?
<p>I understand the concept behind for and do/while loops, but I am trying to understand what is happening at the hardware level that allows a loop to run infinitely. Technically wouldn't it have to stop at some point because there are only a couple billion transistors in a microprocessor? Maybe my logic is off.</p>&#x...
loops
1
How can a computer run an infinite loop? -- (loops) <p>I understand the concept behind for and do/while loops, but I am trying to understand what is happening at the hardware level that allows a loop to run infinitely. Technically wouldn't it have to stop at some point because there are only a couple billion transistor...
habedi/stack-exchange-dataset
99,817
Algorithms for elementary operations using other elementary operators
<p>The question asks to provide an algorithm to compute </p>&#xA;&#xA;<p><span class="math-container">$(i)$</span> The product of <span class="math-container">$n$</span>-bit numbers using&#xA;reciprocation operation and addition operation but not using multiplication&#xA;and squaring.</p>&#xA;&#xA;<p><span class="math-...
algorithms complexity theory arithmetic
1
Algorithms for elementary operations using other elementary operators -- (algorithms complexity theory arithmetic) <p>The question asks to provide an algorithm to compute </p>&#xA;&#xA;<p><span class="math-container">$(i)$</span> The product of <span class="math-container">$n$</span>-bit numbers using&#xA;reciprocation...
habedi/stack-exchange-dataset
99,830
Making a profit as a high-dimensional store owner?
<p>Been thinking about a problem recently and I am wondering if anyone can comment on some ideas to make solutions to this problem more efficient.</p>&#xA;&#xA;<hr>&#xA;&#xA;<p>Let's say that I am some business owner with a set of <span class="math-container">$n$</span> possible store locations <span class="math-contai...
algorithms graphs computational geometry dynamic programming clique
1
Making a profit as a high-dimensional store owner? -- (algorithms graphs computational geometry dynamic programming clique) <p>Been thinking about a problem recently and I am wondering if anyone can comment on some ideas to make solutions to this problem more efficient.</p>&#xA;&#xA;<hr>&#xA;&#xA;<p>Let's say that I am...
habedi/stack-exchange-dataset
99,837
Why is dominating set in $W[2]$, but independent set in $W[1]$
<p>In <a href="https://en.wikipedia.org/wiki/Parameterized_complexity" rel="nofollow noreferrer">Parameterized Complexity</a> the <a href="https://en.wikipedia.org/wiki/Independent_set_(graph_theory)" rel="nofollow noreferrer">Independent Set Problem</a> for a Parameter <span class="math-container">$k$</span> ist <span...
complexity theory graphs parameterized complexity
1
Why is dominating set in $W[2]$, but independent set in $W[1]$ -- (complexity theory graphs parameterized complexity) <p>In <a href="https://en.wikipedia.org/wiki/Parameterized_complexity" rel="nofollow noreferrer">Parameterized Complexity</a> the <a href="https://en.wikipedia.org/wiki/Independent_set_(graph_theory)" r...
habedi/stack-exchange-dataset
99,840
2SAT Problem using Implication Graph
<p>I was doing a practice question. As you can see below there is an Implication graph. To check whether the problem is satisfiable, I checked whether there were any 'bad loops'. To do so, for each literal/variable in the boolean formula, I see if there is a path from X --->-X and from -X---->X if both exist then a 'ba...
complexity theory np satisfiability 3 sat 2 sat
1
2SAT Problem using Implication Graph -- (complexity theory np satisfiability 3 sat 2 sat) <p>I was doing a practice question. As you can see below there is an Implication graph. To check whether the problem is satisfiable, I checked whether there were any 'bad loops'. To do so, for each literal/variable in the boolean ...
habedi/stack-exchange-dataset
99,842
Regular expression for $\{x : \#_{01}(x) \mod 3 = 0\}$
<p>Let <span class="math-container">$L_1$</span> be the language over alphabet <span class="math-container">$\{0, 1\}$</span> defined by <span class="math-container">$L_1 = \{x : \#_{01}(x) \mod 3 = 0\}$</span>.</p>&#xA;<p>Give a regular expression that denotes <span class="math-container">$L_1$</span>, and justify its...
regular expressions
1
Regular expression for $\{x : \#_{01}(x) \mod 3 = 0\}$ -- (regular expressions) <p>Let <span class="math-container">$L_1$</span> be the language over alphabet <span class="math-container">$\{0, 1\}$</span> defined by <span class="math-container">$L_1 = \{x : \#_{01}(x) \mod 3 = 0\}$</span>.</p>&#xA;<p>Give a regular ex...
habedi/stack-exchange-dataset
99,847
Give a DFSA that accepts $L_1 = \{x : \#_{01}(x) \mod 3 = 0\}$ using as few states as possible
<p>Let <span class="math-container">$L_1$</span> be the language over alphabet <span class="math-container">$\{0, 1\}$</span> defined by <span class="math-container">$L_1 = \{x : \#_{01}(x) \mod 3 = 0\}$</span>.</p>&#xA;&#xA;<p>Using as few states as possible, give a DFSA that accepts <span class="math-container">$L_1$...
automata
1
Give a DFSA that accepts $L_1 = \{x : \#_{01}(x) \mod 3 = 0\}$ using as few states as possible -- (automata) <p>Let <span class="math-container">$L_1$</span> be the language over alphabet <span class="math-container">$\{0, 1\}$</span> defined by <span class="math-container">$L_1 = \{x : \#_{01}(x) \mod 3 = 0\}$</span>....
habedi/stack-exchange-dataset
99,849
What's the difference between environment and memory in terms of programming languages?
<p>I've been reading up on programming languages to better my understanding with the textbook <em>Essentials of Programming Languages (3e) - Friedman &amp; Wand</em>.</p>&#xA;&#xA;<p><br></p>&#xA;&#xA;<p>In a chapter regarding the states of languages (i.e. when we account for the effects that a computation may have rat...
programming languages
1
What's the difference between environment and memory in terms of programming languages? -- (programming languages) <p>I've been reading up on programming languages to better my understanding with the textbook <em>Essentials of Programming Languages (3e) - Friedman &amp; Wand</em>.</p>&#xA;&#xA;<p><br></p>&#xA;&#xA;<p>I...
habedi/stack-exchange-dataset
99,858
A,B decidable: proof that A\B is decidable too
<p>For an assignment I have to proof that for two given decidable languages A,B, A\B is decidable too.</p>&#xA;&#xA;<p>My idea is as follows:&#xA;If B is empty or doesnt have elements in common with A, then A\B is decidable because A\B=A.</p>&#xA;&#xA;<p>If B is not empty and intersects with A, A\B is just a smaller su...
formal languages turing machines undecidability
1
A,B decidable: proof that A\B is decidable too -- (formal languages turing machines undecidability) <p>For an assignment I have to proof that for two given decidable languages A,B, A\B is decidable too.</p>&#xA;&#xA;<p>My idea is as follows:&#xA;If B is empty or doesnt have elements in common with A, then A\B is decida...
habedi/stack-exchange-dataset
99,862
Checking if the graph provided by a distance matrix is a tree
<p>I came across this problem in an online judge: We are given a distance matrix consisting of <span class="math-container">$N$</span> rows and columns. The <span class="math-container">$i$</span>th line of <span class="math-container">$j$</span>th row is the distance between node <span class="math-container">$i$</span...
algorithms graphs trees
1
Checking if the graph provided by a distance matrix is a tree -- (algorithms graphs trees) <p>I came across this problem in an online judge: We are given a distance matrix consisting of <span class="math-container">$N$</span> rows and columns. The <span class="math-container">$i$</span>th line of <span class="math-cont...
habedi/stack-exchange-dataset
99,865
How to add decimals to formal grammar?
<p>I have a formal language that describes digit production like</p>&#xA;&#xA;<pre><code>&lt;digit&gt; ::= 0|1|2|...|9&#xA;</code></pre>&#xA;&#xA;<p>and I need to intruduce fraction to write decimals like <code>3.14</code> and so on</p>&#xA;&#xA;<p>What did I do:</p>&#xA;&#xA;<pre><code>&lt;frac&gt; ::= &lt;digit&gt;&l...
formal languages formal grammars
1
How to add decimals to formal grammar? -- (formal languages formal grammars) <p>I have a formal language that describes digit production like</p>&#xA;&#xA;<pre><code>&lt;digit&gt; ::= 0|1|2|...|9&#xA;</code></pre>&#xA;&#xA;<p>and I need to intruduce fraction to write decimals like <code>3.14</code> and so on</p>&#xA;&#...
habedi/stack-exchange-dataset
99,866
Primitive recursive plus Ackermann
<p>Let us consider the class <span class="math-container">$\cal F$</span> of functions that contains</p>&#xA;&#xA;<ul>&#xA;<li>all constant functions</li>&#xA;<li>all projections</li>&#xA;<li>the successor function</li>&#xA;<li>the Ackermann function</li>&#xA;</ul>&#xA;&#xA;<p>as basic functions, and that is closed und...
computability computation models primitive recursion
1
Primitive recursive plus Ackermann -- (computability computation models primitive recursion) <p>Let us consider the class <span class="math-container">$\cal F$</span> of functions that contains</p>&#xA;&#xA;<ul>&#xA;<li>all constant functions</li>&#xA;<li>all projections</li>&#xA;<li>the successor function</li>&#xA;<li...
habedi/stack-exchange-dataset
99,870
Is the language of all TMs accepting all strings starting with 010 decidable?
<p>I am trying to figure out if this language is decidable: &#xA;<span class="math-container">$$ \{ \langle M \rangle \mid \text{$M$ accepts all strings starting with 010}\}. $$</span></p>&#xA;&#xA;<p>My intuition is that it is. Whatever string <span class="math-container">$w$</span> starts with 010 it accepts, and if ...
turing machines computability undecidability
1
Is the language of all TMs accepting all strings starting with 010 decidable? -- (turing machines computability undecidability) <p>I am trying to figure out if this language is decidable: &#xA;<span class="math-container">$$ \{ \langle M \rangle \mid \text{$M$ accepts all strings starting with 010}\}. $$</span></p>&#xA...
habedi/stack-exchange-dataset
99,881
Prove or disprove L is regular
<p>There is question in one of my exercise but I couldn't prove or disprove anything about it.<br>&#xA;This is language <span class="math-container">$L$</span> which is introduced with grammar:<br>&#xA;<span class="math-container">$$S \to 0S1 | 1S0 | AA$$</span>&#xA;<span class="math-container">$$A \to 0A | \lambda|A1$...
regular languages regular expressions pumping lemma
1
Prove or disprove L is regular -- (regular languages regular expressions pumping lemma) <p>There is question in one of my exercise but I couldn't prove or disprove anything about it.<br>&#xA;This is language <span class="math-container">$L$</span> which is introduced with grammar:<br>&#xA;<span class="math-container">$...
habedi/stack-exchange-dataset
99,896
$L_n = \{x \in \Sigma^{*} | \exists w, y, z \in \Sigma^*, x = ywz, w^r = w, |w| = n \}$ Informally x is palindrome of length n. Find regex for n = 1
<p><span class="math-container">$L_n = \{x \in \Sigma^{*} | \exists w, y, z \in \Sigma^*, x = ywz, w^R = w, |w| = n \}$</span></p>&#xA;&#xA;<p>Informally x is palindrome of length n </p>&#xA;&#xA;<p>where <span class="math-container">$\Sigma = \{0,1\}$</span></p>&#xA;&#xA;<hr>&#xA;&#xA;<p>I'm having a hard time underst...
regular expressions
1
$L_n = \{x \in \Sigma^{*} | \exists w, y, z \in \Sigma^*, x = ywz, w^r = w, |w| = n \}$ Informally x is palindrome of length n. Find regex for n = 1 -- (regular expressions) <p><span class="math-container">$L_n = \{x \in \Sigma^{*} | \exists w, y, z \in \Sigma^*, x = ywz, w^R = w, |w| = n \}$</span></p>&#xA;&#xA;<p>Inf...
habedi/stack-exchange-dataset
99,897
How do you correctly write this sentence as a CTL formula?
<p>Sentence: From every reachable state it is possible to reach a state where <span class="math-container">$p$</span> is true.</p>&#xA;&#xA;<p>How do you write this sentence as a CTL formula? So far I only dealt with CTL syntax and trees but maybe it will also be asked in a test how you convert a sentence to a CTL form...
logic model checking temporal logic computation tree logic
1
How do you correctly write this sentence as a CTL formula? -- (logic model checking temporal logic computation tree logic) <p>Sentence: From every reachable state it is possible to reach a state where <span class="math-container">$p$</span> is true.</p>&#xA;&#xA;<p>How do you write this sentence as a CTL formula? So fa...
habedi/stack-exchange-dataset
99,902
Minimum cost node cut
<p>I am interested in solving the following problem:</p>&#xA;&#xA;<blockquote>&#xA; <p>Given an undirected graph whose vertices are weighted, find a subset of vertices of minimal weight whose removal disconnects the graph.</p>&#xA;</blockquote>&#xA;&#xA;<p>Is there any known algorithm solving this problem?</p>&#xA;&#x...
graphs python ford fulkerson
1
Minimum cost node cut -- (graphs python ford fulkerson) <p>I am interested in solving the following problem:</p>&#xA;&#xA;<blockquote>&#xA; <p>Given an undirected graph whose vertices are weighted, find a subset of vertices of minimal weight whose removal disconnects the graph.</p>&#xA;</blockquote>&#xA;&#xA;<p>Is the...
habedi/stack-exchange-dataset
99,910
Why is reflexivity enough in this HoTT formulation of quotient types?
<p>In <a href="https://gist.github.com/gergoerdi/4ff359b58657d816d5876b8b15c6640a" rel="noreferrer">this formulation of quotient types in cubical type theory</a> I was able to implement an eliminator and use that to implement basically curried function application. However, in all this, the only requirement on the fact...
homotopy type theory
1
Why is reflexivity enough in this HoTT formulation of quotient types? -- (homotopy type theory) <p>In <a href="https://gist.github.com/gergoerdi/4ff359b58657d816d5876b8b15c6640a" rel="noreferrer">this formulation of quotient types in cubical type theory</a> I was able to implement an eliminator and use that to implemen...
habedi/stack-exchange-dataset
99,923
Searching in a Binary Search Tree
<p>I'm studying Binary Search Trees (BST) and I would like to verify that my understanding of BSTs is correct.</p>&#xA;&#xA;<p>For example, let S = [17, -10, 7, 19, 21, 23, -13, 31, 59].</p>&#xA;&#xA;<p>Binary Search Tree for S, with S<a href="https://i.stack.imgur.com/P00hI.png" rel="nofollow noreferrer">1</a> as root...
binary trees binary search trees binary search
1
Searching in a Binary Search Tree -- (binary trees binary search trees binary search) <p>I'm studying Binary Search Trees (BST) and I would like to verify that my understanding of BSTs is correct.</p>&#xA;&#xA;<p>For example, let S = [17, -10, 7, 19, 21, 23, -13, 31, 59].</p>&#xA;&#xA;<p>Binary Search Tree for S, with ...
habedi/stack-exchange-dataset
99,927
Concave Polygon Intersection - Algorithm
<p>I'm trying to develop an Algorithm for Polygon Intersection. Where each polygon is an array of Points, where each Point has X and Y properties. <br><br>&#xA;Algorithm limitations:<br>&#xA;- Algorithm input: 2 Polygons.<br>&#xA;- Algorithm output: Intersection Polygon.<br>&#xA;- Polygons may be convex or concave (ang...
computational geometry
1
Concave Polygon Intersection - Algorithm -- (computational geometry) <p>I'm trying to develop an Algorithm for Polygon Intersection. Where each polygon is an array of Points, where each Point has X and Y properties. <br><br>&#xA;Algorithm limitations:<br>&#xA;- Algorithm input: 2 Polygons.<br>&#xA;- Algorithm output: I...
habedi/stack-exchange-dataset
99,938
Prove hash family is 3-wise independent
<p>Let <span class="math-container">$q$</span> be a prime number and let <span class="math-container">$\mathbb{Z}_q = \left\{1,\dots,q-1\right\}$</span>; I need to prove that the family <span class="math-container">$\mathcal{H} = \left\{h_s \colon \mathbb{Z}_q \rightarrow \mathbb{Z}_q\right\}_{s \in \mathbb{Z}_q^3}$</s...
cryptography hashing
1
Prove hash family is 3-wise independent -- (cryptography hashing) <p>Let <span class="math-container">$q$</span> be a prime number and let <span class="math-container">$\mathbb{Z}_q = \left\{1,\dots,q-1\right\}$</span>; I need to prove that the family <span class="math-container">$\mathcal{H} = \left\{h_s \colon \mathb...
habedi/stack-exchange-dataset
99,947
context free grammar for palindrome: $L_n = \{x \in \Sigma^* | x = ywz, w^R = w, |w| \geq n, |y| = |z| \}$
<p>Let <span class="math-container">$L_{n} = \{x \in \Sigma^* | x = ywz, w^R = w, |w| \geq n, |y| = |z| \}$</span></p>&#xA;&#xA;<p>Generate a cfg of <span class="math-container">$L_n$</span></p>&#xA;&#xA;<p>For n = 1, 2, 3</p>&#xA;&#xA;<hr>&#xA;&#xA;<p>Informally, x is in <span class="math-container">$L_n$</span> means...
formal languages context free formal grammars
1
context free grammar for palindrome: $L_n = \{x \in \Sigma^* | x = ywz, w^R = w, |w| \geq n, |y| = |z| \}$ -- (formal languages context free formal grammars) <p>Let <span class="math-container">$L_{n} = \{x \in \Sigma^* | x = ywz, w^R = w, |w| \geq n, |y| = |z| \}$</span></p>&#xA;&#xA;<p>Generate a cfg of <span class="...
habedi/stack-exchange-dataset
99,972
Algorithm to find non-overlapping intervals that minimize standard deviation
<p>I am looking for the name of an algorithm category, or even specific algorithms, that solve the following problem.</p>&#xA;&#xA;<p>I have noisy data. For simplicity, let this data be represented by numbers. I have the full data set in RAM. In this noisy data, I want to find signal. Signal is an interval of conti...
algorithms
1
Algorithm to find non-overlapping intervals that minimize standard deviation -- (algorithms) <p>I am looking for the name of an algorithm category, or even specific algorithms, that solve the following problem.</p>&#xA;&#xA;<p>I have noisy data. For simplicity, let this data be represented by numbers. I have the full...
habedi/stack-exchange-dataset
99,973
How to check if a given point is inside a polygon with holes?
<p>How to check if a given point lies inside or outside a polygon with holes?</p>&#xA;&#xA;<p>Does the below algorithm works for polygon with holes?</p>&#xA;&#xA;<p><a href="https://www.geeksforgeeks.org/how-to-check-if-a-given-point-lies-inside-a-polygon/" rel="nofollow noreferrer">https://www.geeksforgeeks.org/how-to...
algorithms computational geometry
1
How to check if a given point is inside a polygon with holes? -- (algorithms computational geometry) <p>How to check if a given point lies inside or outside a polygon with holes?</p>&#xA;&#xA;<p>Does the below algorithm works for polygon with holes?</p>&#xA;&#xA;<p><a href="https://www.geeksforgeeks.org/how-to-check-if...
habedi/stack-exchange-dataset
99,974
Lempel-Zilv-Welch Algorithm Decoding Question
<p>Hello i am studying about LZW algorithm by watching this video:&#xA;<a href="https://www.youtube.com/watch?v=j2HSd3HCpDs&amp;t=481s" rel="nofollow noreferrer">https://www.youtube.com/watch?v=j2HSd3HCpDs&amp;t=481s</a></p>&#xA;&#xA;<p>I couldnt fully understand decoding process.&#xA;At current 258,how does 116 come a...
algorithms lempel ziv
1
Lempel-Zilv-Welch Algorithm Decoding Question -- (algorithms lempel ziv) <p>Hello i am studying about LZW algorithm by watching this video:&#xA;<a href="https://www.youtube.com/watch?v=j2HSd3HCpDs&amp;t=481s" rel="nofollow noreferrer">https://www.youtube.com/watch?v=j2HSd3HCpDs&amp;t=481s</a></p>&#xA;&#xA;<p>I couldnt ...
habedi/stack-exchange-dataset
99,976
Meta Programming Operators
<p>I have a basic understanding how operators work (bitwise, logical, unary, ternary, etc.), but I am confused how you define what the operator does so the machine knows how to treat the operator when you use it in your code base. Are operators predefined by the compiler and is there a way for me to access the source c...
programming languages
1
Meta Programming Operators -- (programming languages) <p>I have a basic understanding how operators work (bitwise, logical, unary, ternary, etc.), but I am confused how you define what the operator does so the machine knows how to treat the operator when you use it in your code base. Are operators predefined by the com...
habedi/stack-exchange-dataset
99,978
Alternative formulation of complexity class $BPP$
<p>In Aurora and Barak, they give the following alternative definition of <span class="math-container">$BPP$</span>:</p>&#xA;&#xA;<p><a href="https://i.stack.imgur.com/0ePOR.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/0ePOR.png" alt="enter image description here"></a></p>&#xA;&#xA;<p>What is the ...
complexity theory complexity classes
1
Alternative formulation of complexity class $BPP$ -- (complexity theory complexity classes) <p>In Aurora and Barak, they give the following alternative definition of <span class="math-container">$BPP$</span>:</p>&#xA;&#xA;<p><a href="https://i.stack.imgur.com/0ePOR.png" rel="nofollow noreferrer"><img src="https://i.sta...
habedi/stack-exchange-dataset
99,995
PDA of the language where the number of a's are NOT equal to the number of b's
<p>I have this NPDA for language <code>L = {w: num_a(w) == num_b(w)}</code> <br />&#xA;all loops in q1&#xA;<code>&#xA;a, <span class="math-container">$ -&gt; 0$</span> b, <span class="math-container">$ -&gt; 1$</span>&#xA;a, 0 -&gt; 00 b, 1 -&gt; 11&#xA;a, 1 -&gt; \lambda b, 0 -&gt; \lambda&#xA;</code> &#x...
regular languages context free pushdown automata nondeterminism
1
PDA of the language where the number of a's are NOT equal to the number of b's -- (regular languages context free pushdown automata nondeterminism) <p>I have this NPDA for language <code>L = {w: num_a(w) == num_b(w)}</code> <br />&#xA;all loops in q1&#xA;<code>&#xA;a, <span class="math-container">$ -&gt; 0$</span> ...
habedi/stack-exchange-dataset
99,997
Why is this pushdown automaton for some palindromes right?
<p><span class="math-container">$B = \{w \in \{0,1\}^* | w^R = w, w \text{ length is odd} \}$</span></p>&#xA;&#xA;<p>Solution:</p>&#xA;&#xA;<p><a href="https://i.stack.imgur.com/ZryYo.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ZryYo.png" alt="enter image description here"></a></p>&#xA;&#xA;<p>Fo...
automata pushdown automata correctness proof
1
Why is this pushdown automaton for some palindromes right? -- (automata pushdown automata correctness proof) <p><span class="math-container">$B = \{w \in \{0,1\}^* | w^R = w, w \text{ length is odd} \}$</span></p>&#xA;&#xA;<p>Solution:</p>&#xA;&#xA;<p><a href="https://i.stack.imgur.com/ZryYo.png" rel="nofollow noreferr...
habedi/stack-exchange-dataset
99,999
Finding loop invariant of Lowest common multiple function
<p>So I have the following function:</p>&#xA;&#xA;<pre><code>def lcm(a,b):&#xA; x = a&#xA; y = b&#xA; while x != y:&#xA; if x &lt; y:&#xA; x += a&#xA; else:&#xA; y += b&#xA; return x&#xA;</code></pre>&#xA;&#xA;<p>I'm not sure how I will go about finding the loop invariant ...
algorithm analysis runtime analysis correctness proof
1
Finding loop invariant of Lowest common multiple function -- (algorithm analysis runtime analysis correctness proof) <p>So I have the following function:</p>&#xA;&#xA;<pre><code>def lcm(a,b):&#xA; x = a&#xA; y = b&#xA; while x != y:&#xA; if x &lt; y:&#xA; x += a&#xA; else:&#xA; ...
habedi/stack-exchange-dataset
100,011
Strings which are not in a language generated by a Grammar
<p>I have the following question and its solution &#xA;<a href="https://i.stack.imgur.com/2g2Sb.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/2g2Sb.png" alt="enter image description here"></a></p>&#xA;&#xA;<p><strong><em>Here T -> XTX&#xA;since T -> X and X->b&#xA; S ->XbX&#xA;since X->a&#xA;...
formal languages context free
1
Strings which are not in a language generated by a Grammar -- (formal languages context free) <p>I have the following question and its solution &#xA;<a href="https://i.stack.imgur.com/2g2Sb.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/2g2Sb.png" alt="enter image description here"></a></p>&#xA;&#xA...
habedi/stack-exchange-dataset
100,023
minimum number of nodes that traverse all the graph
<p>In the following graph, we can traverse entire graph if we select the nodes 0 and 2. I am looking for an efficient algorithm which returns this two nodes. Note that this is neither vertex-cover problem nor dominating-set problem since we don't need to select node 3. We say that, if we select node 0, we can go to nod...
graphs algorithm analysis data structures runtime analysis
1
minimum number of nodes that traverse all the graph -- (graphs algorithm analysis data structures runtime analysis) <p>In the following graph, we can traverse entire graph if we select the nodes 0 and 2. I am looking for an efficient algorithm which returns this two nodes. Note that this is neither vertex-cover problem...
habedi/stack-exchange-dataset
100,026
"Ways to make change for a dollar": How to optimize with constraints
<p>I'm working on an algorithm that takes a number of unit coins ([1, 2, 5, 10] for example) and a certain amount of money (13 in this case), and figures out how many ways there are to provide change for it. In the case of this testset the solution is 16.</p>&#xA;&#xA;<pre><code>1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1&#x...
algorithms efficiency coin change
1
"Ways to make change for a dollar": How to optimize with constraints -- (algorithms efficiency coin change) <p>I'm working on an algorithm that takes a number of unit coins ([1, 2, 5, 10] for example) and a certain amount of money (13 in this case), and figures out how many ways there are to provide change for it. In t...
habedi/stack-exchange-dataset
100,029
What is the relation between the quantity of information of $A_i$ and $A$, where $A=\bigcup_iA_i$?
<p>Let <span class="math-container">$A$</span> be an event divided into 4 events <span class="math-container">$A_i$</span> with the same probability. Why does the quantity of information of <span class="math-container">$A_i$</span> satisfy&#xA;<span class="math-container">$$ I(A_i) = I(A) + \log (4)?$$</span></p>&#xA;
probability theory information theory mathematical foundations
1
What is the relation between the quantity of information of $A_i$ and $A$, where $A=\bigcup_iA_i$? -- (probability theory information theory mathematical foundations) <p>Let <span class="math-container">$A$</span> be an event divided into 4 events <span class="math-container">$A_i$</span> with the same probability. Why...
habedi/stack-exchange-dataset
100,030
Understanding Hamiltonian Path, NP vs Co-NP
<p>I am having difficulty understanding the distinction between NP and Co-NP.</p>&#xA;&#xA;<p>According to my textbook (Sipser), the HAMPATH problem is in NP. That is, for the language: <br/><em>HAMPATH = { (G,s,t) | G is a directed graph with a Hamiltonian path from s to t}</em>, there exists a nondeterministic Turing...
np nondeterminism co np
1
Understanding Hamiltonian Path, NP vs Co-NP -- (np nondeterminism co np) <p>I am having difficulty understanding the distinction between NP and Co-NP.</p>&#xA;&#xA;<p>According to my textbook (Sipser), the HAMPATH problem is in NP. That is, for the language: <br/><em>HAMPATH = { (G,s,t) | G is a directed graph with a H...
habedi/stack-exchange-dataset
100,033
Christofides algorithm (by hand)
<p>I am following this algorithm example: <a href="https://en.wikipedia.org/wiki/Christofides_algorithm#example" rel="nofollow noreferrer">https://en.wikipedia.org/wiki/Christofides_algorithm#example</a></p>&#xA;&#xA;<pre><code>The graph:&#xA;</code></pre>&#xA;&#xA;<p>[![enter image description here][1]][1]</p>&#xA;&#x...
algorithms graphs approximation traveling salesman
1
Christofides algorithm (by hand) -- (algorithms graphs approximation traveling salesman) <p>I am following this algorithm example: <a href="https://en.wikipedia.org/wiki/Christofides_algorithm#example" rel="nofollow noreferrer">https://en.wikipedia.org/wiki/Christofides_algorithm#example</a></p>&#xA;&#xA;<pre><code>The...
habedi/stack-exchange-dataset
100,046
Variance of MAXSAT clause satisfiability
<p>For a given MAXSAT problem, it is trivially easy to compute the mean number of clauses satisfied for all assignments, or equivalently the expected number of clauses satisfied by a random assignment.</p>&#xA;&#xA;<p>Is it likewise possible to compute the variance of the number of clauses satisfied? And I mean an exac...
satisfiability probability theory
1
Variance of MAXSAT clause satisfiability -- (satisfiability probability theory) <p>For a given MAXSAT problem, it is trivially easy to compute the mean number of clauses satisfied for all assignments, or equivalently the expected number of clauses satisfied by a random assignment.</p>&#xA;&#xA;<p>Is it likewise possibl...
habedi/stack-exchange-dataset
100,047
Reusing variable in converting grammar to Chomsky Normal Form
<p>I'm not sure if reusing variable is allowed in CNF.&#xA;<br>&#xA;<br>&#xA;For example, I have this grammar not in CNF. So I have to convert it to CNF.&#xA;<code>&#xA;1. S-&gt;abAB|abB|abA|ab&#xA;2. A-&gt;bAa|ba&#xA;3. B-&gt;BAa|bAa|ba|Ba|Aa|a&#xA;</code>&#xA;<BR>&#xA;For conversion, I'm using a convention where new ...
formal languages context free formal grammars normal forms
1
Reusing variable in converting grammar to Chomsky Normal Form -- (formal languages context free formal grammars normal forms) <p>I'm not sure if reusing variable is allowed in CNF.&#xA;<br>&#xA;<br>&#xA;For example, I have this grammar not in CNF. So I have to convert it to CNF.&#xA;<code>&#xA;1. S-&gt;abAB|abB|abA|ab&...
habedi/stack-exchange-dataset
100,048
What's the connection between the two "Fast Walsh Transform"?
<p>First Let's take a look at the convolution <span class="math-container">$\displaystyle C _ { i } = \sum _ { j \oplus k = i } A _ { j } * B _ { k }$</span>, and the <span class="math-container">$\oplus$</span>represents any boolean operation. And we are able to evaluate <span class="math-container">$C$</span> in <spa...
discrete mathematics linear algebra fourier transform matrix
1
What's the connection between the two "Fast Walsh Transform"? -- (discrete mathematics linear algebra fourier transform matrix) <p>First Let's take a look at the convolution <span class="math-container">$\displaystyle C _ { i } = \sum _ { j \oplus k = i } A _ { j } * B _ { k }$</span>, and the <span class="math-contain...
habedi/stack-exchange-dataset
100,054
Help needed for understanding proof of No Regret Multi Armed Bandit Algorithm
<p>I was reading Elad Hazan's book on Online Convex Optimization(<a href="http://ocobook.cs.princeton.edu/OCObook.pdf" rel="nofollow noreferrer">http://ocobook.cs.princeton.edu/OCObook.pdf</a>) and am facing difficulty understanding the proof given for the No regret algorithm for MAB (Pg 102-103). It would be great if ...
optimization machine learning reinforcement learning
1
Help needed for understanding proof of No Regret Multi Armed Bandit Algorithm -- (optimization machine learning reinforcement learning) <p>I was reading Elad Hazan's book on Online Convex Optimization(<a href="http://ocobook.cs.princeton.edu/OCObook.pdf" rel="nofollow noreferrer">http://ocobook.cs.princeton.edu/OCObook...
habedi/stack-exchange-dataset
100,056
Avoiding underflow when identifying neighbours of a cell in a grid by using modulo
<p>I'm going through <a href="https://rustwasm.github.io/book/game-of-life/implementing.html#rust-implementation" rel="nofollow noreferrer">a tutorial</a> that is using the Game of Life as example code. It has a function in it that finds the neighbor of a given cell. It is explained quickly that "When applying a delta ...
linear algebra
1
Avoiding underflow when identifying neighbours of a cell in a grid by using modulo -- (linear algebra) <p>I'm going through <a href="https://rustwasm.github.io/book/game-of-life/implementing.html#rust-implementation" rel="nofollow noreferrer">a tutorial</a> that is using the Game of Life as example code. It has a funct...
habedi/stack-exchange-dataset
100,068
Is the bitwise-xor of a Uniform bit string and a non_uniform bit string Uniform?
<p>Having two bit strings <span class="math-container">$x,y \in \left\{0,1\right\}^n$</span>, where <span class="math-container">$x$</span> is selected following a uniform distribution but <span class="math-container">$y$</span> is not.</p>&#xA;&#xA;<p>Is <span class="math-container">$z = x \oplus y$</span> uniform?</p...
probability theory cryptography xor
1
Is the bitwise-xor of a Uniform bit string and a non_uniform bit string Uniform? -- (probability theory cryptography xor) <p>Having two bit strings <span class="math-container">$x,y \in \left\{0,1\right\}^n$</span>, where <span class="math-container">$x$</span> is selected following a uniform distribution but <span cla...
habedi/stack-exchange-dataset
100,069
My code works, But how do I make this code run in a deterministic time?
<p><strong>The Problem: &#xA;Given 3 inputs Bounce, Ball drop height, and ball view height.</strong> </p>&#xA;&#xA;<p>How do I calculate the number of times the observer can see the ball pass. &#xA;So my code gives correct output, but it takes a longer time as bounce approaches 1, how do I make it deterministic in natu...
algorithms time complexity runtime analysis python
1
My code works, But how do I make this code run in a deterministic time? -- (algorithms time complexity runtime analysis python) <p><strong>The Problem: &#xA;Given 3 inputs Bounce, Ball drop height, and ball view height.</strong> </p>&#xA;&#xA;<p>How do I calculate the number of times the observer can see the ball pass....
habedi/stack-exchange-dataset
100,082
Largest rectangle problem
<p>Recently while solving programming challenges for the fun of it, I encountered a challenge which left me kind of puzzled and yearning for a proper solution, other than brute forcing. The problem (stated in my own words) is as follows:</p>&#xA;<blockquote>&#xA;<p>In each testcase you are given N (6 &lt;= N &lt;= 10) ...
algorithms data structures
1
Largest rectangle problem -- (algorithms data structures) <p>Recently while solving programming challenges for the fun of it, I encountered a challenge which left me kind of puzzled and yearning for a proper solution, other than brute forcing. The problem (stated in my own words) is as follows:</p>&#xA;<blockquote>&#xA...
habedi/stack-exchange-dataset
100,085
Do multiple transitions over the input give finite state machines more power?
<p>In the common model of FSA, the automaton reads the input string once, moving from one state to another after reading each letter in the input string. Epsilon transitions allow moving from one state to another without reading a character. However, the movement over the input string is still unidirectional. </p>&#xA;...
formal languages automata finite automata
1
Do multiple transitions over the input give finite state machines more power? -- (formal languages automata finite automata) <p>In the common model of FSA, the automaton reads the input string once, moving from one state to another after reading each letter in the input string. Epsilon transitions allow moving from one...
habedi/stack-exchange-dataset
100,099
Variant of an approximation algorithm for vertex cover
<p>Here is an approximation algorithm that finds vertex cover of a graph.</p>&#xA;&#xA;<pre><code> C = {}&#xA; E' = {Edge set}&#xA; while E' =/ 0&#xA; Let (u,v) be an arbitrarily edge of E'&#xA; C = C U {u,v}&#xA; remove E' incident on u and v.&#xA;return C&#xA;</code></pre>&#xA;&#xA;<p>A variant: what if inste...
graphs np complete np hard approximation
1
Variant of an approximation algorithm for vertex cover -- (graphs np complete np hard approximation) <p>Here is an approximation algorithm that finds vertex cover of a graph.</p>&#xA;&#xA;<pre><code> C = {}&#xA; E' = {Edge set}&#xA; while E' =/ 0&#xA; Let (u,v) be an arbitrarily edge of E'&#xA; C = C U {u,v}&#xA; ...
habedi/stack-exchange-dataset
100,105
Addition or Subtraction of Polynomials
<p>Can addition (or subtraction) of polynomials of degree <span class="math-container">$&lt; n$</span> be done in constant time ? </p>&#xA;&#xA;<p>I am quite new to algorithms. I thought about using sorted arrays for storing the coefficients. But the addition of two sorted arrays appears to be <span class="math-contai...
time complexity
1
Addition or Subtraction of Polynomials -- (time complexity) <p>Can addition (or subtraction) of polynomials of degree <span class="math-container">$&lt; n$</span> be done in constant time ? </p>&#xA;&#xA;<p>I am quite new to algorithms. I thought about using sorted arrays for storing the coefficients. But the addition...
habedi/stack-exchange-dataset
100,112
Find a grammar for this language
<p>Assume the language:&#xA;<span class="math-container">$$L=\left\{w\in\{0,1\}^*\,| \text{ w has odd length and 111 right in the middle}\right\}$$</span></p>&#xA;&#xA;<p>This is my attempt for constructing a grammar <span class="math-container">$G$</span> for this language:</p>&#xA;&#xA;<p><span class="math-container"...
formal languages formal grammars
1
Find a grammar for this language -- (formal languages formal grammars) <p>Assume the language:&#xA;<span class="math-container">$$L=\left\{w\in\{0,1\}^*\,| \text{ w has odd length and 111 right in the middle}\right\}$$</span></p>&#xA;&#xA;<p>This is my attempt for constructing a grammar <span class="math-container">$G$...
habedi/stack-exchange-dataset
100,114
Gerrymandering Problem: Variant on Set Partitioning
<p>I was recently helping a friend with homework from a dynamic programming class, and this was the question:</p>&#xA;<blockquote>&#xA;<p>Given a set of&#xA;n&#xA;precincts&#xA;P<sub>1</sub>&#xA;,...&#xA;P<sub>n</sub>&#xA;, each containing&#xA;m&#xA;votes, with <code>n</code> being even. We&#xA;want to divide each pre...
algorithms dynamic programming np hard
1
Gerrymandering Problem: Variant on Set Partitioning -- (algorithms dynamic programming np hard) <p>I was recently helping a friend with homework from a dynamic programming class, and this was the question:</p>&#xA;<blockquote>&#xA;<p>Given a set of&#xA;n&#xA;precincts&#xA;P<sub>1</sub>&#xA;,...&#xA;P<sub>n</sub>&#xA;, ...
habedi/stack-exchange-dataset
100,120
Is there any better way to find the closest points' distance?
<p>The problem is:</p>&#xA;&#xA;<blockquote>&#xA; <p>Suppose you're given <span class="math-container">$n$</span> points in the coordinate plane, and for convenience assume that no two of their <span class="math-container">$x$</span> or <span class="math-container">$y$</span> coordinates are the same. Design an algori...
algorithms
1
Is there any better way to find the closest points' distance? -- (algorithms) <p>The problem is:</p>&#xA;&#xA;<blockquote>&#xA; <p>Suppose you're given <span class="math-container">$n$</span> points in the coordinate plane, and for convenience assume that no two of their <span class="math-container">$x$</span> or <spa...
habedi/stack-exchange-dataset
100,121
reducing a decision problem to a local search problem
<p>Lemma 4 in <a href="https://www.karlin.mff.cuni.cz/~krajicek/jpy2.pdf" rel="nofollow noreferrer">How easy is local search</a> by Johnson, Papadimitriou, and Yannakakis, states:</p>&#xA;&#xA;<blockquote>&#xA; <p>If a <strong>PLS</strong> problem is <strong>NP</strong>-hard then <strong>NP</strong> = <strong>P</stron...
complexity theory reductions decision problem search problem
1
reducing a decision problem to a local search problem -- (complexity theory reductions decision problem search problem) <p>Lemma 4 in <a href="https://www.karlin.mff.cuni.cz/~krajicek/jpy2.pdf" rel="nofollow noreferrer">How easy is local search</a> by Johnson, Papadimitriou, and Yannakakis, states:</p>&#xA;&#xA;<blockq...
habedi/stack-exchange-dataset
100,128
Binary Search Tree – Number of comparisons when element is not found
<p>I am confused regarding Binary Search Trees (BST) when an element does not exist in the tree. </p>&#xA;&#xA;<p>For example, to search for element "6", would it take 5 comparisons to search for this element?</p>&#xA;&#xA;<p>My understanding is:</p>&#xA;&#xA;<ol>&#xA;<li><p>Compare root (Not found - move left)</p></li...
binary search trees
1
Binary Search Tree – Number of comparisons when element is not found -- (binary search trees) <p>I am confused regarding Binary Search Trees (BST) when an element does not exist in the tree. </p>&#xA;&#xA;<p>For example, to search for element "6", would it take 5 comparisons to search for this element?</p>&#xA;&#xA;<p>...
habedi/stack-exchange-dataset
100,133
How to think when devising a TM that decides if a DFA rejects some string?
<p>The title should explain my question thoroughly enough. I can't seem to get started anywhere. Intuitively it seems like some kind of brute-forcing would work i.e if the DFA has the symbols <span class="math-container">$\Sigma$</span> you would simply be passing strings from <span class="math-container">$\Sigma^*$</s...
turing machines
1
How to think when devising a TM that decides if a DFA rejects some string? -- (turing machines) <p>The title should explain my question thoroughly enough. I can't seem to get started anywhere. Intuitively it seems like some kind of brute-forcing would work i.e if the DFA has the symbols <span class="math-container">$\S...
habedi/stack-exchange-dataset
100,152
NP-Completeness reduction, using a same input
<p>We have problem X and Y that we know is NP-Complete. Problem X uses graph G as an input and Problem Y uses graph G and constant k as an input.</p>&#xA;&#xA;<p>Problem we are trying to reduce to, which I will call Z, is reasoning whether given a graph G and constant k, does G have X or Y.</p>&#xA;&#xA;<p>I have been ...
np complete reductions
1
NP-Completeness reduction, using a same input -- (np complete reductions) <p>We have problem X and Y that we know is NP-Complete. Problem X uses graph G as an input and Problem Y uses graph G and constant k as an input.</p>&#xA;&#xA;<p>Problem we are trying to reduce to, which I will call Z, is reasoning whether given ...
habedi/stack-exchange-dataset
100,158
Proving a value is the result of the execution of an algorithm
<p>Assuming an algorithm <span class="math-container">$A$</span> known to both Alice and Bob.</p>&#xA;&#xA;<p>Alice runs the algorithm and gets a result <span class="math-container">$R$</span>.&#xA;How can Alice prove to Bob that <span class="math-container">$R$</span> is the result of the execution of <span class="mat...
proof techniques
1
Proving a value is the result of the execution of an algorithm -- (proof techniques) <p>Assuming an algorithm <span class="math-container">$A$</span> known to both Alice and Bob.</p>&#xA;&#xA;<p>Alice runs the algorithm and gets a result <span class="math-container">$R$</span>.&#xA;How can Alice prove to Bob that <span...
habedi/stack-exchange-dataset
100,159
How to avoid having to store extra information about padding (for byte size alignment) with Huffman coding
<p>When storing the encoded Huffman bit stream in bytes, in general, either</p>&#xA;&#xA;<ol>&#xA;<li>the final byte gets padded or</li>&#xA;<li>a pseudo end-of-file symbol gets used</li>&#xA;</ol>&#xA;&#xA;<p>In the former case, the number of bits padded needs to be stored somewhere, requiring another 3 bits. In the l...
huffman coding
1
How to avoid having to store extra information about padding (for byte size alignment) with Huffman coding -- (huffman coding) <p>When storing the encoded Huffman bit stream in bytes, in general, either</p>&#xA;&#xA;<ol>&#xA;<li>the final byte gets padded or</li>&#xA;<li>a pseudo end-of-file symbol gets used</li>&#xA;<...
habedi/stack-exchange-dataset
100,175
Interval extensionality?
<p>For example, in the proof of lemma 6.4.1 in the HoTT book, a function inductively defined over a function is simply applied on paths <code>loop</code> and <code>refl</code>, and then a path between <code>loop</code> and <code>refl</code> is used (presumably by congruence via <code>f</code>) to construct a path betwe...
homotopy type theory
1
Interval extensionality? -- (homotopy type theory) <p>For example, in the proof of lemma 6.4.1 in the HoTT book, a function inductively defined over a function is simply applied on paths <code>loop</code> and <code>refl</code>, and then a path between <code>loop</code> and <code>refl</code> is used (presumably by congr...
habedi/stack-exchange-dataset
100,180
Is this an abuse big O notation as a power of a number?
<p>Theorem 7.11 in <a href="https://rads.stackoverflow.com/amzn/click/113318779X" rel="nofollow noreferrer">Introduction to the theory of computation</a> 3rth edition says</p>&#xA;&#xA;<blockquote>&#xA; <p>Let <span class="math-container">$t(n)$</span> be a function where <span class="math-container">$t(n)&gt;n$</span...
time complexity
1
Is this an abuse big O notation as a power of a number? -- (time complexity) <p>Theorem 7.11 in <a href="https://rads.stackoverflow.com/amzn/click/113318779X" rel="nofollow noreferrer">Introduction to the theory of computation</a> 3rth edition says</p>&#xA;&#xA;<blockquote>&#xA; <p>Let <span class="math-container">$t(...
habedi/stack-exchange-dataset
100,187
General structure of solutions to 3-SAT circuits
<p>Certain special forms of the SAT problem have solution sets of a special form. For example, given any three solutions to a 2-SAT circuit, their bitwise median is also a solution. Likewise, given any three solutions to an XOR-SAT circuit, their bitwise XOR is also a solution. Lastly, given any two solutions to a HORN...
satisfiability 3 sat constraint satisfaction 2 sat
1
General structure of solutions to 3-SAT circuits -- (satisfiability 3 sat constraint satisfaction 2 sat) <p>Certain special forms of the SAT problem have solution sets of a special form. For example, given any three solutions to a 2-SAT circuit, their bitwise median is also a solution. Likewise, given any three solutio...
habedi/stack-exchange-dataset
100,196
proving correctness of algorithm about graphs with DFS
<p>I need to prove/disprove the correctness of the following algorithm:&#xA;Let G be a simple, undirected and connected graph. The task is to find if the graph contains an odd cycle. The algorithm goes that way. First, you run the DFS algorithm on the graph, since it is connected it will result in a single tree. The fo...
algorithms graphs correctness proof
1
proving correctness of algorithm about graphs with DFS -- (algorithms graphs correctness proof) <p>I need to prove/disprove the correctness of the following algorithm:&#xA;Let G be a simple, undirected and connected graph. The task is to find if the graph contains an odd cycle. The algorithm goes that way. First, you r...
habedi/stack-exchange-dataset
100,197
How to calculate $\sum_{i=1}^n \mu^2(i)$ in less than $O(n)$'s time
<p>To go with <span class="math-container">$O(n)$</span>, we can use the <strong>linear sieve</strong> according to that <span class="math-container">$\mu(n)$</span> is multiplicative. But it seems that we don't have to work each <span class="math-container">$\mu(n)$</span> out and accumulate them together, because I o...
time complexity discrete mathematics number theory
1
How to calculate $\sum_{i=1}^n \mu^2(i)$ in less than $O(n)$'s time -- (time complexity discrete mathematics number theory) <p>To go with <span class="math-container">$O(n)$</span>, we can use the <strong>linear sieve</strong> according to that <span class="math-container">$\mu(n)$</span> is multiplicative. But it seem...
habedi/stack-exchange-dataset
100,198
Compound interest with varying compounding frequency
<p>Here is the problem I have attempted to solve.</p>&#xA;&#xA;<blockquote>&#xA; <p>Given original principal <span class="math-container">$n$</span> and aggregate rate <span class="math-container">$r$</span>, find the maximum final principal that can be yielded.</p>&#xA;</blockquote>&#xA;&#xA;<p>Though I know that the...
algorithms
1
Compound interest with varying compounding frequency -- (algorithms) <p>Here is the problem I have attempted to solve.</p>&#xA;&#xA;<blockquote>&#xA; <p>Given original principal <span class="math-container">$n$</span> and aggregate rate <span class="math-container">$r$</span>, find the maximum final principal that can...
habedi/stack-exchange-dataset
100,201
Deleting edges such that largest connected component has at most $n/4$ nodes
<p>Let <span class="math-container">$G = (V, E)$</span> be a connected undirected graph with <span class="math-container">$n &gt; 4$</span> nodes <span class="math-container">$V = \{v_1, v_2, \dots, v_n\}$</span> and <span class="math-container">$m$</span> edges.&#xA;Let <span class="math-container">$\{e_1, e_2, \dots ...
complexity theory graphs
1
Deleting edges such that largest connected component has at most $n/4$ nodes -- (complexity theory graphs) <p>Let <span class="math-container">$G = (V, E)$</span> be a connected undirected graph with <span class="math-container">$n &gt; 4$</span> nodes <span class="math-container">$V = \{v_1, v_2, \dots, v_n\}$</span> ...
habedi/stack-exchange-dataset
100,206
Why is there no permutation in Regexes? (Even if regular languages seem to be able to do this)
<h1>The Problem</h1>&#xA;&#xA;<p>There is no easy way to get a permutation with a regex.</p>&#xA;&#xA;<ul>&#xA;<li><strong>Permutation:</strong> Getting a <em>word</em> <span class="math-container">$$w=x_1…x_n$$</span> ("aabc") to another order, without changing number or kind of letters.</li>&#xA;<li><strong>Regex:</s...
formal languages regular languages regular expressions
1
Why is there no permutation in Regexes? (Even if regular languages seem to be able to do this) -- (formal languages regular languages regular expressions) <h1>The Problem</h1>&#xA;&#xA;<p>There is no easy way to get a permutation with a regex.</p>&#xA;&#xA;<ul>&#xA;<li><strong>Permutation:</strong> Getting a <em>word</...
habedi/stack-exchange-dataset
100,208
Why does the cut $(V_C,V-V_C)$ respect $A$?
<blockquote>&#xA;<p><em><strong>Corollary 23.2</strong></em></p>&#xA;<p>Let <span class="math-container">$G = (V,E)$</span> be a connected, undirected graph with a real-valued weight function <span class="math-container">$w$</span> defined on <span class="math-container">$E$</span>. Let <span class="math-container">$A$...
minimum spanning tree
1
Why does the cut $(V_C,V-V_C)$ respect $A$? -- (minimum spanning tree) <blockquote>&#xA;<p><em><strong>Corollary 23.2</strong></em></p>&#xA;<p>Let <span class="math-container">$G = (V,E)$</span> be a connected, undirected graph with a real-valued weight function <span class="math-container">$w$</span> defined on <span ...
habedi/stack-exchange-dataset
100,211
What is the best way to compress a string with only numbers and commas in it?
<p>I have a string like this:</p>&#xA;&#xA;<pre><code>11,512,64,23,46,12,67,85,84&#xA;</code></pre>&#xA;&#xA;<p>And I'm sure it's following these rules below:</p>&#xA;&#xA;<ol>&#xA;<li>Only <code>,</code> and <code>0123456789</code> in it.</li>&#xA;<li>No number will be bigger than 999, that means they are all 1,2 or 3...
algorithms data compression
1
What is the best way to compress a string with only numbers and commas in it? -- (algorithms data compression) <p>I have a string like this:</p>&#xA;&#xA;<pre><code>11,512,64,23,46,12,67,85,84&#xA;</code></pre>&#xA;&#xA;<p>And I'm sure it's following these rules below:</p>&#xA;&#xA;<ol>&#xA;<li>Only <code>,</code> and ...
habedi/stack-exchange-dataset
100,223
Why does Radix sort require stable digit sorts?
<p>I'm reading the CLRS book and have a question about the following quote from the book. </p>&#xA;&#xA;<blockquote>&#xA; <p>In order for radix sort to work correctly, the digit sorts must be stable.</p>&#xA;</blockquote>&#xA;&#xA;<p>Why is stability required? Wouldn't Radix sort still produce correctly sorted output ...
algorithms sorting radix sort
1
Why does Radix sort require stable digit sorts? -- (algorithms sorting radix sort) <p>I'm reading the CLRS book and have a question about the following quote from the book. </p>&#xA;&#xA;<blockquote>&#xA; <p>In order for radix sort to work correctly, the digit sorts must be stable.</p>&#xA;</blockquote>&#xA;&#xA;<p>Wh...
habedi/stack-exchange-dataset
100,226
Regarding time complexity of multi-tape Turing machines
<p>So let's say I've implemented an algorithm running in <span class="math-container">$O(n^2)$</span> on my 3-tape TM. What kind of time complexity would I expect for a single-tape TM? </p>&#xA;&#xA;<p>I just don't know where to get started...</p>&#xA;
complexity theory turing machines
1
Regarding time complexity of multi-tape Turing machines -- (complexity theory turing machines) <p>So let's say I've implemented an algorithm running in <span class="math-container">$O(n^2)$</span> on my 3-tape TM. What kind of time complexity would I expect for a single-tape TM? </p>&#xA;&#xA;<p>I just don't know where...
habedi/stack-exchange-dataset
100,230
How many prefix code we can find for a given distribution of probability?
<p>A source emits 5 signals s1, s2, s3, s4 and s5 whose probabilities are as follows: 1/3, 1/3, 1/9, 1/9, 1/9, 1/9. How many prefix codes we can construct on A={a, b, c}? And how many are there with the same performance (efficiency)?</p>&#xA;
probability theory information theory coding theory mathematical foundations
1
How many prefix code we can find for a given distribution of probability? -- (probability theory information theory coding theory mathematical foundations) <p>A source emits 5 signals s1, s2, s3, s4 and s5 whose probabilities are as follows: 1/3, 1/3, 1/9, 1/9, 1/9, 1/9. How many prefix codes we can construct on A={a, ...
habedi/stack-exchange-dataset
100,231
Minimizing the area of a simple polygon by modifying/adding to a subset of its vertices
<p>I'm trying to minimize the area of a simple (non-intersecting, without holes) polygon by adding points to it, or modifying points of its subset. Let me describe this more formally:</p>&#xA;&#xA;<p>Let:</p>&#xA;&#xA;<ul>&#xA;<li><span class="math-container">$P$</span> be a polygon consisting of points <span class="ma...
optimization computational geometry
1
Minimizing the area of a simple polygon by modifying/adding to a subset of its vertices -- (optimization computational geometry) <p>I'm trying to minimize the area of a simple (non-intersecting, without holes) polygon by adding points to it, or modifying points of its subset. Let me describe this more formally:</p>&#xA...
habedi/stack-exchange-dataset
100,233
NP-completeness and reduction of MAX-XOR-SAT and MAX-2-XOR-SAT
<p>It is often stated that the MAX-XOR-SAT problem is NP-hard, and that likewise is the MAX-2-XOR-SAT problem. However, I cannot find a reduction from SAT to either of these problems, nor a proof of NP-hardness. Is one published anywhere?</p>&#xA;
np complete satisfiability
1
NP-completeness and reduction of MAX-XOR-SAT and MAX-2-XOR-SAT -- (np complete satisfiability) <p>It is often stated that the MAX-XOR-SAT problem is NP-hard, and that likewise is the MAX-2-XOR-SAT problem. However, I cannot find a reduction from SAT to either of these problems, nor a proof of NP-hardness. Is one publis...
habedi/stack-exchange-dataset
100,237
How to compare an element with other elements within an array efficiently for a condition
<p>I need to compare each index with one another and associated array value as well. </p>&#xA;&#xA;<p>For example,</p>&#xA;&#xA;<pre><code>for(int i = 0; i &lt; n - 1; i++) {&#xA;&#xA; for(int j = i + 1; j &lt; n; j++) {&#xA;&#xA; if(a[i] &gt; a[j]) { // Condition will be any &#xA;&#xA; swap(a[i], ...
time complexity sorting arrays comparison
1
How to compare an element with other elements within an array efficiently for a condition -- (time complexity sorting arrays comparison) <p>I need to compare each index with one another and associated array value as well. </p>&#xA;&#xA;<p>For example,</p>&#xA;&#xA;<pre><code>for(int i = 0; i &lt; n - 1; i++) {&#xA;&#xA...
habedi/stack-exchange-dataset
100,247
Cost of the MST of the graph
<p>Studying for a test in a computer science class and cannot figure out the answer to this question. Any help would be appreciated! </p>&#xA;&#xA;<p><a href="https://i.stack.imgur.com/R2Izx.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/R2Izx.png" alt="Cost of the MST"></a> </p>&#xA;&#xA;<p>Althou...
graphs minimum spanning tree
1
Cost of the MST of the graph -- (graphs minimum spanning tree) <p>Studying for a test in a computer science class and cannot figure out the answer to this question. Any help would be appreciated! </p>&#xA;&#xA;<p><a href="https://i.stack.imgur.com/R2Izx.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.co...
habedi/stack-exchange-dataset
100,250
The time complexity of the Wikipedia version of Pollards $(p-1)$ algorithm
<p>I am trying to understand the runtime of Pollard's <span class="math-container">$(p-1)$</span>-algorithm as presented on <a href="https://en.wikipedia.org/wiki/Pollard%27s_p_%E2%88%92_1_algorithm" rel="nofollow noreferrer">Wikipedia</a>. There the author writes that it takes <span class="math-container">$\mathcal{O}...
algorithms runtime analysis primes
1
The time complexity of the Wikipedia version of Pollards $(p-1)$ algorithm -- (algorithms runtime analysis primes) <p>I am trying to understand the runtime of Pollard's <span class="math-container">$(p-1)$</span>-algorithm as presented on <a href="https://en.wikipedia.org/wiki/Pollard%27s_p_%E2%88%92_1_algorithm" rel="...
habedi/stack-exchange-dataset
100,255
Algorithm Design for Linear Programming
<p>I am trying to complete question and would like to avoid copying answers, but I do not necessarily understand what I am doing.</p>&#xA;&#xA;<p>I am working on the following problem: </p>&#xA;&#xA;<blockquote>&#xA; <p>Suppose you are consulting for a company that manufactures PC. equipment and ships it to distributo...
algorithms dynamic programming
1
Algorithm Design for Linear Programming -- (algorithms dynamic programming) <p>I am trying to complete question and would like to avoid copying answers, but I do not necessarily understand what I am doing.</p>&#xA;&#xA;<p>I am working on the following problem: </p>&#xA;&#xA;<blockquote>&#xA; <p>Suppose you are consult...
habedi/stack-exchange-dataset
100,256
Given tree with 0 or 1 assigned to each node, count paths with odd number of ones in it
<p>Let's say we have given tree of <span class="math-container">$N$</span> nodes and <span class="math-container">$N-1$</span> edges, each of the <span class="math-container">$N$</span> nodes is assigned one integer, either <span class="math-container">$0$</span> or <span class="math-container">$1$</span>. We want to c...
trees counting
1
Given tree with 0 or 1 assigned to each node, count paths with odd number of ones in it -- (trees counting) <p>Let's say we have given tree of <span class="math-container">$N$</span> nodes and <span class="math-container">$N-1$</span> edges, each of the <span class="math-container">$N$</span> nodes is assigned one inte...
habedi/stack-exchange-dataset
100,265
Checking if sequence is almost strictly in ascending order
<p>This was part of my interview questions.</p>&#xA;<blockquote>&#xA;<p>Given a sequence of integers as an array, I have to determine whether it is possible to obtain a strictly increasing sequence by removing no more than one element from the array.</p>&#xA;<p>For instance,</p>&#xA;<p>For <code>sequence = [1, 3, 2, 1]...
algorithms
1
Checking if sequence is almost strictly in ascending order -- (algorithms) <p>This was part of my interview questions.</p>&#xA;<blockquote>&#xA;<p>Given a sequence of integers as an array, I have to determine whether it is possible to obtain a strictly increasing sequence by removing no more than one element from the a...
habedi/stack-exchange-dataset
100,278
Shannon Entropy of 0.922, 3 Distinct Values
<p>Given a string of values <span class="math-container">$AAAAAAAABC$</span>, the Shannon Entropy in log base&nbsp;<span class="math-container">$2$</span> comes to <span class="math-container">$0.922$</span>. From what I understand, in base&nbsp;<span class="math-container">$2$</span> the Shannon Entropy rounded up is ...
information theory mathematical foundations entropy binary
1
Shannon Entropy of 0.922, 3 Distinct Values -- (information theory mathematical foundations entropy binary) <p>Given a string of values <span class="math-container">$AAAAAAAABC$</span>, the Shannon Entropy in log base&nbsp;<span class="math-container">$2$</span> comes to <span class="math-container">$0.922$</span>. Fro...
habedi/stack-exchange-dataset
100,279
Determining cycle time and and hold time in logic circuits
<p>First I have general question. In a circuit with both logic and D edge flip flop does hold time have to satisfy <span class="math-container">$t_{hold} &lt; t_{setup}($</span>D-FF<span class="math-container">$) + t_{pd-min}$</span>(Logic), </p>&#xA;&#xA;<p>or is it enough that <span class="math-container">$t_{hold} \...
algorithms optimization computer architecture logic
1
Determining cycle time and and hold time in logic circuits -- (algorithms optimization computer architecture logic) <p>First I have general question. In a circuit with both logic and D edge flip flop does hold time have to satisfy <span class="math-container">$t_{hold} &lt; t_{setup}($</span>D-FF<span class="math-conta...
habedi/stack-exchange-dataset
100,281
How to solve $T(n) = 3 T(n-1) + 10 T(n-2) + 7 \cdot 5 ^ n$?
<p>Consider the recurrence&#xA;<span class="math-container">$$ T(n) = 3 T(n-1) + 10 T(n-2) + 7 \cdot 5 ^ n, $$</span>&#xA;with base cases <span class="math-container">$T(0) = 4$</span> and <span class="math-container">$T(1) = 3$</span>.</p>&#xA;&#xA;<p>How do I solve such a recurrence?</p>&#xA;
recurrence relation
1
How to solve $T(n) = 3 T(n-1) + 10 T(n-2) + 7 \cdot 5 ^ n$? -- (recurrence relation) <p>Consider the recurrence&#xA;<span class="math-container">$$ T(n) = 3 T(n-1) + 10 T(n-2) + 7 \cdot 5 ^ n, $$</span>&#xA;with base cases <span class="math-container">$T(0) = 4$</span> and <span class="math-container">$T(1) = 3$</span>...
habedi/stack-exchange-dataset
100,287
Checking Divisibility Using Minimal Bits
<blockquote>&#xA; <p>Suppose we're given an infinite stream of integers, <span class="math-container">$x_1, x_2, \dots$</span>.</p>&#xA; &#xA; <p>a) Show that we can compute whether the sum of all integers seen so far is divisible by some fixed integer <span class="math-container">$N$</span> using <span class="math-...
number theory modular arithmetic
1
Checking Divisibility Using Minimal Bits -- (number theory modular arithmetic) <blockquote>&#xA; <p>Suppose we're given an infinite stream of integers, <span class="math-container">$x_1, x_2, \dots$</span>.</p>&#xA; &#xA; <p>a) Show that we can compute whether the sum of all integers seen so far is divisible by some...
habedi/stack-exchange-dataset
100,304
Is this a correct grammar for untyped lambda calculus?
<p>I am trying to write a recursive-descent parser for untyped lambda calculus. While researching the way of formulating the grammar, I managed to put together something like this:</p>&#xA;&#xA;<pre><code>without left-recursion:&#xA;TERM -&gt; APPLICATION | ABSTRACTION&#xA;ABSTRACTION -&gt; LAMBDA LCID DOT TER...
formal grammars lambda calculus parsers
1
Is this a correct grammar for untyped lambda calculus? -- (formal grammars lambda calculus parsers) <p>I am trying to write a recursive-descent parser for untyped lambda calculus. While researching the way of formulating the grammar, I managed to put together something like this:</p>&#xA;&#xA;<pre><code>without left-re...
habedi/stack-exchange-dataset
100,311
FSA for $(ab)^*(cb^n)^*$
<blockquote>&#xA; <p>How can I prove that this language is regular, possibly by making a finite automata for this: <span class="math-container">$(ab)^*(cb^n)^*$</span>, where <span class="math-container">$n\ge1$</span>?</p>&#xA;</blockquote>&#xA;&#xA;<p>An automaton can easily be drawn for the part <span class="math-c...
regular languages finite automata context sensitive
1
FSA for $(ab)^*(cb^n)^*$ -- (regular languages finite automata context sensitive) <blockquote>&#xA; <p>How can I prove that this language is regular, possibly by making a finite automata for this: <span class="math-container">$(ab)^*(cb^n)^*$</span>, where <span class="math-container">$n\ge1$</span>?</p>&#xA;</blockqu...
habedi/stack-exchange-dataset
100,313
Find Hamiltonian cycle in polynomial time
<p>I want to know for what types of graph it is possible to find Hamiltonian cycle in polynomial time. It would be helpful also to show why on some types of graph finding Hamiltonian cycle would be only possible in exponential time.</p>&#xA;
time complexity polynomial time hamiltonian circuit
1
Find Hamiltonian cycle in polynomial time -- (time complexity polynomial time hamiltonian circuit) <p>I want to know for what types of graph it is possible to find Hamiltonian cycle in polynomial time. It would be helpful also to show why on some types of graph finding Hamiltonian cycle would be only possible in expone...
habedi/stack-exchange-dataset
100,315
Is a Turing machine too strong of a model to model physical computation?
<p>I've heard many times people debate the possibility of a real world computation that is impossible for a Turing machine, especially in the context of a human mind. Implying that the Church-Turing thesis is wrong and that a Turing machine does not accurately model any possible real world computation. To me, it seems ...
turing machines computability church turing thesis
1
Is a Turing machine too strong of a model to model physical computation? -- (turing machines computability church turing thesis) <p>I've heard many times people debate the possibility of a real world computation that is impossible for a Turing machine, especially in the context of a human mind. Implying that the Church...
habedi/stack-exchange-dataset
100,318
What is the difference between A-normalization and K-normalization in compilers?
<p><a href="https://en.wikipedia.org/wiki/A-normal_form" rel="noreferrer">Administrative normal form</a> is a program intermediate representation in which each immediate instruction has a name. It is used in <a href="https://ghc.haskell.org/trac/ghc/wiki/Commentary/Compiler/GeneratedCode" rel="noreferrer">GHC</a> and <...
programming languages compilers
1
What is the difference between A-normalization and K-normalization in compilers? -- (programming languages compilers) <p><a href="https://en.wikipedia.org/wiki/A-normal_form" rel="noreferrer">Administrative normal form</a> is a program intermediate representation in which each immediate instruction has a name. It is us...
habedi/stack-exchange-dataset
100,320
Find pair of complex numbers with maximal sum
<p>Given two lists of complex numbers, is there an efficient algorithm to choose one element from each list such that the magnitude of their sum is maximal?</p>&#xA;
algorithms computational geometry
1
Find pair of complex numbers with maximal sum -- (algorithms computational geometry) <p>Given two lists of complex numbers, is there an efficient algorithm to choose one element from each list such that the magnitude of their sum is maximal?</p>&#xA;
habedi/stack-exchange-dataset
100,357
In ISGCI, unit interval graphs are denoted as ($C_{n+4}$,$S_3$,claw,net)-free. Is this an accurate notation?
<p>When I search <a href="http://graphclasses.org/classes/gc_299.html" rel="noreferrer">unit interval graphs</a> in ISGCI, it says that the unit interval graphs (<strong>UIG</strong>) are equivalent to (<span class="math-container">$C_{n+4}$</span>,<span class="math-container">$S_3$</span>,claw,net)-free graphs.</p>&#x...
graphs notation
1
In ISGCI, unit interval graphs are denoted as ($C_{n+4}$,$S_3$,claw,net)-free. Is this an accurate notation? -- (graphs notation) <p>When I search <a href="http://graphclasses.org/classes/gc_299.html" rel="noreferrer">unit interval graphs</a> in ISGCI, it says that the unit interval graphs (<strong>UIG</strong>) are eq...
habedi/stack-exchange-dataset
100,362
Prove that $L = \{a^i \;:\; (\exists x \in \mathrm{Lang}(M_i))\;[ xx \notin \mathrm{Lang}(M_i) ] \}$ not recursively enumerable
<p>Past year paper question:</p>&#xA;&#xA;<p>Let <span class="math-container">$M_i$</span> denote the Turing machine with code <span class="math-container">$i$</span> using the alphabet <span class="math-container">$\Sigma=\{a,b\}$</span>.</p>&#xA;&#xA;<p>Show that the following language is not recursively enumerable:<...
computability reductions undecidability
1
Prove that $L = \{a^i \;:\; (\exists x \in \mathrm{Lang}(M_i))\;[ xx \notin \mathrm{Lang}(M_i) ] \}$ not recursively enumerable -- (computability reductions undecidability) <p>Past year paper question:</p>&#xA;&#xA;<p>Let <span class="math-container">$M_i$</span> denote the Turing machine with code <span class="math-co...
habedi/stack-exchange-dataset
100,364
Listing all prime numbers less than an integer N
<p>I am trying to solve this problem listing all prime numbers less than an integer but using the smallest amount of memory. </p>&#xA;&#xA;<p>Is it possible to solve this problem using a smaller amount of memory?</p>&#xA;&#xA;<pre><code>int main () &#xA;{&#xA; int n = 10000;&#xA; for (int i=2; i&lt;n; i++) &#xA; ...
algorithms primes
1
Listing all prime numbers less than an integer N -- (algorithms primes) <p>I am trying to solve this problem listing all prime numbers less than an integer but using the smallest amount of memory. </p>&#xA;&#xA;<p>Is it possible to solve this problem using a smaller amount of memory?</p>&#xA;&#xA;<pre><code>int main ()...
habedi/stack-exchange-dataset
100,366
DFA that rejects $a^{23}$ but accepts $\{a^i|i\geq 24\}$
<p>Construct a DFA <span class="math-container">$M$</span> with <span class="math-container">$\Sigma = \{a\}$</span> and max. 11 states so that <span class="math-container">$a^{23}\not\in L(M)$</span> but <span class="math-container">$\{a^i|i\geq 24\}\subset L(M)$</span>. </p>&#xA;&#xA;<p>I don't see how it is possible...
formal languages automata finite automata
1
DFA that rejects $a^{23}$ but accepts $\{a^i|i\geq 24\}$ -- (formal languages automata finite automata) <p>Construct a DFA <span class="math-container">$M$</span> with <span class="math-container">$\Sigma = \{a\}$</span> and max. 11 states so that <span class="math-container">$a^{23}\not\in L(M)$</span> but <span class...
habedi/stack-exchange-dataset
100,368
Linear Regression using a Neural Network
<p>I am trying to create a regression model using a Neural Network. I am currently learning how to work with neural networks (deeplearning.ai) and so the model is not implemented using any existing frameworks like keras.</p>&#xA;&#xA;<p>Based on what I have learned, </p>&#xA;&#xA;<ul>&#xA;<li>the model is configured to...
neural networks
1
Linear Regression using a Neural Network -- (neural networks) <p>I am trying to create a regression model using a Neural Network. I am currently learning how to work with neural networks (deeplearning.ai) and so the model is not implemented using any existing frameworks like keras.</p>&#xA;&#xA;<p>Based on what I have ...
habedi/stack-exchange-dataset
100,390
Why does the concatenation operation imply the empty string?
<p>I'm a noob reading Michael Sipser's Introduction to the Theory of Computation, and I'm at a part where he's demonstrating how to construct finite automata that accept languages described by regular expressions. He does this by giving regular expressions, breaking them down into simpler regular expressions that repre...
finite automata regular expressions
1
Why does the concatenation operation imply the empty string? -- (finite automata regular expressions) <p>I'm a noob reading Michael Sipser's Introduction to the Theory of Computation, and I'm at a part where he's demonstrating how to construct finite automata that accept languages described by regular expressions. He d...
habedi/stack-exchange-dataset
100,394
Short pipeline or long pipeline
<p>What is meant by a short pipeline?</p>&#xA;&#xA;<p>Does that mean the instructions are split into small number of pieces OR length of a piece is short?</p>&#xA;
cpu pipelines
1
Short pipeline or long pipeline -- (cpu pipelines) <p>What is meant by a short pipeline?</p>&#xA;&#xA;<p>Does that mean the instructions are split into small number of pieces OR length of a piece is short?</p>&#xA;
habedi/stack-exchange-dataset
100,401
what is the meaning of hit time?
<pre><code>Average memory access time = Hit time + Miss rate * miss penalty&#xA;</code></pre>&#xA;&#xA;<p>Assume a computer with only one cache level. What is the exact meaning of hit time? Is it the number of clock cycles to access data from cache? OR Clock cycles to execute an instruction? How does the number of cloc...
cpu cache memory access
1
what is the meaning of hit time? -- (cpu cache memory access) <pre><code>Average memory access time = Hit time + Miss rate * miss penalty&#xA;</code></pre>&#xA;&#xA;<p>Assume a computer with only one cache level. What is the exact meaning of hit time? Is it the number of clock cycles to access data from cache? OR Clock...
habedi/stack-exchange-dataset
100,411
Multiple inputs in lambda calculus (Confusing example)
<p>In a programming class I take, we briefly (very briefly) touched lambda calculus. I think I have a pretty good grasp of the basics now, but one example given I just don't understand. Am I missing something or is the example possibly false?</p>&#xA;&#xA;<p><span class="math-container">$\lambda x.x \; (\lambda y.2*y) ...
lambda calculus functional programming
1
Multiple inputs in lambda calculus (Confusing example) -- (lambda calculus functional programming) <p>In a programming class I take, we briefly (very briefly) touched lambda calculus. I think I have a pretty good grasp of the basics now, but one example given I just don't understand. Am I missing something or is the ex...
habedi/stack-exchange-dataset
100,414
Proving problem NP-completeness
<p>I am studying computational complexity and i am trying to solve this problem.&#xA;We are given a (non-bipartite) <strong>complete</strong> graph:</p>&#xA;&#xA;<p><em>G = (V, W, E)</em></p>&#xA;&#xA;<p>where the vertices can be divided in two classes V and W and the edges between any two vertices are weighted either ...
complexity theory np complete reductions proof techniques np
1
Proving problem NP-completeness -- (complexity theory np complete reductions proof techniques np) <p>I am studying computational complexity and i am trying to solve this problem.&#xA;We are given a (non-bipartite) <strong>complete</strong> graph:</p>&#xA;&#xA;<p><em>G = (V, W, E)</em></p>&#xA;&#xA;<p>where the vertices...
habedi/stack-exchange-dataset