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
69,819
What does it mean by saying "Asymptotically more efficient"?
<p>What does it mean when we say that an algorithm $X$ is asymptotically more efficient than $Y$ ?</p>&#xA;&#xA;<ul>&#xA;<li>$X$ will be a better choice for all inputs.</li>&#xA;<li>$X$ will be a better choice for all inputs except small inputs.</li>&#xA;<li>$X$ will be a better choice for all inputs except large input...
algorithms algorithm analysis terminology asymptotics
1
What does it mean by saying "Asymptotically more efficient"? -- (algorithms algorithm analysis terminology asymptotics) <p>What does it mean when we say that an algorithm $X$ is asymptotically more efficient than $Y$ ?</p>&#xA;&#xA;<ul>&#xA;<li>$X$ will be a better choice for all inputs.</li>&#xA;<li>$X$ will be a bett...
habedi/stack-exchange-dataset
69,821
Savitch's theorem and time relation
<p>We know that $NTIME(t(n)) \subseteq DSPACE(t(n))$ and we know - by Savitch's theorem - that $NSPACE(s(n)) \subseteq DSPACE(s^2(n))$.</p>&#xA;&#xA;<p>By the space/time relation $(s(n) \leq t(n))$ I know that $NTIME(t(n)) \subseteq NSPACE(t(n))$, then by Savitch's theorem $NSPACE(t(n)) \subseteq DSPACE(t^2(n))$ and no...
time complexity
1
Savitch's theorem and time relation -- (time complexity) <p>We know that $NTIME(t(n)) \subseteq DSPACE(t(n))$ and we know - by Savitch's theorem - that $NSPACE(s(n)) \subseteq DSPACE(s^2(n))$.</p>&#xA;&#xA;<p>By the space/time relation $(s(n) \leq t(n))$ I know that $NTIME(t(n)) \subseteq NSPACE(t(n))$, then by Savitch...
habedi/stack-exchange-dataset
69,830
What is the name of this positive integer set data structure?
<p>Google is failing me, so here goes:</p>&#xA;&#xA;<ul>&#xA;<li>The data structure is used to describe a set of positive integers.</li>&#xA;<li>It works conceptually, by keeping track of disjoint ranges [a,b) on the number line.</li>&#xA;<li>These ranges are stored, in a sorted manner. For two consecutive ranges <code...
data structures sets
1
What is the name of this positive integer set data structure? -- (data structures sets) <p>Google is failing me, so here goes:</p>&#xA;&#xA;<ul>&#xA;<li>The data structure is used to describe a set of positive integers.</li>&#xA;<li>It works conceptually, by keeping track of disjoint ranges [a,b) on the number line.</l...
habedi/stack-exchange-dataset
69,846
Is maximum matching problem equivalent to maximum independent set problem in its dual graph?
<p>A hypergraph $H = (V,E)$ consists of a set $V = \{v_1, v_2, \cdots, v_n\}$ of vertices and a set $E = \{e_1, e_2, \cdots , e_m\}$ of edges, each being a subset of $V$. </p>&#xA;&#xA;<p>A subset $M \subseteq E(H)$ is a <strong><em>matching</em></strong> if every pair of edges from $M$ has an empty intersection.</p>&#...
complexity theory graphs approximation
1
Is maximum matching problem equivalent to maximum independent set problem in its dual graph? -- (complexity theory graphs approximation) <p>A hypergraph $H = (V,E)$ consists of a set $V = \{v_1, v_2, \cdots, v_n\}$ of vertices and a set $E = \{e_1, e_2, \cdots , e_m\}$ of edges, each being a subset of $V$. </p>&#xA;&#x...
habedi/stack-exchange-dataset
69,856
How can a Turing machine write the description of the n-th Turing machine?
<p>I am trying to interpret the following problem:</p>&#xA;&#xA;<p>"Describe an algorithm for a Turing machine which receives the integer n as&#xA;input and proceeds to write the description of the n-th Turing machine from&#xA;the standard enumeration on its tape."</p>&#xA;&#xA;<p>I am confused about how a Turing machi...
turing machines computation models
1
How can a Turing machine write the description of the n-th Turing machine? -- (turing machines computation models) <p>I am trying to interpret the following problem:</p>&#xA;&#xA;<p>"Describe an algorithm for a Turing machine which receives the integer n as&#xA;input and proceeds to write the description of the n-th Tu...
habedi/stack-exchange-dataset
69,859
Solve using master method $T(n) = n · T(n/2) + n^{\log n}$
<p>$T(n)=n\displaystyle \cdot T\left(\frac{n}{2}\right)+n^{\log_{2}n}$.</p>&#xA;&#xA;<p>$f(n) = n^{\log_{2}n}$</p>&#xA;&#xA;<p>Number of leaves = $n^{\log_{a}b} = n^{\log_{2}n}$</p>&#xA;&#xA;<p>CASE 2 (All level same)</p>&#xA;&#xA;<p>$f(n) = \Theta(n^{\log_{b}a} {\log^{k}n}) $</p>&#xA;&#xA;<p>$f(n) = \Theta(n^{\log_{2}...
algorithms complexity theory time complexity asymptotics
1
Solve using master method $T(n) = n · T(n/2) + n^{\log n}$ -- (algorithms complexity theory time complexity asymptotics) <p>$T(n)=n\displaystyle \cdot T\left(\frac{n}{2}\right)+n^{\log_{2}n}$.</p>&#xA;&#xA;<p>$f(n) = n^{\log_{2}n}$</p>&#xA;&#xA;<p>Number of leaves = $n^{\log_{a}b} = n^{\log_{2}n}$</p>&#xA;&#xA;<p>CASE ...
habedi/stack-exchange-dataset
69,863
Finding median of 2 sorted arrays in O(log n)
<p>If there are given two arrays, A and B, each containing n real numbers in sorted order. How to compute the median of all the numbers in A and B, in O(log n) time. I have to make an algorithm that takes at most logarithmic time.</p>&#xA;&#xA;<p>My idea:</p>&#xA;&#xA;<pre><code>A = 1, 3, 6, 8, 10, 15, 20&#xA;&#xA;B = ...
algorithms complexity theory time complexity
1
Finding median of 2 sorted arrays in O(log n) -- (algorithms complexity theory time complexity) <p>If there are given two arrays, A and B, each containing n real numbers in sorted order. How to compute the median of all the numbers in A and B, in O(log n) time. I have to make an algorithm that takes at most logarithmic...
habedi/stack-exchange-dataset
69,867
Is there a known algorithm for computing the n-th Turing machine directly?
<p>Let us define a Turing machine by a machine description that is a string of symbols produced by some numerical encoding. For example, a Turing machine $M_1$ can be represented by 9,900,599 ([0 0 halt], where halt = 5 and the start and end of an instruction is 99). A standard enumeration consists of all possible Turi...
algorithms turing machines computation models enumeration
1
Is there a known algorithm for computing the n-th Turing machine directly? -- (algorithms turing machines computation models enumeration) <p>Let us define a Turing machine by a machine description that is a string of symbols produced by some numerical encoding. For example, a Turing machine $M_1$ can be represented by ...
habedi/stack-exchange-dataset
69,872
Complexity of Block edit distance with Swapping only
<p>Suppose I have <strong>distinct</strong> letters in an alphabet $\sum = \{a_1,a_2,...,a_n\}$. I also have two permutations of these letters, let's call them $A,B$. How can I find the Edit distance between $A$ and $B$ with block edit operations allowed?</p>&#xA;&#xA;<p>To make it clearer, an example would be $\sum =\...
complexity theory time complexity strings string metrics edit distance
1
Complexity of Block edit distance with Swapping only -- (complexity theory time complexity strings string metrics edit distance) <p>Suppose I have <strong>distinct</strong> letters in an alphabet $\sum = \{a_1,a_2,...,a_n\}$. I also have two permutations of these letters, let's call them $A,B$. How can I find the Edit ...
habedi/stack-exchange-dataset
69,874
Finite languages are Turing decidable - contradiction
<p>Let's say that I define the language $L$ over the alphabet $\{0, 1\}$ to be a language containing only one word, $w$, where:</p>&#xA;&#xA;<p>$$ w = &#xA; \begin{cases} &#xA; 1 &amp; \text{if the continuum hypothesis is true}\\&#xA; 0 &amp; \text{otherwise.}&#xA; \end{cases}&#xA;$$</p>&#xA;&#xA;<p>$L$ is f...
formal languages turing machines finite automata undecidability finite sets
1
Finite languages are Turing decidable - contradiction -- (formal languages turing machines finite automata undecidability finite sets) <p>Let's say that I define the language $L$ over the alphabet $\{0, 1\}$ to be a language containing only one word, $w$, where:</p>&#xA;&#xA;<p>$$ w = &#xA; \begin{cases} &#xA; 1 &...
habedi/stack-exchange-dataset
69,882
In Lbest PSO, how is the local best position in a neighbourhood defined?
<p>I am implementing a couple of PSO (particle swarm optimization) algorithms, and I got stuck on a bit of detail which I could not clearly determine from the papers I have read. In lbest PSO, for each particle, the velocity update step takes the best particle's position in that particle's neighbourhood into account. W...
artificial intelligence
1
In Lbest PSO, how is the local best position in a neighbourhood defined? -- (artificial intelligence) <p>I am implementing a couple of PSO (particle swarm optimization) algorithms, and I got stuck on a bit of detail which I could not clearly determine from the papers I have read. In lbest PSO, for each particle, the ve...
habedi/stack-exchange-dataset
69,892
Worst known case for log rank conjecture
<p>The log rank conjecture states that there is some universal constant $c &gt; 0$ so that</p>&#xA;&#xA;<p>$$CC(f) = O(\log^c \text{rk}\,(M_f))$$</p>&#xA;&#xA;<p>where $f : X \times Y \to \{0, 1\}$ is a boolean function, $CC$ denotes the deterministic communication complexity, $M_f$ is the $|X| \times |Y|$ binary matri...
communication complexity
1
Worst known case for log rank conjecture -- (communication complexity) <p>The log rank conjecture states that there is some universal constant $c &gt; 0$ so that</p>&#xA;&#xA;<p>$$CC(f) = O(\log^c \text{rk}\,(M_f))$$</p>&#xA;&#xA;<p>where $f : X \times Y \to \{0, 1\}$ is a boolean function, $CC$ denotes the determinist...
habedi/stack-exchange-dataset
69,893
Need introductory guide to cellular automata for geographic automata systems
<p>I would like to work on urbanisation and I've read that cellular automata has potential use on model urban sprawl. However I need some kind of introductory to cellular automata in order to tackle an academic paper I have found.</p>&#xA;&#xA;<p>I have a fair background in Computer Science. Moreover I am looking for a...
automata applied theory cellular automata
1
Need introductory guide to cellular automata for geographic automata systems -- (automata applied theory cellular automata) <p>I would like to work on urbanisation and I've read that cellular automata has potential use on model urban sprawl. However I need some kind of introductory to cellular automata in order to tack...
habedi/stack-exchange-dataset
69,901
Why there is no FPTAS for multiple knapsack problem for two knapsacks unless P=NP?
<p>The multiple knapsack problem (MKP) is defined in <a href="http://repository.upenn.edu/cgi/viewcontent.cgi?article=1215&amp;context=cis_papers" rel="nofollow noreferrer">"A PTAS for the Multiple Knapsack Problem"</a> as:</p>&#xA;&#xA;<ul>&#xA;<li><em>Instance</em>: A pair $(B, S)$ where $B$ is a set of $m$ knapsacks...
algorithms reductions knapsack problems
1
Why there is no FPTAS for multiple knapsack problem for two knapsacks unless P=NP? -- (algorithms reductions knapsack problems) <p>The multiple knapsack problem (MKP) is defined in <a href="http://repository.upenn.edu/cgi/viewcontent.cgi?article=1215&amp;context=cis_papers" rel="nofollow noreferrer">"A PTAS for the Mul...
habedi/stack-exchange-dataset
69,902
Measuring and maintaining the diversity of individuals in Genetic Algorithm
<p>While I was using the Genetic Algorithm to generate full correct Sudoku grids starting from a population of random grids, I occasionally face the problem of the process being stuck on a local maxima until the population loses its diversity.</p>&#xA;&#xA;<p>So, I decided to find a mechanism for maintaining the divers...
genetic algorithms evolutionary computing
1
Measuring and maintaining the diversity of individuals in Genetic Algorithm -- (genetic algorithms evolutionary computing) <p>While I was using the Genetic Algorithm to generate full correct Sudoku grids starting from a population of random grids, I occasionally face the problem of the process being stuck on a local ma...
habedi/stack-exchange-dataset
69,909
Given language consisting Turing machines is decidable or not?
<p>$$L=\{M\mid \text{there exist }x,y\in\Sigma^* \text{ s.t. }x \in L(M)\text{ and } y \notin L(M)\}\,.$$</p>&#xA;&#xA;<p>I think it's not recursively enumerable because this language reduces to complement of the membership problem. $\langle M,w\rangle$ would be input where $y$ would become $w$ and $x$ belongs to $L(M)...
computability turing machines reductions undecidability semi decidability
1
Given language consisting Turing machines is decidable or not? -- (computability turing machines reductions undecidability semi decidability) <p>$$L=\{M\mid \text{there exist }x,y\in\Sigma^* \text{ s.t. }x \in L(M)\text{ and } y \notin L(M)\}\,.$$</p>&#xA;&#xA;<p>I think it's not recursively enumerable because this lan...
habedi/stack-exchange-dataset
69,910
How to solve this partial order reduction in $O(n^2)$?
<p>There are two orderings of numbers from the same set. Number $a$ is "immediately before" $b$ <strong>iff</strong> $a$ appears before $b$ in both sequences <strong>and</strong> there is no other number that appears between them in both sequences.</p>&#xA;&#xA;<p>So in this example:</p>&#xA;&#xA;<pre><code>Seq 1: 1 2 ...
algorithms partial order
1
How to solve this partial order reduction in $O(n^2)$? -- (algorithms partial order) <p>There are two orderings of numbers from the same set. Number $a$ is "immediately before" $b$ <strong>iff</strong> $a$ appears before $b$ in both sequences <strong>and</strong> there is no other number that appears between them in bo...
habedi/stack-exchange-dataset
69,924
Simplified big O notation of $O(nm)$ for $n\gg m$
<p>Assume $n$ is much greater than $m$. Would $O(nm)$ simplify to $O(n)$? Is there an explanation?</p>&#xA;
asymptotics
1
Simplified big O notation of $O(nm)$ for $n\gg m$ -- (asymptotics) <p>Assume $n$ is much greater than $m$. Would $O(nm)$ simplify to $O(n)$? Is there an explanation?</p>&#xA;
habedi/stack-exchange-dataset
69,928
Why do i have to show that a problem L $ \in $ NP before i start a polynomial reduction?
<p>i want to do a polynomial reduction from the Independent-Set-Problem which is NP-complete to the AUCTION-Problem, to show that AUCTION $\in$ NP-complete,&#xA;but why do i always have to show first, that our problem(in this case AUCTION) $ \in $ NP?</p>&#xA;
np complete np decision problem
1
Why do i have to show that a problem L $ \in $ NP before i start a polynomial reduction? -- (np complete np decision problem) <p>i want to do a polynomial reduction from the Independent-Set-Problem which is NP-complete to the AUCTION-Problem, to show that AUCTION $\in$ NP-complete,&#xA;but why do i always have to show ...
habedi/stack-exchange-dataset
69,936
Why are some games np-complete?
<p>I read the Wikipedia entry about "<a href="https://en.wikipedia.org/wiki/List_of_NP-complete_problems">List of NP-complete problems</a>" and found that games like super mario, pokemon, tetris or candy crush saga are np-complete. How can I imagine np-completeness of a game? Answers don't need to be too precise. I ju...
complexity theory np complete computer games
1
Why are some games np-complete? -- (complexity theory np complete computer games) <p>I read the Wikipedia entry about "<a href="https://en.wikipedia.org/wiki/List_of_NP-complete_problems">List of NP-complete problems</a>" and found that games like super mario, pokemon, tetris or candy crush saga are np-complete. How ca...
habedi/stack-exchange-dataset
69,937
Examples of Context-sensitive grammars which produces non-indexed language
<p>Well known <a href="https://en.wikipedia.org/wiki/Context-sensitive_grammar#Examples" rel="nofollow noreferrer">example of Context-sensitive grammar</a> which produces language <span class="math-container">$\{a^nb^nc^n|n\geq 1\}$</span> is widely used in various papers. But actually, while this language is definitel...
formal languages formal grammars context sensitive
1
Examples of Context-sensitive grammars which produces non-indexed language -- (formal languages formal grammars context sensitive) <p>Well known <a href="https://en.wikipedia.org/wiki/Context-sensitive_grammar#Examples" rel="nofollow noreferrer">example of Context-sensitive grammar</a> which produces language <span cla...
habedi/stack-exchange-dataset
69,943
Why does this pumping lemma proof not cover every division of xyz?
<p>I am trying to prove $L =$ {${a^k|k=2^n, n \ge 0}$} is not regular. &#xA;So far I have identifed a string $s = a^{2^p}$, and I've divided $s$ into $xyz$ as follows:</p>&#xA;&#xA;<p>$x = a^l$</p>&#xA;&#xA;<p>$y = a^k$</p>&#xA;&#xA;<p>*(where $k + l \le p$)</p>&#xA;&#xA;<p>$z = a^{2^p-l-k}$</p>&#xA;&#xA;<p>Now, when I...
regular languages pumping lemma
1
Why does this pumping lemma proof not cover every division of xyz? -- (regular languages pumping lemma) <p>I am trying to prove $L =$ {${a^k|k=2^n, n \ge 0}$} is not regular. &#xA;So far I have identifed a string $s = a^{2^p}$, and I've divided $s$ into $xyz$ as follows:</p>&#xA;&#xA;<p>$x = a^l$</p>&#xA;&#xA;<p>$y = a...
habedi/stack-exchange-dataset
69,948
Is it Possible to Get Maximum Weighted Input Value in a Neural Network?
<p>Let's say that I have a standard feedforward neural network which has $M$ inputs, some number of hidden layers $N$, and a single neuron in the output.</p>&#xA;&#xA;<p>Is it possible to construct a network such that the output neuron's output value is the maximum weighted input value?</p>&#xA;&#xA;<p>I know that I co...
neural networks neural computing
1
Is it Possible to Get Maximum Weighted Input Value in a Neural Network? -- (neural networks neural computing) <p>Let's say that I have a standard feedforward neural network which has $M$ inputs, some number of hidden layers $N$, and a single neuron in the output.</p>&#xA;&#xA;<p>Is it possible to construct a network su...
habedi/stack-exchange-dataset
69,951
What is the generating function for the sequence $\{kH_k\}_{k \geq 1}$
<p>I am trying to answer exercise 3.1 from Sedgewick and Flajolet's "Introduction to the Analysis of Algorithms". That is, I am trying to find the Ordinary Generating Function for the sequence:</p>&#xA;&#xA;<p>$$\{kH_k\}_{k \geq 1}$$</p>&#xA;&#xA;<p>I think that the generating function for this sequence is:</p>&#xA;&#...
algorithm analysis
1
What is the generating function for the sequence $\{kH_k\}_{k \geq 1}$ -- (algorithm analysis) <p>I am trying to answer exercise 3.1 from Sedgewick and Flajolet's "Introduction to the Analysis of Algorithms". That is, I am trying to find the Ordinary Generating Function for the sequence:</p>&#xA;&#xA;<p>$$\{kH_k\}_{k ...
habedi/stack-exchange-dataset
69,953
forall a b, a -> b
<p>I know for pretty sure that there is a function with the type $f: \forall \alpha, \beta . \alpha \rightarrow \beta$ (at least in a Hindley-Milner type system), but I can't wrap my head over it. <s>Neither could I think of an actual function with this type.</s></p>&#xA;&#xA;<p>I found a function of this type, which i...
type theory curry howard
1
forall a b, a -> b -- (type theory curry howard) <p>I know for pretty sure that there is a function with the type $f: \forall \alpha, \beta . \alpha \rightarrow \beta$ (at least in a Hindley-Milner type system), but I can't wrap my head over it. <s>Neither could I think of an actual function with this type.</s></p>&#xA...
habedi/stack-exchange-dataset
69,967
Does computability according to Church-Turing thesis include side effects?
<p>To my understanding: </p>&#xA;&#xA;<ul>&#xA;<li>The Church-Turing thesis means that one could theoretically compute anything that can be computed using either a Turing Machine or the Lambda Calculus. </li>&#xA;<li>The Lambda Calculus is based on mathematical functions. This leads to the inability of "pure" function...
computability turing machines church turing thesis
1
Does computability according to Church-Turing thesis include side effects? -- (computability turing machines church turing thesis) <p>To my understanding: </p>&#xA;&#xA;<ul>&#xA;<li>The Church-Turing thesis means that one could theoretically compute anything that can be computed using either a Turing Machine or the Lam...
habedi/stack-exchange-dataset
69,976
Prove the following language is in L (LogSpace)
<p>I'm trying to prove the following language is in $L$ (decided by a TM in $O(\log n)$ space):</p>&#xA;&#xA;<p>$$A = \{ (C,x) \mid C(x)=1\text{ and $C$ is a Boolean formula with depth }\log(n)\}\,,$$&#xA;where $n = |(C,x)|$. Equivalently, $C$ can be a Boolean circuit with maximum fan-out of&nbsp;$1$.)</p>&#xA;&#xA;<p...
complexity theory complexity classes space complexity
1
Prove the following language is in L (LogSpace) -- (complexity theory complexity classes space complexity) <p>I'm trying to prove the following language is in $L$ (decided by a TM in $O(\log n)$ space):</p>&#xA;&#xA;<p>$$A = \{ (C,x) \mid C(x)=1\text{ and $C$ is a Boolean formula with depth }\log(n)\}\,,$$&#xA;where $...
habedi/stack-exchange-dataset
69,980
A new definition of recursively enumerable set?
<p>Given a Turing machine $M$, we associate a partial function $f_M : \Sigma^{\ast} \to \Sigma^{\ast}$ to it (this is called the function computed by the machine), where $\Sigma$ denotes the finite input and output alphabet, defined as&#xA;$$&#xA; f(u) = v :\Leftrightarrow \mbox{The machine halts on input $u$ with outp...
computability turing machines terminology
1
A new definition of recursively enumerable set? -- (computability turing machines terminology) <p>Given a Turing machine $M$, we associate a partial function $f_M : \Sigma^{\ast} \to \Sigma^{\ast}$ to it (this is called the function computed by the machine), where $\Sigma$ denotes the finite input and output alphabet, ...
habedi/stack-exchange-dataset
69,987
Difference between $\beta$-contracts and $\beta$-reduces in Hindley
<p>I brought the book <em>Lambda-Calculus and Combinators: An Introduction</em> by J. Roger Hindley and the author explains what is $\beta$-reduction. </p>&#xA;&#xA;<p>Now there is a difference between $\beta$-contracts and $\beta$-reduces:&#xA;$$&#xA;\begin{align*}&#xA;P &amp;\rhd_{1\beta} P^\prime\\&#xA;P &amp;\rhd_{...
lambda calculus
1
Difference between $\beta$-contracts and $\beta$-reduces in Hindley -- (lambda calculus) <p>I brought the book <em>Lambda-Calculus and Combinators: An Introduction</em> by J. Roger Hindley and the author explains what is $\beta$-reduction. </p>&#xA;&#xA;<p>Now there is a difference between $\beta$-contracts and $\beta$...
habedi/stack-exchange-dataset
69,992
Number Partitioning targeting a Ratio of subset sums?
<p>I have a problem, which appears to be similar to <a href="https://en.wikipedia.org/wiki/Partition_problem" rel="nofollow noreferrer">number partitioning</a>:&#xA;a set of numbers partitioned (two-way), such that the sum of the numbers in each subset are as close as possible to a targeted ratio (instead of having the...
process scheduling
1
Number Partitioning targeting a Ratio of subset sums? -- (process scheduling) <p>I have a problem, which appears to be similar to <a href="https://en.wikipedia.org/wiki/Partition_problem" rel="nofollow noreferrer">number partitioning</a>:&#xA;a set of numbers partitioned (two-way), such that the sum of the numbers in e...
habedi/stack-exchange-dataset
69,994
Linear Regression. Why do we take sum of errors to compute the cost?
<p>While calculating the cost in linear regression (for either with multiple features or a single one using gradient descent) we compute the cost by squaring and summing up the cost related to each training set. What is the point of summing up the cost related to each training example is what I do not understand.&#xA;W...
algorithms machine learning
1
Linear Regression. Why do we take sum of errors to compute the cost? -- (algorithms machine learning) <p>While calculating the cost in linear regression (for either with multiple features or a single one using gradient descent) we compute the cost by squaring and summing up the cost related to each training set. What i...
habedi/stack-exchange-dataset
70,003
NFA to DFA accepting states
<p>I was working through an NFA to DFA conversion tutorial: where I'm converting the following NFA to a DFA:<br>&#xA;<a href="https://i.stack.imgur.com/H26SG.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/H26SG.jpg" alt="NFA to a DFA:"></a><br>&#xA;I used lazy subset construction which I'm sure the ...
finite automata
1
NFA to DFA accepting states -- (finite automata) <p>I was working through an NFA to DFA conversion tutorial: where I'm converting the following NFA to a DFA:<br>&#xA;<a href="https://i.stack.imgur.com/H26SG.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/H26SG.jpg" alt="NFA to a DFA:"></a><br>&#xA;I ...
habedi/stack-exchange-dataset
70,006
The content of an implication from the snm-Theorem
<p>I have a question on the <a href="http://mathworld.wolfram.com/Kleeness-m-nTheorem.html" rel="noreferrer">statement of the s-m-n Theorem</a> and the implication&#xA;$$ &#xA; \varphi_{f(x,y)} = \lambda z \varphi_x(\varphi_y(z))&#xA;$$&#xA;for some recursive function $f(x,y)$ cited in the above link. In what sense doe...
formal languages computability turing machines
1
The content of an implication from the snm-Theorem -- (formal languages computability turing machines) <p>I have a question on the <a href="http://mathworld.wolfram.com/Kleeness-m-nTheorem.html" rel="noreferrer">statement of the s-m-n Theorem</a> and the implication&#xA;$$ &#xA; \varphi_{f(x,y)} = \lambda z \varphi_x(\...
habedi/stack-exchange-dataset
70,008
What makes data flow analysis higher level than control flow analysis?
<p>I feel understanding why data flow is higher level than control flow is key to writing good code (and convincing others during code reviews). I find this repeatedly when arguing why my functional style programming with immutability is superior to their mutable state code which is more common and expected.</p>&#xA;&#...
lambda calculus functional programming programming paradigms data flow analysis
1
What makes data flow analysis higher level than control flow analysis? -- (lambda calculus functional programming programming paradigms data flow analysis) <p>I feel understanding why data flow is higher level than control flow is key to writing good code (and convincing others during code reviews). I find this repeate...
habedi/stack-exchange-dataset
70,009
What is the Pumping Lemma a lemma to?
<p>This is something I couldn't find - but I always found it interesting that the pumping lemma is just a lemma (especially since it has the same name for regular languages, context free languages, etc...)</p>&#xA;&#xA;<p>What is it a lemma to?</p>&#xA;
complexity theory regular languages finite automata
1
What is the Pumping Lemma a lemma to? -- (complexity theory regular languages finite automata) <p>This is something I couldn't find - but I always found it interesting that the pumping lemma is just a lemma (especially since it has the same name for regular languages, context free languages, etc...)</p>&#xA;&#xA;<p>Wha...
habedi/stack-exchange-dataset
70,029
Using Big $O,\Omega,\Theta$, how would you represent these equations?
<p>How would you write the following equations in $O,\Omega,\Theta$ notation?&#xA;$$&#xA;\begin{align*}&#xA;t(n) &amp;= 4n^4 + 3n^5 + 3n^6 \\&#xA;g(n) &amp;= 2n^6 + 5\log n \\&#xA;f(n) &amp;= 50n^5&#xA;\end{align*}&#xA;$$</p>&#xA;
algorithm analysis asymptotics
1
Using Big $O,\Omega,\Theta$, how would you represent these equations? -- (algorithm analysis asymptotics) <p>How would you write the following equations in $O,\Omega,\Theta$ notation?&#xA;$$&#xA;\begin{align*}&#xA;t(n) &amp;= 4n^4 + 3n^5 + 3n^6 \\&#xA;g(n) &amp;= 2n^6 + 5\log n \\&#xA;f(n) &amp;= 50n^5&#xA;\end{align*...
habedi/stack-exchange-dataset
70,044
Program Correctness, The specification
<p>From Wikipedia: In theoretical computer science, correctness of an algorithm is asserted when it is said that the algorithm is correct with respect to a specification.</p>&#xA;&#xA;<p>But the problem is that to get the "appropriate" specification is not a trivial task, and there is no 100% correct method (as far as ...
formal methods software verification program correctness
1
Program Correctness, The specification -- (formal methods software verification program correctness) <p>From Wikipedia: In theoretical computer science, correctness of an algorithm is asserted when it is said that the algorithm is correct with respect to a specification.</p>&#xA;&#xA;<p>But the problem is that to get t...
habedi/stack-exchange-dataset
70,045
How could I prove that $B$ reduces to $A$ in polynomial time in this case?
<p>Let $A$ be a decision problem with at least one yes instance and at least one no instance. Also let $B \in \textbf{P}$. How could I prove that B reduces to A in polynomial time?</p>&#xA;&#xA;<p>Thanks in advance.</p>&#xA;
complexity theory reductions decision problem polynomial time
1
How could I prove that $B$ reduces to $A$ in polynomial time in this case? -- (complexity theory reductions decision problem polynomial time) <p>Let $A$ be a decision problem with at least one yes instance and at least one no instance. Also let $B \in \textbf{P}$. How could I prove that B reduces to A in polynomial tim...
habedi/stack-exchange-dataset
70,046
Bounded Integer Edge Weights, Dijkstra's Algorithm
<p>I'm trying to understand how we can get the time complexity of Dijkstra's Algorithm down from O(V²) (for a matrix-implemented Dijkstra's) to O(V) if the edge weights of our graph are bounded by a constant C. I've read up on <a href="https://courses.csail.mit.edu/6.006/spring11/rec/rec16.pdf" rel="nofollow noreferrer...
graphs graph traversal weighted graphs
1
Bounded Integer Edge Weights, Dijkstra's Algorithm -- (graphs graph traversal weighted graphs) <p>I'm trying to understand how we can get the time complexity of Dijkstra's Algorithm down from O(V²) (for a matrix-implemented Dijkstra's) to O(V) if the edge weights of our graph are bounded by a constant C. I've read up o...
habedi/stack-exchange-dataset
70,050
Karp reduction from PARTITION to SUBSET SUM
<p>PARTITION: Given a set of positive integers $A=\{a_1,...,a_n\}$ does there exist a subset of $A$ with sum equal to the sum of it's complement?</p>&#xA;&#xA;<p>SUBSET SUM: Given a set of positive integers $A=\{a_1,...,a_n\}$ and another positive integer $B$, does there exist a subset of $A$ such that it's sum is equa...
complexity theory np complete reductions
1
Karp reduction from PARTITION to SUBSET SUM -- (complexity theory np complete reductions) <p>PARTITION: Given a set of positive integers $A=\{a_1,...,a_n\}$ does there exist a subset of $A$ with sum equal to the sum of it's complement?</p>&#xA;&#xA;<p>SUBSET SUM: Given a set of positive integers $A=\{a_1,...,a_n\}$ and...
habedi/stack-exchange-dataset
70,060
Can a regular language enforce a length limit AND disallow consecutive characters?
<p>I was reading the venerable <a href="http://www.regular-expressions.info/email.html" rel="nofollow noreferrer">"How to Find or Validate an Email Address [using Regex]"</a>, and I came across the following statement at the bottom of the page:</p>&#xA;&#xA;<blockquote>&#xA; <p>[A] true regular language cannot enforce...
computability regular languages finite automata regular expressions
1
Can a regular language enforce a length limit AND disallow consecutive characters? -- (computability regular languages finite automata regular expressions) <p>I was reading the venerable <a href="http://www.regular-expressions.info/email.html" rel="nofollow noreferrer">"How to Find or Validate an Email Address [using R...
habedi/stack-exchange-dataset
70,061
Meaning of ε in NFA-ε?
<p>In <a href="https://en.wikipedia.org/wiki/Nondeterministic_finite_automaton" rel="nofollow noreferrer">wikipedia</a> NFA-ε transition function defined as follows $Δ : Q × (Σ ∪ \{ε\}) → P(Q)$, where $Σ$ is an alphabet and $ε$ - empty <strong>string</strong>. I don't understand the meaning of $ε$ in this context.</p>&...
automata finite automata computation models
1
Meaning of ε in NFA-ε? -- (automata finite automata computation models) <p>In <a href="https://en.wikipedia.org/wiki/Nondeterministic_finite_automaton" rel="nofollow noreferrer">wikipedia</a> NFA-ε transition function defined as follows $Δ : Q × (Σ ∪ \{ε\}) → P(Q)$, where $Σ$ is an alphabet and $ε$ - empty <strong>stri...
habedi/stack-exchange-dataset
70,068
Expressing division in relational algebra in terms of other operations
<p>So, I've been conferred upon the opinion that:</p>&#xA;&#xA;<blockquote>&#xA; <p>Union, difference, cross product, selection, projection form the "complete set of relational operations".&#xA; That is, any other relational operation can be expressed as a combination of these (excluding domain manipulation operation...
relational algebra
1
Expressing division in relational algebra in terms of other operations -- (relational algebra) <p>So, I've been conferred upon the opinion that:</p>&#xA;&#xA;<blockquote>&#xA; <p>Union, difference, cross product, selection, projection form the "complete set of relational operations".&#xA; That is, any other relationa...
habedi/stack-exchange-dataset
70,076
Decidability of languages containing bitstrings and their corresponding ones' complements
<p>Consider strings $s \in \{0,1\}^*$. Define $c_1(s)$ to be the ones' complement of $s$; i.e., the string obtained from $s$ by inverting all of its bits. So, for example, $c_1(000111) = 111000$. Call a language $L \subset \{0,1\}^*$ <em>ones' complement closed</em>, or OCC, if $s' \in L$ $\iff$ $c_1(s') \in L$, provid...
formal languages turing machines undecidability
1
Decidability of languages containing bitstrings and their corresponding ones' complements -- (formal languages turing machines undecidability) <p>Consider strings $s \in \{0,1\}^*$. Define $c_1(s)$ to be the ones' complement of $s$; i.e., the string obtained from $s$ by inverting all of its bits. So, for example, $c_1(...
habedi/stack-exchange-dataset
70,083
Can I have actions that, if taken, cannot be taken again in the following N timesteps?
<p>I'm trying to train a load-balancing system with reinforcement-learning (RL) s.t. the incoming jobs are queued evenly at the available servers.&#xA;The system will not be able to directly dispatch the jobs, but it will only offer suggestions to use a set of servers over another.&#xA;The system will also be capable o...
reinforcement learning
1
Can I have actions that, if taken, cannot be taken again in the following N timesteps? -- (reinforcement learning) <p>I'm trying to train a load-balancing system with reinforcement-learning (RL) s.t. the incoming jobs are queued evenly at the available servers.&#xA;The system will not be able to directly dispatch the j...
habedi/stack-exchange-dataset
70,094
Pumping Lemma: 1^n^2 is not regular
<p>I am attempting to prove via the pumping lemma that $1^{n^2}$ is not a regular language. I started with </p>&#xA;&#xA;<p>$w = 1^{p^2}$</p>&#xA;&#xA;<p>I then divided $w$ into $xyz$, where:</p>&#xA;&#xA;<p>$x = 1^{l}$</p>&#xA;&#xA;<p>$y = 1^{m}$</p>&#xA;&#xA;<p>$z = 1^{{p^2}-l-m}$, where $l+m \le p$ and $m \ge 0$.</p...
proof techniques pumping lemma
1
Pumping Lemma: 1^n^2 is not regular -- (proof techniques pumping lemma) <p>I am attempting to prove via the pumping lemma that $1^{n^2}$ is not a regular language. I started with </p>&#xA;&#xA;<p>$w = 1^{p^2}$</p>&#xA;&#xA;<p>I then divided $w$ into $xyz$, where:</p>&#xA;&#xA;<p>$x = 1^{l}$</p>&#xA;&#xA;<p>$y = 1^{m}$<...
habedi/stack-exchange-dataset
70,095
DFA - Accept all strings that does not contain a certain substring
<p>So I have been trying to create a Deterministic Finite Automaton(DFA) in Jflap that accepts all strings from the alphabet {a, b, c} except those that contain the substring &quot;abc&quot;. However i keep running into issues where certain strings that should be allowed aren't, such as &quot;acbc&quot;. Do you have an...
automata finite automata substrings
1
DFA - Accept all strings that does not contain a certain substring -- (automata finite automata substrings) <p>So I have been trying to create a Deterministic Finite Automaton(DFA) in Jflap that accepts all strings from the alphabet {a, b, c} except those that contain the substring &quot;abc&quot;. However i keep runni...
habedi/stack-exchange-dataset
70,098
Ehrenfeucht-Fraïssé games, possible mistake in example
<p>I was reading up on Ehrenfeucht-Fraïssé and came by this example at <a href="http://www.math.cornell.edu/~mec/Summer2009/Raluca/lesson3.html" rel="nofollow noreferrer">http://www.math.cornell.edu/~mec/Summer2009/Raluca/lesson3.html</a></p>&#xA;&#xA;<p><a href="https://i.stack.imgur.com/0wmpe.png" rel="nofollow noref...
first order logic
1
Ehrenfeucht-Fraïssé games, possible mistake in example -- (first order logic) <p>I was reading up on Ehrenfeucht-Fraïssé and came by this example at <a href="http://www.math.cornell.edu/~mec/Summer2009/Raluca/lesson3.html" rel="nofollow noreferrer">http://www.math.cornell.edu/~mec/Summer2009/Raluca/lesson3.html</a></p>...
habedi/stack-exchange-dataset
70,101
Tight instance for unweighted maximum coverage problem?
<p>The <a href="https://en.wikipedia.org/wiki/Maximum_coverage_problem" rel="nofollow noreferrer">maximum (unweighted) coverage problem</a> is defined as follows:</p>&#xA;&#xA;<ul>&#xA;<li><strong>Instance</strong>: A number $k$ and a collection of sets $S = \{S_1, S_2, \ldots, S_m\}$.</li>&#xA;<li><strong>Objective</s...
algorithms reductions
1
Tight instance for unweighted maximum coverage problem? -- (algorithms reductions) <p>The <a href="https://en.wikipedia.org/wiki/Maximum_coverage_problem" rel="nofollow noreferrer">maximum (unweighted) coverage problem</a> is defined as follows:</p>&#xA;&#xA;<ul>&#xA;<li><strong>Instance</strong>: A number $k$ and a co...
habedi/stack-exchange-dataset
70,106
Sort complexity expressed via distinct number of elements
<p>I am reading <a href="http://algo.inria.fr/flajolet/Publications/FlMa85.pdf" rel="nofollow noreferrer">Probabilistic counting algorithms for database applications</a>. In the introduction an algorithm for finding an intersection is specified:</p>&#xA;&#xA;<p>Sort A, search each element of B in A and retain it if it ...
algorithms complexity theory sets
1
Sort complexity expressed via distinct number of elements -- (algorithms complexity theory sets) <p>I am reading <a href="http://algo.inria.fr/flajolet/Publications/FlMa85.pdf" rel="nofollow noreferrer">Probabilistic counting algorithms for database applications</a>. In the introduction an algorithm for finding an inte...
habedi/stack-exchange-dataset
70,109
Algorithm for getting symetric vertex sets of undirected graph
<p>For my application problem, I am searching for <strong>an algorithm that can find all symmetric vertex sets of an undirected labeled graph.</strong></p>&#xA;&#xA;<p>My definition of symmetric vertex set is:&#xA;Let $G$ be a graph with vertex set $V$ and edge set $E = \{u,v\}, u,v \in V$. If $S \subseteq V$ and there...
graphs graph isomorphism transitivity
1
Algorithm for getting symetric vertex sets of undirected graph -- (graphs graph isomorphism transitivity) <p>For my application problem, I am searching for <strong>an algorithm that can find all symmetric vertex sets of an undirected labeled graph.</strong></p>&#xA;&#xA;<p>My definition of symmetric vertex set is:&#xA;...
habedi/stack-exchange-dataset
70,112
Decidability of checking whether all words accepted by a TM have an even number of 1s
<p>Let $\Sigma = \{0,1\}$, and consider the language&#xA;$$L = \{\langle M \rangle \mid &#xA;M \text{ is a TM and } L(M) \text{ is a subset of } Σ^* \text{ and all strings in this set have an even number of 1s}\}.$$</p>&#xA;&#xA;<p>I think $L$ is undecidable. But I am stuck on proving it. I think it is equivalent to pr...
turing machines undecidability
1
Decidability of checking whether all words accepted by a TM have an even number of 1s -- (turing machines undecidability) <p>Let $\Sigma = \{0,1\}$, and consider the language&#xA;$$L = \{\langle M \rangle \mid &#xA;M \text{ is a TM and } L(M) \text{ is a subset of } Σ^* \text{ and all strings in this set have an even n...
habedi/stack-exchange-dataset
70,113
Petri Net Verifier
<p>Imagine I can specify a certain process as a Petri Net. Is there any good software, open source or not, that can verify my process against some conditions I declare (or code) in some language?</p>&#xA;&#xA;<p>In case not, is there an open source software that does at least simulations?</p>&#xA;
software verification petri nets
1
Petri Net Verifier -- (software verification petri nets) <p>Imagine I can specify a certain process as a Petri Net. Is there any good software, open source or not, that can verify my process against some conditions I declare (or code) in some language?</p>&#xA;&#xA;<p>In case not, is there an open source software that ...
habedi/stack-exchange-dataset
70,118
Construct DFA accepting strings ending with '110' or '101'
<p>Let the alphabet be $\Sigma=\{0,1\}$. I want to construct a DFA which accepts strings ending with either '110' or '101', additionally there should be only one final state.</p>&#xA;&#xA;<p>I have a solution with more than one final state, but cannot come up with a solution which has only one final state.</p>&#xA;
automata finite automata
1
Construct DFA accepting strings ending with '110' or '101' -- (automata finite automata) <p>Let the alphabet be $\Sigma=\{0,1\}$. I want to construct a DFA which accepts strings ending with either '110' or '101', additionally there should be only one final state.</p>&#xA;&#xA;<p>I have a solution with more than one fin...
habedi/stack-exchange-dataset
70,120
Are registers stack, per core or per application based?
<p>I am doing a study on I found on youtube called OpenSecurityTraining: Introductory Intel x86. From what I understand there are registers like EAX, ECD, EDX, ect... and each have a purpose and hold/move information in memory.</p>&#xA;&#xA;<p>Are these registers per stack/application? Meaning, each application will ha...
memory management stacks
1
Are registers stack, per core or per application based? -- (memory management stacks) <p>I am doing a study on I found on youtube called OpenSecurityTraining: Introductory Intel x86. From what I understand there are registers like EAX, ECD, EDX, ect... and each have a purpose and hold/move information in memory.</p>&#x...
habedi/stack-exchange-dataset
70,125
Why are most mutex implementations unfair?
<p>My understanding is that most popular implementations of a mutex (e.g. std::mutex in C++) do not guarantee <em>fairness</em> -- that is, they <a href="https://stackoverflow.com/questions/9046746/do-mutex-locks-happen-in-the-same-order-they-are-asked">do not guarantee</a> that in instances of contention, the lock wil...
concurrency synchronization threads
1
Why are most mutex implementations unfair? -- (concurrency synchronization threads) <p>My understanding is that most popular implementations of a mutex (e.g. std::mutex in C++) do not guarantee <em>fairness</em> -- that is, they <a href="https://stackoverflow.com/questions/9046746/do-mutex-locks-happen-in-the-same-orde...
habedi/stack-exchange-dataset
70,126
Size of constant depth circuit for digital comparator?
<blockquote>&#xA; <p>Is a lower bound of $\Omega(n^2)$ known for the size of any constant depth circuit expressing a digital comparator for two $n$-bit numbers?</p>&#xA;</blockquote>&#xA;&#xA;<p>Two $n$-bit binary numbers can be compared using a <a href="https://en.wikipedia.org/wiki/Digital_comparator" rel="noreferre...
lower bounds circuits digital circuits
1
Size of constant depth circuit for digital comparator? -- (lower bounds circuits digital circuits) <blockquote>&#xA; <p>Is a lower bound of $\Omega(n^2)$ known for the size of any constant depth circuit expressing a digital comparator for two $n$-bit numbers?</p>&#xA;</blockquote>&#xA;&#xA;<p>Two $n$-bit binary number...
habedi/stack-exchange-dataset
70,129
What is the complexity for the universality problem for a NFA with all states accepting?
<p>It is well known that the universality problem for NFA (deciding whether $L(A)=\Sigma^*$) is $PSPACE$-complete. However, what if every state of the NFA is known to be accepting? It seems to me that the problem is at most in $co$-$NP$, as a counterexample (unlike in the case of a general NFA) is polynomial (even line...
complexity theory regular languages finite automata
1
What is the complexity for the universality problem for a NFA with all states accepting? -- (complexity theory regular languages finite automata) <p>It is well known that the universality problem for NFA (deciding whether $L(A)=\Sigma^*$) is $PSPACE$-complete. However, what if every state of the NFA is known to be acce...
habedi/stack-exchange-dataset
70,133
DFS algorithm and how do I show/put it into practice?
<p>I'm new to DFS algorithm and I'm trying to figure it out.</p>&#xA;&#xA;<p>The main concepts I get from it is that you have a stack of nodes, and they have a value, and can contain children-nodes (Even called branches or leaves) that can contains nodes with values.</p>&#xA;&#xA;<p>So let's say that I have a Tree cont...
algorithms
1
DFS algorithm and how do I show/put it into practice? -- (algorithms) <p>I'm new to DFS algorithm and I'm trying to figure it out.</p>&#xA;&#xA;<p>The main concepts I get from it is that you have a stack of nodes, and they have a value, and can contain children-nodes (Even called branches or leaves) that can contains n...
habedi/stack-exchange-dataset
70,134
Why is it that any graph traversal method can be described as pre-order, in-order, or post-order? What do those terms mean?
<p>There are several graph traversal algorithms in computer science ( vis. depth first, breadth first, etc. ). Furthermore, each of these algorithms can be implemented in pre-order, in-order, and post-order.</p>&#xA;&#xA;<p>What do those terms mean? How do I properly categorize an algorithm as pre-order, in-order, or p...
trees search trees graph traversal order theory
1
Why is it that any graph traversal method can be described as pre-order, in-order, or post-order? What do those terms mean? -- (trees search trees graph traversal order theory) <p>There are several graph traversal algorithms in computer science ( vis. depth first, breadth first, etc. ). Furthermore, each of these algor...
habedi/stack-exchange-dataset
70,140
Minimum difference between two subsets of an array of integers
<h2>The Problem</h2>&#xA;&#xA;<p>Suppose we have an array A[1...n] of integers, with values ranging from 0 to K (so 0&lt;=A[i]&lt;=K for each i). We need to describe an algorithm to find an (X,Y) partition from the set {1,2,...,n} such that |Sx-Sy| is minimum, where Sx and Sy are the sums of the elements in X and Y. i....
algorithms dynamic programming greedy algorithms
1
Minimum difference between two subsets of an array of integers -- (algorithms dynamic programming greedy algorithms) <h2>The Problem</h2>&#xA;&#xA;<p>Suppose we have an array A[1...n] of integers, with values ranging from 0 to K (so 0&lt;=A[i]&lt;=K for each i). We need to describe an algorithm to find an (X,Y) partiti...
habedi/stack-exchange-dataset
70,142
Proof of correctness of algorithm to determine whether the elements of an array are repeated an equal number of times
<p>I apologize for the long title, but I really didn't know how to write it different without lacking informations about the content.</p>&#xA;&#xA;<p>I recently had an university exam about Parallel Algorithms. One exercise asked me to write an algorithm to determine if the elements of an array, let's call it <code>A</...
algorithms algorithm analysis correctness proof
1
Proof of correctness of algorithm to determine whether the elements of an array are repeated an equal number of times -- (algorithms algorithm analysis correctness proof) <p>I apologize for the long title, but I really didn't know how to write it different without lacking informations about the content.</p>&#xA;&#xA;<p...
habedi/stack-exchange-dataset
70,148
Solving for the minimum cost, colored, set cover
<h2>Formulation</h2>&#xA;<p>This problem has four entities:</p>&#xA;<ul>&#xA;<li>A universe: <span class="math-container">$U = \{1, 2, ..., n\} $</span> of <span class="math-container">$n$</span> elements, indexed with <span class="math-container">$u$</span></li>&#xA;<li>A set of available colors: <span class="math-con...
complexity theory graphs optimization integer programming
1
Solving for the minimum cost, colored, set cover -- (complexity theory graphs optimization integer programming) <h2>Formulation</h2>&#xA;<p>This problem has four entities:</p>&#xA;<ul>&#xA;<li>A universe: <span class="math-container">$U = \{1, 2, ..., n\} $</span> of <span class="math-container">$n$</span> elements, in...
habedi/stack-exchange-dataset
70,160
Why is a set of attributes X not a key if X → Y holds but there exists a strict subset V of X where V → Y?
<p>Apologies if I butchered the question, I wasn't quite sure how to word it.</p>&#xA;&#xA;<p>In the Ramakrishnan text (2nd edition) on page 423 (in the section on functional dependencies) this statement is made:</p>&#xA;&#xA;<blockquote>&#xA; <p>If $X \rightarrow Y$ holds, where [$X$ is the set of key attributes and]...
database theory
1
Why is a set of attributes X not a key if X → Y holds but there exists a strict subset V of X where V → Y? -- (database theory) <p>Apologies if I butchered the question, I wasn't quite sure how to word it.</p>&#xA;&#xA;<p>In the Ramakrishnan text (2nd edition) on page 423 (in the section on functional dependencies) thi...
habedi/stack-exchange-dataset
70,162
What does distinct mean in terms of an array?
<p>I've tried searching this up, but from my what I think it is. It means there are no duplicate elements (ie. all elements are unique elements)?</p>&#xA;
terminology arrays
1
What does distinct mean in terms of an array? -- (terminology arrays) <p>I've tried searching this up, but from my what I think it is. It means there are no duplicate elements (ie. all elements are unique elements)?</p>&#xA;
habedi/stack-exchange-dataset
70,166
Balanced Binary Tree
<p>Can someone please explain to me how the Wikipedia <a href="https://en.wikipedia.org/wiki/Binary_tree#cite_note-22#Types_of_binary_trees" rel="nofollow noreferrer">example</a> on the left for a balanced binary tree is correct?</p>&#xA;&#xA;<blockquote>&#xA; <p>One common balanced tree structure is a binary tree str...
binary trees
1
Balanced Binary Tree -- (binary trees) <p>Can someone please explain to me how the Wikipedia <a href="https://en.wikipedia.org/wiki/Binary_tree#cite_note-22#Types_of_binary_trees" rel="nofollow noreferrer">example</a> on the left for a balanced binary tree is correct?</p>&#xA;&#xA;<blockquote>&#xA; <p>One common balan...
habedi/stack-exchange-dataset
70,171
Why graph planarity is important
<p>What is the reason to study planar graphs and algorithms on such graphs (as well as algorithms allowing to check a graph's planarity)? Where in industry this knowlege is needed?&#xA;I know that planarity arises in microchip design ("wires" intersection). I also found the following excerpt from a lecture notes:</p>&#...
graphs planar graphs
1
Why graph planarity is important -- (graphs planar graphs) <p>What is the reason to study planar graphs and algorithms on such graphs (as well as algorithms allowing to check a graph's planarity)? Where in industry this knowlege is needed?&#xA;I know that planarity arises in microchip design ("wires" intersection). I a...
habedi/stack-exchange-dataset
70,174
Why is string concatenation not distributive over intersection?
<p>Background: This is to be seen in the context of formal languages, very beginner-level.</p>&#xA;&#xA;<p>My professor claims that concatenation is not distributive over intersection, meaning that $L \circ (L_1 \cap L_2) \neq (L \circ L_1) \cap (L \circ L_2)$ and $(L_1 \cap L_2) \circ L \neq (L_1 \circ L) \cap (L_2 \c...
formal languages
1
Why is string concatenation not distributive over intersection? -- (formal languages) <p>Background: This is to be seen in the context of formal languages, very beginner-level.</p>&#xA;&#xA;<p>My professor claims that concatenation is not distributive over intersection, meaning that $L \circ (L_1 \cap L_2) \neq (L \cir...
habedi/stack-exchange-dataset
70,182
Well-Characterized vs NP-Complete
<p>Definition: <code>Well-Characterized</code> also known as <code>Good-Characterized</code> is defined as follows:</p>&#xA;&#xA;<blockquote>&#xA; <p>Problem that have Yes and No certificates i.e., are in NP $\cap$ co-NP, are&#xA; said to be Well-Characterized. (<strong>Reference</strong>: <em>V.Vazirani,&#xA; Appro...
np complete np
1
Well-Characterized vs NP-Complete -- (np complete np) <p>Definition: <code>Well-Characterized</code> also known as <code>Good-Characterized</code> is defined as follows:</p>&#xA;&#xA;<blockquote>&#xA; <p>Problem that have Yes and No certificates i.e., are in NP $\cap$ co-NP, are&#xA; said to be Well-Characterized. (<...
habedi/stack-exchange-dataset
70,185
Do two strongly connected nodes constitute a cycle in directed graph?
<p>I'm seeing seemingly contradictory information about this around. On the one hand, it seems that for undirected graphs, you need at least 3 nodes to make a cycle.&#xA;On the other other, I've also seen people differentiate between trivial and non-trivial cycles.</p>&#xA;&#xA;<p>Let's say in your directed graph you h...
graphs graph traversal
1
Do two strongly connected nodes constitute a cycle in directed graph? -- (graphs graph traversal) <p>I'm seeing seemingly contradictory information about this around. On the one hand, it seems that for undirected graphs, you need at least 3 nodes to make a cycle.&#xA;On the other other, I've also seen people differenti...
habedi/stack-exchange-dataset
70,194
What's the fastest way to find the Kth smallest value in an unsorted list without sorting?
<p>My initial algorithm:</p>&#xA;&#xA;<ol>&#xA;<li>Compare element 0 with every other element, keeping track of how many elements are less than it. </li>&#xA;<li>Repeat for each element until an element that is greater than exactly (k-1) elements is found.</li>&#xA;</ol>&#xA;&#xA;<p>I assume this would take $O(n^2)$ in...
search algorithms lists
1
What's the fastest way to find the Kth smallest value in an unsorted list without sorting? -- (search algorithms lists) <p>My initial algorithm:</p>&#xA;&#xA;<ol>&#xA;<li>Compare element 0 with every other element, keeping track of how many elements are less than it. </li>&#xA;<li>Repeat for each element until an eleme...
habedi/stack-exchange-dataset
70,199
Ask about a non-RE language
<p>I have a question about undecidability. And I hope you could point out where I am wrong.</p>&#xA;&#xA;<p>The question is: to decide the following question as (A) recursive, (B) RE but not recursive, (C) not RE.</p>&#xA;&#xA;<p>$L = \{\langle M\rangle|M \text{ is a TM and } |L(M)| \geq 3\}$</p>&#xA;&#xA;<p>If we use ...
computability undecidability
1
Ask about a non-RE language -- (computability undecidability) <p>I have a question about undecidability. And I hope you could point out where I am wrong.</p>&#xA;&#xA;<p>The question is: to decide the following question as (A) recursive, (B) RE but not recursive, (C) not RE.</p>&#xA;&#xA;<p>$L = \{\langle M\rangle|M \t...
habedi/stack-exchange-dataset
70,200
Predict language from given expression $(b^* (aaa)^* b^*)^*$
<p>I want to predict language from the given regular expression.</p>&#xA;&#xA;<p>Regular Expression: $$(b^* (aaa)^* b^*)^*$$</p>&#xA;&#xA;<p>As per my assumption language may be like:</p>&#xA;&#xA;<p>Let the string contain alphabet $\{a,b\}$ where every string contain number of $'a'$ divided/multiply by $3$.</p>&#xA;&#...
regular languages regular expressions
1
Predict language from given expression $(b^* (aaa)^* b^*)^*$ -- (regular languages regular expressions) <p>I want to predict language from the given regular expression.</p>&#xA;&#xA;<p>Regular Expression: $$(b^* (aaa)^* b^*)^*$$</p>&#xA;&#xA;<p>As per my assumption language may be like:</p>&#xA;&#xA;<p>Let the string c...
habedi/stack-exchange-dataset
70,203
Relational division
<p>I try to understand how the relational division can be expressed by primitive operations of the relational algebra. So, I found this formula (I writed it such as I found it in the same format):<br>&#xA;$A \DIVIDEBY B = A[X] \MINUS ((A[X] \TIMES B) \MINUS A)[X]$<br>&#xA;But I can't get this. If we use $\TIMES$ (the C...
relational algebra
1
Relational division -- (relational algebra) <p>I try to understand how the relational division can be expressed by primitive operations of the relational algebra. So, I found this formula (I writed it such as I found it in the same format):<br>&#xA;$A \DIVIDEBY B = A[X] \MINUS ((A[X] \TIMES B) \MINUS A)[X]$<br>&#xA;But...
habedi/stack-exchange-dataset
70,209
How to show that $\log (n!) = \Omega(n\log n)$ using Stirling's approximation?
<p>Using Stirling's approximation, we have $\log_{2} (n!) = n\log_{2} n - (log_{2} e)n + O(log_{2}n)$. Most lecture notes I have come across say that $ n\log_{2} n - (log_{2} e)n + O(log_{2}n) = \Omega (n\log_{2} n)$. Can someone give a rigorous proof of the last line using the basic definitions of big-O and big-Omega?...
asymptotics
1
How to show that $\log (n!) = \Omega(n\log n)$ using Stirling's approximation? -- (asymptotics) <p>Using Stirling's approximation, we have $\log_{2} (n!) = n\log_{2} n - (log_{2} e)n + O(log_{2}n)$. Most lecture notes I have come across say that $ n\log_{2} n - (log_{2} e)n + O(log_{2}n) = \Omega (n\log_{2} n)$. Can so...
habedi/stack-exchange-dataset
70,212
Rice's Theorem for Total Computable Functions
<p>Fix a Gödel numbering, and write $\phi_n$ for the function coded by $n$. Rice's theorem states that if $P$ is the set of partial computable functions, and $A \subseteq P$, then the decision problem</p>&#xA;&#xA;<blockquote>&#xA; <p>Given $n$, does $\phi_n \in A$?</p>&#xA;</blockquote>&#xA;&#xA;<p>is decidable if an...
computability rice theorem
1
Rice's Theorem for Total Computable Functions -- (computability rice theorem) <p>Fix a Gödel numbering, and write $\phi_n$ for the function coded by $n$. Rice's theorem states that if $P$ is the set of partial computable functions, and $A \subseteq P$, then the decision problem</p>&#xA;&#xA;<blockquote>&#xA; <p>Given ...
habedi/stack-exchange-dataset
70,213
Interesting problem on tree
<p>You are given a tree of <span class="math-container">$N$</span> nodes with colors assigned to each node. You need to find for each node <span class="math-container">$X$</span>, a value <span class="math-container">$AR[X]$</span>.</p>&#xA;&#xA;<p><span class="math-container">$AR[X]$</span> = The sum of values of <spa...
algorithms trees
1
Interesting problem on tree -- (algorithms trees) <p>You are given a tree of <span class="math-container">$N$</span> nodes with colors assigned to each node. You need to find for each node <span class="math-container">$X$</span>, a value <span class="math-container">$AR[X]$</span>.</p>&#xA;&#xA;<p><span class="math-con...
habedi/stack-exchange-dataset
70,235
Decidability of bitstring languages with no ones' complements
<p>For any string $s \in \{0,1\}^*$, let the ones' complement of $s$, denoted $1_c(s)$, be the string obtained by flipping all bits in $s$. For example, $1_c(001100) = 110011$. Now call a language $L \subset \{0,1\}^*$ <em>ones' complement asymmetric</em> or OCA for short, if for every string $s \in \{0,1\}^+$, precis...
formal languages turing machines undecidability
1
Decidability of bitstring languages with no ones' complements -- (formal languages turing machines undecidability) <p>For any string $s \in \{0,1\}^*$, let the ones' complement of $s$, denoted $1_c(s)$, be the string obtained by flipping all bits in $s$. For example, $1_c(001100) = 110011$. Now call a language $L \subs...
habedi/stack-exchange-dataset
70,246
Deterministic construction for trapezoidal decomposition
<p>There is a nice decomposition called trapezoidal to process point location queries given a set of disjoint generally curvilinear segments. I found the randomized algorithm for building this type of decomposition in Berg's book on computational geometry. Can someone point me out papers which report deterministic algo...
data structures computational geometry
1
Deterministic construction for trapezoidal decomposition -- (data structures computational geometry) <p>There is a nice decomposition called trapezoidal to process point location queries given a set of disjoint generally curvilinear segments. I found the randomized algorithm for building this type of decomposition in B...
habedi/stack-exchange-dataset
70,257
Checking if a given flow is a maximum flow
<p>I'm curious as to if there's any way to check (without having to run a 'whole' maximum-flow-algorithm) whether a given flow $f_e$ is the maximum flow of the flow graph $G$ in $O(|E|)$ time complexity.</p>&#xA;&#xA;<p>I've thought about running one iteration of Ford-Fulkerson to see if there is an augmenting path fro...
graphs graph traversal network flow ford fulkerson
1
Checking if a given flow is a maximum flow -- (graphs graph traversal network flow ford fulkerson) <p>I'm curious as to if there's any way to check (without having to run a 'whole' maximum-flow-algorithm) whether a given flow $f_e$ is the maximum flow of the flow graph $G$ in $O(|E|)$ time complexity.</p>&#xA;&#xA;<p>I...
habedi/stack-exchange-dataset
70,263
How hard are PSPACE-complete problems?
<p>There are already good answers from several perspectives regarding the "hardness" of $PSPACE$-complete problems, such as this: <a href="https://cs.stackexchange.com/questions/43723/what-is-practical-difference-between-np-and-pspace-complete">What is practical difference between NP and PSPACE-complete?</a></p>&#xA;&#...
space complexity
1
How hard are PSPACE-complete problems? -- (space complexity) <p>There are already good answers from several perspectives regarding the "hardness" of $PSPACE$-complete problems, such as this: <a href="https://cs.stackexchange.com/questions/43723/what-is-practical-difference-between-np-and-pspace-complete">What is practi...
habedi/stack-exchange-dataset
70,265
Convert a digraph to the corresponding undirected graph in linear time using adjacency lists
<p>Suppose we have a directed graph $G = (V,E$) represented with adjacency lists. Is it possible to convert $G$ into its undirected equivalent* $G'$, also represented with adjacency lists, in $O(|V|+|E|)$ time?</p>&#xA;&#xA;<p>The obvious algorithm walks the adjacency list of each vertex $v$, and for each adjacent ver...
graphs
1
Convert a digraph to the corresponding undirected graph in linear time using adjacency lists -- (graphs) <p>Suppose we have a directed graph $G = (V,E$) represented with adjacency lists. Is it possible to convert $G$ into its undirected equivalent* $G'$, also represented with adjacency lists, in $O(|V|+|E|)$ time?</p>...
habedi/stack-exchange-dataset
70,269
Approximating the dominating set on a certain kind of DAG
<p>A <em>dominating set</em> on a <em>directed graph</em> $G=(V,E)$ is a subset $D$ of $V$ such that for all $v\in V$ it holds that $v\in D$ or there is an $u\in D$ such that $(u,v)\in E.$</p>&#xA;&#xA;<p>For a concrete problem (size reduction of endgame tablebases), I want to approximate the dominating set of a direc...
graphs dag
1
Approximating the dominating set on a certain kind of DAG -- (graphs dag) <p>A <em>dominating set</em> on a <em>directed graph</em> $G=(V,E)$ is a subset $D$ of $V$ such that for all $v\in V$ it holds that $v\in D$ or there is an $u\in D$ such that $(u,v)\in E.$</p>&#xA;&#xA;<p>For a concrete problem (size reduction o...
habedi/stack-exchange-dataset
70,282
"Learning occupancy grid maps with forward sensor models, S.Thurn,2008" a formula that is difficult to overcome
<p>I am reviewing the document" Learning occupancy grid maps with forward sensor models, S.Thrun, 2008" (<a href="http://faculty.iiit.ac.in/~mkrishna/ThrunOccGrid.pdf" rel="nofollow noreferrer">http://faculty.iiit.ac.in/~mkrishna/ThrunOccGrid.pdf</a>)</p>&#xA;&#xA;<p>i am really confused about formula (26), which is me...
artificial intelligence probability theory probabilistic algorithms
1
"Learning occupancy grid maps with forward sensor models, S.Thurn,2008" a formula that is difficult to overcome -- (artificial intelligence probability theory probabilistic algorithms) <p>I am reviewing the document" Learning occupancy grid maps with forward sensor models, S.Thrun, 2008" (<a href="http://faculty.iiit.a...
habedi/stack-exchange-dataset
70,286
Is there a fundamental reason/limitation, such as $P \not = NP$, that prevents computers from being able to do mathematics (proofs, etc.)?
<p>I'm a student, so I apologise if this is an idiotic question: Is there a fundamental reason/limitation, such as $P \not = NP$, that prevents computers from being able to do mathematics (posing conjectures, proofs, etc.)? Why or why not?</p>&#xA;&#xA;<p>I have heard arguments that computers will never be able to do m...
complexity theory time complexity p vs np mathematical programming proof assistants
1
Is there a fundamental reason/limitation, such as $P \not = NP$, that prevents computers from being able to do mathematics (proofs, etc.)? -- (complexity theory time complexity p vs np mathematical programming proof assistants) <p>I'm a student, so I apologise if this is an idiotic question: Is there a fundamental reas...
habedi/stack-exchange-dataset
70,288
Hash table where items can fall into multiple buckets. What's the name of the data scrtucture?
<p>I have a task to search through an array of items. I want to narrow the search down to some partitions. I thought of hash tables, but the difference in my case is that the "hash-function" is not unique; in my case, it rather should be called "partition-function".</p>&#xA;&#xA;<p>Here's a fizz-buzz example:</p>&#xA;&...
data structures sets hash tables
1
Hash table where items can fall into multiple buckets. What's the name of the data scrtucture? -- (data structures sets hash tables) <p>I have a task to search through an array of items. I want to narrow the search down to some partitions. I thought of hash tables, but the difference in my case is that the "hash-functi...
habedi/stack-exchange-dataset
70,297
How can I use prefix sum of an array to solve this problem?
<p>I attempted this question on hackerrank. It seemed simple enough, and my program ran on small inputs. But my approach was "naive". And failed for more computationally intensive inputs. Here is the question:</p>&#xA;&#xA;<p><strong>Problem Statement</strong></p>&#xA;&#xA;<p>You are given a list of size , initialized ...
algorithms arrays
1
How can I use prefix sum of an array to solve this problem? -- (algorithms arrays) <p>I attempted this question on hackerrank. It seemed simple enough, and my program ran on small inputs. But my approach was "naive". And failed for more computationally intensive inputs. Here is the question:</p>&#xA;&#xA;<p><strong>Pro...
habedi/stack-exchange-dataset
70,305
How can I compare two recurrence relation to find which one is better on large inputs
<p>I have two recurrences:</p>&#xA;&#xA;<p>$T_1(n) = 2 T_1(n-1) + n$ if $n &gt; 1$, $1$ if $n = 1$</p>&#xA;&#xA;<p>$T_2(n) = 2 T_2(\frac{n}{2}) + n^2$ if $n &gt; 1$, $2$ if $n = 1$</p>&#xA;&#xA;<p>Does this mean $T_1$ is better than $T_2$ because it has less operations to do?</p>&#xA;&#xA;<p>Edit: I looked at the maste...
complexity theory asymptotics recurrence relation
1
How can I compare two recurrence relation to find which one is better on large inputs -- (complexity theory asymptotics recurrence relation) <p>I have two recurrences:</p>&#xA;&#xA;<p>$T_1(n) = 2 T_1(n-1) + n$ if $n &gt; 1$, $1$ if $n = 1$</p>&#xA;&#xA;<p>$T_2(n) = 2 T_2(\frac{n}{2}) + n^2$ if $n &gt; 1$, $2$ if $n = 1...
habedi/stack-exchange-dataset
70,310
Regular Expressions. Reversal of concatenated strings verification
<p>What is the significance of reversing string $v$ in the following? Can't the string $v$ contain exactly what is in the string $v^R$, since you are just choosing from the alphabet $\Sigma^*$? I don't fully comprehend this question.</p>&#xA;&#xA;<blockquote>&#xA; <p>Consider the language&#xA; $$L = \{uabcv\mid u,v\i...
formal languages
1
Regular Expressions. Reversal of concatenated strings verification -- (formal languages) <p>What is the significance of reversing string $v$ in the following? Can't the string $v$ contain exactly what is in the string $v^R$, since you are just choosing from the alphabet $\Sigma^*$? I don't fully comprehend this questio...
habedi/stack-exchange-dataset
70,314
Which one grows faster asymptotically: $\log(\log^an)$ or $\log^a(\log n)$
<p>Could someone explain to me which function grows faster?</p>&#xA;&#xA;<p>$f(n)=\log(\log^an)$ or $g(n)=\log^a(\log n)$</p>&#xA;
asymptotics
1
Which one grows faster asymptotically: $\log(\log^an)$ or $\log^a(\log n)$ -- (asymptotics) <p>Could someone explain to me which function grows faster?</p>&#xA;&#xA;<p>$f(n)=\log(\log^an)$ or $g(n)=\log^a(\log n)$</p>&#xA;
habedi/stack-exchange-dataset
70,317
Pumping Lemma: Is language with equal number of "aa" and "bb" regular?
<p>Given alphabet $\Sigma=\{a,b\}$, is the language&#xA;$$L = \{ w \mid w\text{ contains an equal number of substrings }aa\text{ and }bb \}$$&#xA;regular?&#xA; My initial though was no, because the language $L' = \{a^nb^n\mid n\ge0\}$, is not regular, and is of the same general form as $L$. However, I am confused about...
regular languages pumping lemma
1
Pumping Lemma: Is language with equal number of "aa" and "bb" regular? -- (regular languages pumping lemma) <p>Given alphabet $\Sigma=\{a,b\}$, is the language&#xA;$$L = \{ w \mid w\text{ contains an equal number of substrings }aa\text{ and }bb \}$$&#xA;regular?&#xA; My initial though was no, because the language $L' =...
habedi/stack-exchange-dataset
70,320
The floor function
<p>How do I prove or disprove the following statements:&#xA;$$(a) ∀n ∈ \mathbb N, ∃k ∈ \mathbb N, ∀x ∈ \mathbb R , \lfloor nx \rfloor − n \lfloor x \rfloor ≤ k$$ and $$ (b)\exists k \in \mathbb N, \forall n \in \mathbb N, \forall x \in \mathbb R, \lfloor nx \rfloor − n \lfloor x \rfloor ≤ k $$</p>&#xA;&#xA;<p>I've also...
proof techniques
1
The floor function -- (proof techniques) <p>How do I prove or disprove the following statements:&#xA;$$(a) ∀n ∈ \mathbb N, ∃k ∈ \mathbb N, ∀x ∈ \mathbb R , \lfloor nx \rfloor − n \lfloor x \rfloor ≤ k$$ and $$ (b)\exists k \in \mathbb N, \forall n \in \mathbb N, \forall x \in \mathbb R, \lfloor nx \rfloor − n \lfloor x...
habedi/stack-exchange-dataset
70,329
Quadratic probing maximum load factor with $c_1 = c_2 = 0.5$ to guarantee successful insertion
<p>For quadratic hashing, i.e an open-addressed table with the hash function of the form -</p>&#xA;&#xA;<p>$h(x, i)= (h'(x) + c_1i + c_2i^2) \mod m$</p>&#xA;&#xA;<p>Setting $c_1 = c_2 = 1/2$, and $m$ to some power of 2, leads to a hash function</p>&#xA;&#xA;<p>$h(x, i) = (h'(x) + 1 + 2 + ... +i) \mod m$</p>&#xA;&#xA;<p...
hash tables
1
Quadratic probing maximum load factor with $c_1 = c_2 = 0.5$ to guarantee successful insertion -- (hash tables) <p>For quadratic hashing, i.e an open-addressed table with the hash function of the form -</p>&#xA;&#xA;<p>$h(x, i)= (h'(x) + c_1i + c_2i^2) \mod m$</p>&#xA;&#xA;<p>Setting $c_1 = c_2 = 1/2$, and $m$ to some ...
habedi/stack-exchange-dataset
70,330
Linear time algorithm to sort points of a simple polygon
<p>In triangulating a simple polygon, using the concept of sweep line helper vertices etc, the very first step is sorting the vertices of such polygon. Apparently this very step can be done in $O(n)$ (where $n$ is the number of vertices). I'm trying to work out why... Assume there's no degenerate case (for any pair of ...
time complexity computational geometry sorting
1
Linear time algorithm to sort points of a simple polygon -- (time complexity computational geometry sorting) <p>In triangulating a simple polygon, using the concept of sweep line helper vertices etc, the very first step is sorting the vertices of such polygon. Apparently this very step can be done in $O(n)$ (where $n$ ...
habedi/stack-exchange-dataset
70,347
Is this grammar right associative (why?)
<p>Given a grammar as follows: </p>&#xA;&#xA;<p>$\left&lt;stmt\right&gt; \rightarrow \left&lt;id\right&gt; = \left&lt;expr\right&gt;$</p>&#xA;&#xA;<p>$\left&lt;const\right&gt; \rightarrow A | B$</p>&#xA;&#xA;<p>$\left&lt;expr\right&gt; \rightarrow \left&lt;term\right&gt; \times \left&lt;expr\right&gt; | \left&lt;term\r...
formal grammars programming languages
1
Is this grammar right associative (why?) -- (formal grammars programming languages) <p>Given a grammar as follows: </p>&#xA;&#xA;<p>$\left&lt;stmt\right&gt; \rightarrow \left&lt;id\right&gt; = \left&lt;expr\right&gt;$</p>&#xA;&#xA;<p>$\left&lt;const\right&gt; \rightarrow A | B$</p>&#xA;&#xA;<p>$\left&lt;expr\right&gt; ...
habedi/stack-exchange-dataset
70,349
Longest Palindrome Brute Force
<p>I'm confused by the running time of the following algorithm. I've been told it's $O(n^3)$, but there are only two loops. How can that be?</p>&#xA;&#xA;<pre><code>for(int i = 0; i &lt; s.length(); ++i) {&#xA; for(int j = i; j &lt;= s.length(); ++j) {&#xA; String sub = s.substring(i, j);&#xA; if(i...
algorithm analysis
1
Longest Palindrome Brute Force -- (algorithm analysis) <p>I'm confused by the running time of the following algorithm. I've been told it's $O(n^3)$, but there are only two loops. How can that be?</p>&#xA;&#xA;<pre><code>for(int i = 0; i &lt; s.length(); ++i) {&#xA; for(int j = i; j &lt;= s.length(); ++j) {&#xA; ...
habedi/stack-exchange-dataset
70,351
For AVL trees, how do we know if a RL or a LR rotation is needed?
<p>Suppose I am trying to construct a simple AVL tree:</p>&#xA;&#xA;<p><a href="https://i.stack.imgur.com/CNaf5.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/CNaf5.jpg" alt="enter image description here"></a></p>&#xA;&#xA;<p>Upon inserting 'B' the tree becomes imbalanced. How do I exactly know that...
trees binary trees balanced search trees
1
For AVL trees, how do we know if a RL or a LR rotation is needed? -- (trees binary trees balanced search trees) <p>Suppose I am trying to construct a simple AVL tree:</p>&#xA;&#xA;<p><a href="https://i.stack.imgur.com/CNaf5.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/CNaf5.jpg" alt="enter image d...
habedi/stack-exchange-dataset
70,356
Temporal alignment of two time series
<p>I have two series of tuples </p>&#xA;&#xA;<p>$$&#xA;A = \{(x_0,t_{01},t_{02}),(x_1,t_{11},t_{12}),\ldots,(x_n,t_{n1},t_{n2})\} \\&#xA;B = \{(y_0,tt_{01},tt_{02}),(y_1,tt_{11},tt_{12}),\ldots,(y_m,tt_{m1},tt_{m2})\}&#xA;$$</p>&#xA;&#xA;<p>where $m \neq n$ and $t$ and $tt$ are both time observations. $t_{i1}$ and $tt_...
algorithms time series analysis
1
Temporal alignment of two time series -- (algorithms time series analysis) <p>I have two series of tuples </p>&#xA;&#xA;<p>$$&#xA;A = \{(x_0,t_{01},t_{02}),(x_1,t_{11},t_{12}),\ldots,(x_n,t_{n1},t_{n2})\} \\&#xA;B = \{(y_0,tt_{01},tt_{02}),(y_1,tt_{11},tt_{12}),\ldots,(y_m,tt_{m1},tt_{m2})\}&#xA;$$</p>&#xA;&#xA;<p>wher...
habedi/stack-exchange-dataset
70,365
Design a 1-bit ALU using the smallest MUX possible
<p>Implement a one-bit ALU which takes two one-bit operands $a_0$, $b_0$, and produces a one-bit output $z_0$. The ALU has a two-bit control input $cont_0$, $cont_1$, with codes as shown below.</p>&#xA;&#xA;<p>|$cont_0$|$cont_1$ |<strong>selects</strong><br>&#xA;|--- 0 ---|--- 0 ---| AND<br>&#xA;|--- 0 ---|--- 1 ---...
computer architecture logic cpu
1
Design a 1-bit ALU using the smallest MUX possible -- (computer architecture logic cpu) <p>Implement a one-bit ALU which takes two one-bit operands $a_0$, $b_0$, and produces a one-bit output $z_0$. The ALU has a two-bit control input $cont_0$, $cont_1$, with codes as shown below.</p>&#xA;&#xA;<p>|$cont_0$|$cont_1$ ...
habedi/stack-exchange-dataset
70,390
DP Knapsack Problem With Categorical Constraint
<p>so I'm working on a variation of the knapsack problem which includes a constraint on the number of each item from each category in addition to a weight. For instance, we have a number of books each given a genre (1 of 3 genres), and our goal is to maximize the total weight as well as include at least G books from e...
algorithms dynamic programming
1
DP Knapsack Problem With Categorical Constraint -- (algorithms dynamic programming) <p>so I'm working on a variation of the knapsack problem which includes a constraint on the number of each item from each category in addition to a weight. For instance, we have a number of books each given a genre (1 of 3 genres), and...
habedi/stack-exchange-dataset