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 |
|---|---|---|---|---|---|---|
113,090 | Filler Algorithm | <p>I am curious to know if there is an algorithm that, given an array of decimals and integers, and given an integer, returns a sequence in descending order, composed of those numbers of the input array whose sum is as close as possible to the number of input, or even be identical, but not greater.<br></p>

<p>... | algorithms data structures arrays | 1 | Filler Algorithm -- (algorithms data structures arrays)
<p>I am curious to know if there is an algorithm that, given an array of decimals and integers, and given an integer, returns a sequence in descending order, composed of those numbers of the input array whose sum is as close as possible to the number of input, or ... | habedi/stack-exchange-dataset |
113,102 | evaluating time complexity of a code | <p>I'm trying to evaluate the time complexity of the following : </p>

<pre><code>foo (n)
 if n ≤ 1
 return 1
 if n is odd
 for i=1 to n
 print i
 return foo(n-1) + 1
 if n is even
 i=n
 while i>2
 j=1&#... | time complexity recurrence relation | 1 | evaluating time complexity of a code -- (time complexity recurrence relation)
<p>I'm trying to evaluate the time complexity of the following : </p>

<pre><code>foo (n)
 if n ≤ 1
 return 1
 if n is odd
 for i=1 to n
 print i
 return foo(n-1) + 1
 ... | habedi/stack-exchange-dataset |
113,112 | Input distribution in FLP Impossibility | <p>Lemma 2 in "<a href="https://groups.csail.mit.edu/tds/papers/Lynch/jacm85.pdf" rel="nofollow noreferrer">Impossibility of Distributed Consensus with One Faulty Process</a>" is as follows:</p>

<blockquote>
 <p>LEMMA 2. P has a bivalent initial configuration.</p>
</blockquote>

<p>They prove ... | distributed systems | 1 | Input distribution in FLP Impossibility -- (distributed systems)
<p>Lemma 2 in "<a href="https://groups.csail.mit.edu/tds/papers/Lynch/jacm85.pdf" rel="nofollow noreferrer">Impossibility of Distributed Consensus with One Faulty Process</a>" is as follows:</p>

<blockquote>
 <p>LEMMA 2. P has a bivalent ini... | habedi/stack-exchange-dataset |
113,124 | Is DISCRETE LOG a NP hard problem? | <p>In cryptography there are two problems which are part of the foundation of modern public key cryptography. Both of them can be solved in polynomial time on quantum computers. I am talking about:</p>

<ul>
<li><p><strong>FACT</strong> </p>

<p><strong>Given:</strong> A composite number, i.e. a po... | complexity classes | 1 | Is DISCRETE LOG a NP hard problem? -- (complexity classes)
<p>In cryptography there are two problems which are part of the foundation of modern public key cryptography. Both of them can be solved in polynomial time on quantum computers. I am talking about:</p>

<ul>
<li><p><strong>FACT</strong> </p>
&#... | habedi/stack-exchange-dataset |
113,127 | Largest subset such that for every two elements one of them divides the other | <p>So the problem states:</p>

<blockquote>
 <p>An array of <span class="math-container">$N (1 \leq N \leq 2000)$</span> natural numbers is given. Find
 the cardinality of the largest subset of that array such that for
 every two numbers <span class="math-container">$A$</span> and <span class="ma... | algorithms | 1 | Largest subset such that for every two elements one of them divides the other -- (algorithms)
<p>So the problem states:</p>

<blockquote>
 <p>An array of <span class="math-container">$N (1 \leq N \leq 2000)$</span> natural numbers is given. Find
 the cardinality of the largest subset of that array suc... | habedi/stack-exchange-dataset |
113,139 | Recognizing strongly connected digraphs in NL | <p><a href="http://cs.brown.edu/courses/gs019/asgn/hw6.sol.pdf" rel="nofollow noreferrer">This</a> homework solution gives a proof that 
<span class="math-container">$L = \{G \mid \text{G is strongly connected directed graph}\} \in N\mathcal{L}$</span>. One suggested way to proof that <span class="math-container">$... | complexity theory | 1 | Recognizing strongly connected digraphs in NL -- (complexity theory)
<p><a href="http://cs.brown.edu/courses/gs019/asgn/hw6.sol.pdf" rel="nofollow noreferrer">This</a> homework solution gives a proof that 
<span class="math-container">$L = \{G \mid \text{G is strongly connected directed graph}\} \in N\mathcal{L}$</... | habedi/stack-exchange-dataset |
113,144 | Least Significant Bit (LSB) vs Little Endian - Are they equivalent in anyway! | <p>For a multiple choice question: What do we call the LSB?
(i)Little Endian (ii)Upper bit (iii)Big Endian (iv)Lower Bit</p>

<p>I feel ideally none of them is a true correct choice, but my best bet was (iv) Lower Bit.</p>

<p>However, our professor claims that the correct choice should be (i)L... | terminology computer architecture | 1 | Least Significant Bit (LSB) vs Little Endian - Are they equivalent in anyway! -- (terminology computer architecture)
<p>For a multiple choice question: What do we call the LSB?
(i)Little Endian (ii)Upper bit (iii)Big Endian (iv)Lower Bit</p>

<p>I feel ideally none of them is a true correct choice, but... | habedi/stack-exchange-dataset |
113,152 | Equivalence of different automata | <p>I have a question about the equivalence of different automata. I looked up the similiar questions but sadly none of them are exactly, what I need or am looking for.</p>

<p>I know some of these are equivalent ( or not ) but for which language class pairs does a real inclusion apply?</p>

<p>DFA = NF... | formal languages automata equality | 1 | Equivalence of different automata -- (formal languages automata equality)
<p>I have a question about the equivalence of different automata. I looked up the similiar questions but sadly none of them are exactly, what I need or am looking for.</p>

<p>I know some of these are equivalent ( or not ) but for which ... | habedi/stack-exchange-dataset |
113,156 | Does basic 2 PL always ensure conflict serializability? | <p>While going through the DBMS book by Korth, it was mentioned : </p>

<p>" For a set of transactions, there may be conflict-serializable schedules that
cannot be obtained through the two-phase locking protocol.</p>

<p>Does this imply that basic 2 PL ensures serializability but does not always ens... | databases database concurrency | 1 | Does basic 2 PL always ensure conflict serializability? -- (databases database concurrency)
<p>While going through the DBMS book by Korth, it was mentioned : </p>

<p>" For a set of transactions, there may be conflict-serializable schedules that
cannot be obtained through the two-phase locking protocol.</p>... | habedi/stack-exchange-dataset |
113,163 | Elementary proof that Bool is a Set | <p>The type <code>Bool</code>, as in the datatype with just two point constructors <code>true false : Bool</code> and no higher-dimensional constructors, has decidable equality which is easy to prove directly, e.g. via a type family that maps <code>true</code> to <code>Unit</code> and <code>false</code> to <code>Void</... | homotopy type theory | 1 | Elementary proof that Bool is a Set -- (homotopy type theory)
<p>The type <code>Bool</code>, as in the datatype with just two point constructors <code>true false : Bool</code> and no higher-dimensional constructors, has decidable equality which is easy to prove directly, e.g. via a type family that maps <code>true</cod... | habedi/stack-exchange-dataset |
113,167 | Complexity Class of an Algorithm with two Inputs | <p>Consider a problem with two inputs like (P,L) and |P|=n and L is some positive integer. If my algorithm had a complexity of O(n^L), would that still be polynomial? Or is it exponential? I'm not sure if I should view L as a constant or as 'size of input', since it's not a size but just some number (as in, Knapsack fo... | complexity theory runtime analysis | 1 | Complexity Class of an Algorithm with two Inputs -- (complexity theory runtime analysis)
<p>Consider a problem with two inputs like (P,L) and |P|=n and L is some positive integer. If my algorithm had a complexity of O(n^L), would that still be polynomial? Or is it exponential? I'm not sure if I should view L as a const... | habedi/stack-exchange-dataset |
113,177 | Is this lambda abstraction created as a generator of a recursive function? | <p>In lambda calculus, a recursive function <span class="math-container">$f$</span> is obtained by </p>

<p><span class="math-container">$$ f = Y g $$</span></p>

<p>where <span class="math-container">$Y$</span> is the Y combinator and <span class="math-container">$g$</span> is the generator of <span cl... | lambda calculus recursion | 1 | Is this lambda abstraction created as a generator of a recursive function? -- (lambda calculus recursion)
<p>In lambda calculus, a recursive function <span class="math-container">$f$</span> is obtained by </p>

<p><span class="math-container">$$ f = Y g $$</span></p>

<p>where <span class="math-containe... | habedi/stack-exchange-dataset |
113,185 | efficiently minimizing quasiconvex function | <p>The problem is as follows: given black box access to a strictly quasiconvex (or unimodal) function <span class="math-container">$f$</span> on an interval, say [0, 1], query <span class="math-container">$f$</span> repeatedly at various points to find a subinterval containing the minimum. After <span class="math-conta... | algorithms search algorithms | 1 | efficiently minimizing quasiconvex function -- (algorithms search algorithms)
<p>The problem is as follows: given black box access to a strictly quasiconvex (or unimodal) function <span class="math-container">$f$</span> on an interval, say [0, 1], query <span class="math-container">$f$</span> repeatedly at various poin... | habedi/stack-exchange-dataset |
113,198 | Number of induced paths in an interval graph | <p>Let <span class="math-container">$G$</span> be an interval graph. For any two vertices <span class="math-container">$u,v$</span> in <span class="math-container">$G$</span>, how many induced paths are between them in <span class="math-container">$G$</span>? Is it polynomial in terms of the number of vertices in <span... | algorithms graphs discrete mathematics | 1 | Number of induced paths in an interval graph -- (algorithms graphs discrete mathematics)
<p>Let <span class="math-container">$G$</span> be an interval graph. For any two vertices <span class="math-container">$u,v$</span> in <span class="math-container">$G$</span>, how many induced paths are between them in <span class=... | habedi/stack-exchange-dataset |
113,210 | k-disjoint pair paths where any source can pair with any sink | <p>I have a question regarding a problem I'm working on.</p>

<p>The problem is given an MxN grid with k sources and sinks, find non intersecting paths (vertex disjoint) such that all sources are paired with a sink. Each source must be paired to a single sink, and each sink must be paired to a single source, ho... | algorithms graphs | 1 | k-disjoint pair paths where any source can pair with any sink -- (algorithms graphs)
<p>I have a question regarding a problem I'm working on.</p>

<p>The problem is given an MxN grid with k sources and sinks, find non intersecting paths (vertex disjoint) such that all sources are paired with a sink. Each source... | habedi/stack-exchange-dataset |
113,211 | Helping prove this notation for Big-O(n!) | <p><a href="https://i.stack.imgur.com/RsahC.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/RsahC.png" alt="enter image description here"></a></p>

<p>Hello, I was wondering if anyone can help me prove the right part of this double equation. I know the left one is possible due to<code>log(n!)... | time complexity big o notation | 1 | Helping prove this notation for Big-O(n!) -- (time complexity big o notation)
<p><a href="https://i.stack.imgur.com/RsahC.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/RsahC.png" alt="enter image description here"></a></p>

<p>Hello, I was wondering if anyone can help me prove the right par... | habedi/stack-exchange-dataset |
113,214 | Neural network game players and incremental updates | <p>Neural networks in recent years have been successfully used for gameplaying. A difference between games and e.g. image processing is that the game boards get updated incrementally. Do any neural network implementations optimize for this fact?</p>

<p>For example, there are 361 squares on a Go board; in a typ... | machine learning artificial intelligence neural networks board games | 1 | Neural network game players and incremental updates -- (machine learning artificial intelligence neural networks board games)
<p>Neural networks in recent years have been successfully used for gameplaying. A difference between games and e.g. image processing is that the game boards get updated incrementally. Do any neu... | habedi/stack-exchange-dataset |
113,224 | On $L^* - \{\epsilon\} = L^+$ | <blockquote>
 <p><span class="math-container">$\Sigma^* - \{\epsilon\} = \Sigma^+$</span></p>
 
 <p><span class="math-container">$L^* - \{\epsilon\} = L^+$</span></p>
 
 <p>Which of the above is always true?</p>
</blockquote>

<p>I was following a discussion on a site and I came acr... | automata equality | 1 | On $L^* - \{\epsilon\} = L^+$ -- (automata equality)
<blockquote>
 <p><span class="math-container">$\Sigma^* - \{\epsilon\} = \Sigma^+$</span></p>
 
 <p><span class="math-container">$L^* - \{\epsilon\} = L^+$</span></p>
 
 <p>Which of the above is always true?</p>
</blockquote>

<p>... | habedi/stack-exchange-dataset |
113,228 | Smallest segment after whose removal all elements are distinct | <p>I am interested in the following <a href="https://codeforces.com/contest/1208/problem/B" rel="nofollow noreferrer">problem</a>:</p>

<blockquote>
 <p>We are given an array of integers and we need to find the <strong>size</strong> of smallest subsegment such that after removing it all elements in the arr... | algorithms binary search | 1 | Smallest segment after whose removal all elements are distinct -- (algorithms binary search)
<p>I am interested in the following <a href="https://codeforces.com/contest/1208/problem/B" rel="nofollow noreferrer">problem</a>:</p>

<blockquote>
 <p>We are given an array of integers and we need to find the <st... | habedi/stack-exchange-dataset |
113,238 | Does Types and Programming Languages use a recursive equation to define a recursive type or its generator? | <p>In <em>Types and Programming Languages</em> by Pierce et al:</p>

<blockquote>
 <p><strong>The recursive equation specifying the type of lists of numbers</strong> is similar to the equation specifying the recursive factorial function on page 52:</p>

<pre><code>factorial = λn. if n=0 then 1 else... | computability programming languages type theory | 1 | Does Types and Programming Languages use a recursive equation to define a recursive type or its generator? -- (computability programming languages type theory)
<p>In <em>Types and Programming Languages</em> by Pierce et al:</p>

<blockquote>
 <p><strong>The recursive equation specifying the type of lists o... | habedi/stack-exchange-dataset |
113,248 | Detecting rotational symmetries of spatial structures | <p>I have a spatial graph-like structure. The structure consists of vertices in the 3D space and connecting edges. Are there any algorithms available that would identify the rotational symmetries of these structures? In particular, I'm interested in all the rotational axis along which I can rotate the structure to over... | algorithms graphs graphics group theory polygons | 1 | Detecting rotational symmetries of spatial structures -- (algorithms graphs graphics group theory polygons)
<p>I have a spatial graph-like structure. The structure consists of vertices in the 3D space and connecting edges. Are there any algorithms available that would identify the rotational symmetries of these structu... | habedi/stack-exchange-dataset |
113,250 | Solving recurrence relation where the $f(n)$ has some constant factor $k$ where $0 < k < 1$ | <p>I am trying to see if a recurrence relation where <span class="math-container">$f(n)$</span> has some constant factor <span class="math-container">$k$</span>, e.g. <span class="math-container">$f(n)=kn$</span> where <span class="math-container">$0 < k < 1$</span>, is <span class="math-container">$O(n)$</span>.... | recurrence relation master theorem | 1 | Solving recurrence relation where the $f(n)$ has some constant factor $k$ where $0 < k < 1$ -- (recurrence relation master theorem)
<p>I am trying to see if a recurrence relation where <span class="math-container">$f(n)$</span> has some constant factor <span class="math-container">$k$</span>, e.g. <span class="math-con... | habedi/stack-exchange-dataset |
113,256 | How to prove by contradiction that every nonempty hereditary language contains the empty string? | <p>A language L is called hereditary if it has the following property:</p>

<p>For every nonempty string x in L, there is a character in x which can be deleted from x to give another string in L.</p>

<p>Prove by contradiction that every nonempty hereditary language contains the empty string.</p>
&#... | proof techniques check my answer | 1 | How to prove by contradiction that every nonempty hereditary language contains the empty string? -- (proof techniques check my answer)
<p>A language L is called hereditary if it has the following property:</p>

<p>For every nonempty string x in L, there is a character in x which can be deleted from x to give an... | habedi/stack-exchange-dataset |
113,257 | Given a specific computer system, is it possible to estimate the actual precise run time of a piece of Assembly code | <p>this is a piece of Assembly code</p>

<pre><code>section .text
 global _start ;must be declared for using gcc
_start: ;tell linker entry point
 mov edx, len ;message length
 mov ecx, msg ;message to write
 mov ebx, 1 ;file descriptor (stdou... | assembly | 1 | Given a specific computer system, is it possible to estimate the actual precise run time of a piece of Assembly code -- (assembly)
<p>this is a piece of Assembly code</p>

<pre><code>section .text
 global _start ;must be declared for using gcc
_start: ;tell linker entry poin... | habedi/stack-exchange-dataset |
113,259 | Whether the given language is a CFL or not? | <p>Let <span class="math-container">$L$</span> be a language defined over <span class="math-container">$\Sigma = \left \{ a, b \right \}$</span> such that
<span class="math-container">$L = \left \{ x\#y \mid x,y \in \Sigma^*, \# \text { is a constant and } x \neq y \right \}$</span>
State whether the language L... | context free pumping lemma | 1 | Whether the given language is a CFL or not? -- (context free pumping lemma)
<p>Let <span class="math-container">$L$</span> be a language defined over <span class="math-container">$\Sigma = \left \{ a, b \right \}$</span> such that
<span class="math-container">$L = \left \{ x\#y \mid x,y \in \Sigma^*, \# \text { is ... | habedi/stack-exchange-dataset |
113,269 | Finding efficient randomized algorithm | <p>I'm doing a course on randomized algorithms and
I've encountered a question that I'm struggling to solve. </p>

<p>Given a system of <span class="math-container">$m$</span> linear equations with <span class="math-container">$n$</span> variables over finite field <span class="math-container">$\mathbb{F_2... | algorithms randomized algorithms randomness | 1 | Finding efficient randomized algorithm -- (algorithms randomized algorithms randomness)
<p>I'm doing a course on randomized algorithms and
I've encountered a question that I'm struggling to solve. </p>

<p>Given a system of <span class="math-container">$m$</span> linear equations with <span class="math-con... | habedi/stack-exchange-dataset |
113,277 | Since the halting problem is undecidable, does that mean that there exists an always undecidable program? | <p>The usual demonstration of the halting problem's undecidability involves positing an adversarial machine (call it <span class="math-container">$A_0$</span>) that runs the decider machine (call it <span class="math-container">$D_0$</span>) on itself and performs the opposite of the answer it gets. But it would be pos... | turing machines undecidability halting problem | 1 | Since the halting problem is undecidable, does that mean that there exists an always undecidable program? -- (turing machines undecidability halting problem)
<p>The usual demonstration of the halting problem's undecidability involves positing an adversarial machine (call it <span class="math-container">$A_0$</span>) th... | habedi/stack-exchange-dataset |
113,279 | Doubt regarding Chomsky Hierarchy, CFG and CSG | <p>I was following a discussion on a website, where a fellow scholar claims that
this grammar</p>

<blockquote>
 <p>S→ aAa | bAb | ϵ</p>
 
 <p>A→aA | bA |ϵ</p>
</blockquote>

<p>is not CSG, so it should also NOT be a CFG. But this grammar properly satisfies the rules of CFG accord... | context free context sensitive chomsky hierarchy | 1 | Doubt regarding Chomsky Hierarchy, CFG and CSG -- (context free context sensitive chomsky hierarchy)
<p>I was following a discussion on a website, where a fellow scholar claims that
this grammar</p>

<blockquote>
 <p>S→ aAa | bAb | ϵ</p>
 
 <p>A→aA | bA |ϵ</p>
</blockquote>

<p>is... | habedi/stack-exchange-dataset |
113,283 | Minimal hitting set with respect to set inclusion from a book "Parameterized Complexity Theory" | <p>In the first chapter of <a href="https://books.google.de/books/about/Parameterized_Complexity_Theory.html?id=VfJz6hvFAjoC&redir_esc=y&hl=de" rel="nofollow noreferrer">"Parameterized Complexity Theory</a>" by Flum and Grohe, an example is presented to find a hitting set of minimal cardinality. </p>

<... | algorithms graphs optimization np hard set cover | 1 | Minimal hitting set with respect to set inclusion from a book "Parameterized Complexity Theory" -- (algorithms graphs optimization np hard set cover)
<p>In the first chapter of <a href="https://books.google.de/books/about/Parameterized_Complexity_Theory.html?id=VfJz6hvFAjoC&redir_esc=y&hl=de" rel="nofollow nore... | habedi/stack-exchange-dataset |
113,286 | Analysis of a LALR shift-reduce conflict | <p>I have created an extremely simple byacc grammar (ok, it's not really that simple but I simplified purposefully to be a minimal complete verifiable example):</p>

<pre><code>%token NEWLINE SPECIFIER
%token EQUALS STRING VAR

%start st

%%

st: toplevel;

toplevel:
| to... | parsers lr k | 1 | Analysis of a LALR shift-reduce conflict -- (parsers lr k)
<p>I have created an extremely simple byacc grammar (ok, it's not really that simple but I simplified purposefully to be a minimal complete verifiable example):</p>

<pre><code>%token NEWLINE SPECIFIER
%token EQUALS STRING VAR

%start st
... | habedi/stack-exchange-dataset |
113,294 | Asymptotic Relationship from Limit | <p>F(n) = n-100
G(n) = n-200</p>

<p>I am trying to show the asymptotic relationship between these two functions using limits. </p>

<p>I take the limit n->∞ f(n) / g(n) and I get the result 1 which is constant c.</p>

<p><strong>From the Big O theorem,</strong> </p>

<p><a href="htt... | asymptotics big o notation | 1 | Asymptotic Relationship from Limit -- (asymptotics big o notation)
<p>F(n) = n-100
G(n) = n-200</p>

<p>I am trying to show the asymptotic relationship between these two functions using limits. </p>

<p>I take the limit n->∞ f(n) / g(n) and I get the result 1 which is constant c.</p>

<p><st... | habedi/stack-exchange-dataset |
113,299 | Why an error probability of 1/3 in BPP? | <p><a href="https://en.m.wikipedia.org/wiki/BPP_(complexity)" rel="nofollow noreferrer">BPP</a> is defined as the class of polynomial-time random algorithms which have an error probability of at most 1/3.</p>

<p>But why was 1/3 chosen? If we have an algorithm with some error probability less than 1/2, then we ... | probabilistic algorithms | 1 | Why an error probability of 1/3 in BPP? -- (probabilistic algorithms)
<p><a href="https://en.m.wikipedia.org/wiki/BPP_(complexity)" rel="nofollow noreferrer">BPP</a> is defined as the class of polynomial-time random algorithms which have an error probability of at most 1/3.</p>

<p>But why was 1/3 chosen? If we... | habedi/stack-exchange-dataset |
113,304 | Simple generator of pseudo-random permutations of variable length short sequence | <p>The problem in front of me is to write a function (from scratch) to permute n elements, where n is an argument. I decided to break it down to applying Knuth's shuffles algorithm, therefore I needed to write a pseudorandom number generator. </p>

<p>So now my task is to write a simple function <code>F(seed,n... | randomness number theory pseudo random generators modular arithmetic random number generator | 1 | Simple generator of pseudo-random permutations of variable length short sequence -- (randomness number theory pseudo random generators modular arithmetic random number generator)
<p>The problem in front of me is to write a function (from scratch) to permute n elements, where n is an argument. I decided to break it down... | habedi/stack-exchange-dataset |
113,305 | Is the graph symbol used in dask a general notation? | <p><a href="https://docs.dask.org/en/latest/" rel="nofollow noreferrer">Dask</a> is a flexible library for parallel computing in Python.</p>

<p>This piece of code define some simple functions.</p>

<pre><code>def inc(x):
 return x + 1

def double(x):
 return x + 2

def add... | graphs computation models | 1 | Is the graph symbol used in dask a general notation? -- (graphs computation models)
<p><a href="https://docs.dask.org/en/latest/" rel="nofollow noreferrer">Dask</a> is a flexible library for parallel computing in Python.</p>

<p>This piece of code define some simple functions.</p>

<pre><code>def inc(x)... | habedi/stack-exchange-dataset |
113,306 | Do determinacy of one-step evaluation and uniqueness of normal forms apply to all (or most) languages in TAPL? | <p>In <em>Types and Programming Languages</em> by Pierce, when talking about untyped arithmetic expressions in Chapter 3, there are two theorems:</p>

<p><span class="math-container">$-→$</span> is single-step evaluation relation:</p>

<blockquote>
 <p>3.5.4 Theorem [Determinacy of one-step evalua... | programming languages type theory | 1 | Do determinacy of one-step evaluation and uniqueness of normal forms apply to all (or most) languages in TAPL? -- (programming languages type theory)
<p>In <em>Types and Programming Languages</em> by Pierce, when talking about untyped arithmetic expressions in Chapter 3, there are two theorems:</p>

<p><span cl... | habedi/stack-exchange-dataset |
113,310 | Does a term being normalizable mean the same as the term has a normal form? | <p>From Types and Programming Languages by Pierce</p>

<blockquote>
 <p>A term <span class="math-container">$t$</span> is in normal form if no evaluation rule applies to it—
 i.e., if there is no <span class="math-container">$t'$</span> such that <span class="math-container">$t -→ t'$</span>. </p>
... | programming languages type theory | 1 | Does a term being normalizable mean the same as the term has a normal form? -- (programming languages type theory)
<p>From Types and Programming Languages by Pierce</p>

<blockquote>
 <p>A term <span class="math-container">$t$</span> is in normal form if no evaluation rule applies to it—
 i.e., if the... | habedi/stack-exchange-dataset |
113,321 | Why are struct and class essentially the same in C++? | <p><code>struct</code> and <code>class</code> in C++ are nearly identical (as covered for example <a href="https://stackoverflow.com/q/92859/1717300">here</a>).</p>

<p>But why is this so? What did happen when C++ was developed and eventually standardized, that <code>struct</code> was allowed to define a full O... | history language design c++ | 1 | Why are struct and class essentially the same in C++? -- (history language design c++)
<p><code>struct</code> and <code>class</code> in C++ are nearly identical (as covered for example <a href="https://stackoverflow.com/q/92859/1717300">here</a>).</p>

<p>But why is this so? What did happen when C++ was develop... | habedi/stack-exchange-dataset |
113,342 | High-dimensional geometry and P vs. NP | <p><strong>Background:</strong> Recently, I obtained the following equivalent problem to SAT. We are given as input a CNF formula with <span class="math-container">$n$</span> variables and <span class="math-container">$m$</span> clauses. Suppose we have an <span class="math-container">$n$</span>-dimensional hyper-cube ... | complexity theory computational geometry satisfiability | 1 | High-dimensional geometry and P vs. NP -- (complexity theory computational geometry satisfiability)
<p><strong>Background:</strong> Recently, I obtained the following equivalent problem to SAT. We are given as input a CNF formula with <span class="math-container">$n$</span> variables and <span class="math-container">$m... | habedi/stack-exchange-dataset |
113,349 | What Is the Complexity Class of Deciding Whether a Problem Is in NP? Is It Decidable? | <p>Title says it all, but to clarify:</p>

<p>Define a problem, called <span class="math-container">$IsInNP$</span>, as follows:</p>

<blockquote>
 <p>Given a Turing Machine <span class="math-container">$M$</span> that always halts, <span class="math-container">$IsInNP$</span> is the problem of dec... | complexity theory computability | 1 | What Is the Complexity Class of Deciding Whether a Problem Is in NP? Is It Decidable? -- (complexity theory computability)
<p>Title says it all, but to clarify:</p>

<p>Define a problem, called <span class="math-container">$IsInNP$</span>, as follows:</p>

<blockquote>
 <p>Given a Turing Machine <s... | habedi/stack-exchange-dataset |
113,355 | Proof that complement of HAMPATH is not in NP | <p>The Sipser book says, Complement of HAMPATH is not in NP.</p>

<p>I tried to find the solution for this, actually, a rigid proof like HAMPATH, which can state Complement of HAMPATH is in/not in NP, but I could not come up with any.</p>

<p>This is what I think, We are given a path from s to t(which c... | complexity theory | 1 | Proof that complement of HAMPATH is not in NP -- (complexity theory)
<p>The Sipser book says, Complement of HAMPATH is not in NP.</p>

<p>I tried to find the solution for this, actually, a rigid proof like HAMPATH, which can state Complement of HAMPATH is in/not in NP, but I could not come up with any.</p>
... | habedi/stack-exchange-dataset |
113,364 | Conversion from octal numerical system to binary numerical system | <p>I know that in order to convert a numeral in base-8 to a numeral in base-2 I can write each octal digit as a binary word of 3 bits.</p>

<p>I know that 2^3 = 8 that is exactly the dimension of the base of the octal system.</p>

<p>I just cannot understand the fundamental reason why it works. Is it ju... | binary base conversion numeral representations | 1 | Conversion from octal numerical system to binary numerical system -- (binary base conversion numeral representations)
<p>I know that in order to convert a numeral in base-8 to a numeral in base-2 I can write each octal digit as a binary word of 3 bits.</p>

<p>I know that 2^3 = 8 that is exactly the dimension o... | habedi/stack-exchange-dataset |
113,370 | Can we always transform a set of lines to a function? | <p>If I have <code>n</code> lines in a programming language like Python (globally or inside a function):</p>
<pre><code>..
..
# from here
..
..
..
..
# to here
..
..
</code></pre>
<p>or</p>
<pre><code>def example():
 ...
 ...
 # from here
 ... | programming languages functional programming | 1 | Can we always transform a set of lines to a function? -- (programming languages functional programming)
<p>If I have <code>n</code> lines in a programming language like Python (globally or inside a function):</p>
<pre><code>..
..
# from here
..
..
..
..
# to here
..
..
</code... | habedi/stack-exchange-dataset |
113,374 | What is the purpose of erasing a type application to a term-application in parametric polymorphism? | <p>From <em>Types and Programming Languages</em> by Pierce</p>

<blockquote>
 <p><strong>23 Polymorphism</strong></p>
 
 <p><strong>23.7 Erasure and Evaluation Order</strong></p>
 
 <p>in a full-blown programming language, which may include side-
 effecting features such as mutable ... | programming languages type theory polymorphisms | 1 | What is the purpose of erasing a type application to a term-application in parametric polymorphism? -- (programming languages type theory polymorphisms)
<p>From <em>Types and Programming Languages</em> by Pierce</p>

<blockquote>
 <p><strong>23 Polymorphism</strong></p>
 
 <p><strong>23.7 Erasure... | habedi/stack-exchange-dataset |
113,375 | Example of a locally trivial semigroup | <p>I was having a look at the block product principle for finite monoids. I wanted to see the derivation of LTT = Acom<span class="math-container">$*$</span>LI, using an example. But I can't come up with a non-trivial example of a monoid in LI. Any help is appreciated.</p>
 | finite automata | 1 | Example of a locally trivial semigroup -- (finite automata)
<p>I was having a look at the block product principle for finite monoids. I wanted to see the derivation of LTT = Acom<span class="math-container">$*$</span>LI, using an example. But I can't come up with a non-trivial example of a monoid in LI. Any help is app... | habedi/stack-exchange-dataset |
113,377 | Weaknesses arising from using same key in both channel directions | <p>I came across the following question:<br/><br/>
Which of the following risk may arise, when same key is used to encrypt both directions of a communication channel, that are not present if using different keys in both direction?<br/><br/>
The answer to the question was reflection attack. The other options pro... | cryptography security encryption | 1 | Weaknesses arising from using same key in both channel directions -- (cryptography security encryption)
<p>I came across the following question:<br/><br/>
Which of the following risk may arise, when same key is used to encrypt both directions of a communication channel, that are not present if using different keys ... | habedi/stack-exchange-dataset |
113,389 | Like transitive reduction, but removing vertices rather than edges? | <p>Suppose I have a directed graph <span class="math-container">$G = (V, E)$</span> <em>(or, which is the same, a relation on the set <span class="math-container">$V$</span> as defined by the adjacency matrix)</em> that may contain three vertices <span class="math-container">$x, y, z$</span>, such that <span class="mat... | algorithms graphs functional programming nondeterminism transitivity | 1 | Like transitive reduction, but removing vertices rather than edges? -- (algorithms graphs functional programming nondeterminism transitivity)
<p>Suppose I have a directed graph <span class="math-container">$G = (V, E)$</span> <em>(or, which is the same, a relation on the set <span class="math-container">$V$</span> as d... | habedi/stack-exchange-dataset |
113,394 | What does it mean that a let-binding can be treated polymorphically, only if its right-hand side is a syntactic value? | <p><em>Types and Programming Languages</em> by Pierce says:</p>

<blockquote>
 <p><strong>22.7 Let polymorphism</strong></p>
 
 <p>A final point worth mentioning is that, in designing full-blown
 programming languages with let-polymorphism, we need to be a bit
 careful of the interaction... | programming languages polymorphisms | 1 | What does it mean that a let-binding can be treated polymorphically, only if its right-hand side is a syntactic value? -- (programming languages polymorphisms)
<p><em>Types and Programming Languages</em> by Pierce says:</p>

<blockquote>
 <p><strong>22.7 Let polymorphism</strong></p>
 
 <p>A final... | habedi/stack-exchange-dataset |
113,396 | How does this allow list operations to be applied to lists with elements of any type? | <p>In <em>Types and Programming Languages</em> by Pierce, Chapter 11 is simple extensions of the simply typed lambda calculus with any simple base types. Section 11.12 introduces Lists. </p>

<p>How does the section allow list operations to be applied to lists with elements of any type? Specifically, my confusi... | programming languages type theory polymorphisms | 1 | How does this allow list operations to be applied to lists with elements of any type? -- (programming languages type theory polymorphisms)
<p>In <em>Types and Programming Languages</em> by Pierce, Chapter 11 is simple extensions of the simply typed lambda calculus with any simple base types. Section 11.12 introduces Li... | habedi/stack-exchange-dataset |
113,412 | Are type abstraction values and universal types not for non functions, but only for functions? | <p>In <em>Types and Programming Languages</em> by Pierce, <em>Chapter 23 Universal Types</em> has a summary of System F in the following figure, in particular, "type abstraction values" and their types "universal types".</p>

<p>In all the examples I have seen so far in the chapter, in particular <em>Section 23... | programming languages type theory polymorphisms | 1 | Are type abstraction values and universal types not for non functions, but only for functions? -- (programming languages type theory polymorphisms)
<p>In <em>Types and Programming Languages</em> by Pierce, <em>Chapter 23 Universal Types</em> has a summary of System F in the following figure, in particular, "type abstra... | habedi/stack-exchange-dataset |
113,416 | Exact meaning of $2^{\mathcal{O}(f(n))}$ | <p>In Sipser's Introduction to the Theory of Computation he uses the notation <span class="math-container">$2^{\mathcal{O}(f(n))}$</span> to denote some asymptotic running time.</p>

<p>For example he says that the running time of a single-tape deterministic turing machine simulating a multi-tape non-determinis... | complexity theory asymptotics notation big o notation | 1 | Exact meaning of $2^{\mathcal{O}(f(n))}$ -- (complexity theory asymptotics notation big o notation)
<p>In Sipser's Introduction to the Theory of Computation he uses the notation <span class="math-container">$2^{\mathcal{O}(f(n))}$</span> to denote some asymptotic running time.</p>

<p>For example he says that t... | habedi/stack-exchange-dataset |
113,420 | Is decimal number 8 represented as 3 bits or 4 bits in computer? | <p>I was told by my professor that</p>

<p>"It takes c * ln(n) bits to store a number n, where ln() is base 2 and c is a constant."</p>

<p>Thus, to store a number 8, we need ln(8) = 3 bits(I think const c can be ignored here.), but isn't 8 stored as "1000" in a computer, which is 4 bits?</p>

<... | number formats binary | 1 | Is decimal number 8 represented as 3 bits or 4 bits in computer? -- (number formats binary)
<p>I was told by my professor that</p>

<p>"It takes c * ln(n) bits to store a number n, where ln() is base 2 and c is a constant."</p>

<p>Thus, to store a number 8, we need ln(8) = 3 bits(I think const c can be... | habedi/stack-exchange-dataset |
113,425 | Recurrent relation for algorithms with two stages | <p>I am trying to do the recurrence relation for my algorithm, but it has two variables <span class="math-container">$T(n,m)$</span>. For sufficiently small <span class="math-container">$n$</span>, <span class="math-container">$m$</span> is practically the same as <span class="math-container">$n$</span>, but <span clas... | algorithm analysis recurrence relation | 1 | Recurrent relation for algorithms with two stages -- (algorithm analysis recurrence relation)
<p>I am trying to do the recurrence relation for my algorithm, but it has two variables <span class="math-container">$T(n,m)$</span>. For sufficiently small <span class="math-container">$n$</span>, <span class="math-container"... | habedi/stack-exchange-dataset |
113,428 | How can mainstream OO languages support strong binary operations by classes? | <p>Section 24.2 in <em>Types and Programming Languages</em> by Pierce compares ADT and existential objects,in terms of how well they support strong binary operations:</p>

<blockquote>
 <p>Other binary operations cannot be implemented without concrete, privileged access to the representations of both abst... | programming languages type theory polymorphisms | 1 | How can mainstream OO languages support strong binary operations by classes? -- (programming languages type theory polymorphisms)
<p>Section 24.2 in <em>Types and Programming Languages</em> by Pierce compares ADT and existential objects,in terms of how well they support strong binary operations:</p>

<blockquo... | habedi/stack-exchange-dataset |
113,429 | Why are ADT packages opened immediately after they are built, while existential objects opened as late as possible? | <p>Section 24.2 in <em>Types and Programming Languages</em> by Pierce defines ADTs in existential types:</p>

<blockquote>
 <p><strong>A conventional abstract data type (or ADT)</strong> consists of (1) a type name A, (2) a concrete representation type T, (3) implementations of
 some operations for c... | programming languages type theory polymorphisms | 1 | Why are ADT packages opened immediately after they are built, while existential objects opened as late as possible? -- (programming languages type theory polymorphisms)
<p>Section 24.2 in <em>Types and Programming Languages</em> by Pierce defines ADTs in existential types:</p>

<blockquote>
 <p><strong>A ... | habedi/stack-exchange-dataset |
113,434 | What does "prime" mean in this context? | <p>In a lecture video the instructor introduced the quadratic probing method for hash tables. The formula he gave was the following:</p>

<p><span class="math-container">$h(k,i) = (h'(k) + c_1 + c_2i^2)$</span> <span class="math-container">$\% M$</span></p>

<p>where <span class="math-container">$h'$</s... | terminology hash hash tables | 1 | What does "prime" mean in this context? -- (terminology hash hash tables)
<p>In a lecture video the instructor introduced the quadratic probing method for hash tables. The formula he gave was the following:</p>

<p><span class="math-container">$h(k,i) = (h'(k) + c_1 + c_2i^2)$</span> <span class="math-container... | habedi/stack-exchange-dataset |
113,438 | Louvain algorithm: self-loop weight is double? | <p>In the 2nd phase of <a href="https://arxiv.org/abs/1108.1502" rel="nofollow noreferrer">the Louvain algorithm</a>, self-loops are given by the sum of all the intra-community weights. I'm wondering from their own figure, why all of the self-loops seem to have <code>2w</code> weights, rather than <code>w</code>. Note ... | graphs | 1 | Louvain algorithm: self-loop weight is double? -- (graphs)
<p>In the 2nd phase of <a href="https://arxiv.org/abs/1108.1502" rel="nofollow noreferrer">the Louvain algorithm</a>, self-loops are given by the sum of all the intra-community weights. I'm wondering from their own figure, why all of the self-loops seem to have... | habedi/stack-exchange-dataset |
113,440 | Which algorithm to detect errors in 32bit data with 8bit parity | <p>I want to transmit a 32bit message in eight groups of 5bit each. This leaves me with 8bits to use for error checking.</p>

<p>Overall, a group is likely transmitted without error, but when there is an error transmitting a group, there are probably multiple bits wrong.</p>

<p>If I use one parity bit ... | algorithms coding theory | 1 | Which algorithm to detect errors in 32bit data with 8bit parity -- (algorithms coding theory)
<p>I want to transmit a 32bit message in eight groups of 5bit each. This leaves me with 8bits to use for error checking.</p>

<p>Overall, a group is likely transmitted without error, but when there is an error transmit... | habedi/stack-exchange-dataset |
113,457 | Compute highest-scoring segmentation | <p>I have the following problem:</p>

<p>There is a "clean" sequence of sequences, say:</p>

<pre><code>clean = [
 [1, 2],
 [3],
 [4, 5]
]
</code></pre>

<p>And a "noisy" sequence which is not segmented:</p>

<pre><code>segmented = [1, 100, 2, 3, 3, 101, 4, 5... | algorithms dynamic programming search algorithms | 1 | Compute highest-scoring segmentation -- (algorithms dynamic programming search algorithms)
<p>I have the following problem:</p>

<p>There is a "clean" sequence of sequences, say:</p>

<pre><code>clean = [
 [1, 2],
 [3],
 [4, 5]
]
</code></pre>

<p>And a "noisy" seque... | habedi/stack-exchange-dataset |
113,473 | Difference between UCB1 and UCT | <p>In <a href="http://ggp.stanford.edu/readings/uct.pdf" rel="nofollow noreferrer">Bandit Based Monte-Carlo Planning</a> by Levente Kocsis and Csaba Szepesvári (2006) they propose the UCT algorithm which is derived from the UCB1 algorithm. </p>

<p>UCB1 algorithm:<br>
<span class="math-container">$$X_j + \s... | algorithms | 1 | Difference between UCB1 and UCT -- (algorithms)
<p>In <a href="http://ggp.stanford.edu/readings/uct.pdf" rel="nofollow noreferrer">Bandit Based Monte-Carlo Planning</a> by Levente Kocsis and Csaba Szepesvári (2006) they propose the UCT algorithm which is derived from the UCB1 algorithm. </p>

<p>UCB1 algorithm:... | habedi/stack-exchange-dataset |
113,481 | Selecting a polygon within an array of complex polygons | <p>I have an array of polygons which are arrays of points. There are no gaps and none of them overlap like a Voronoi diagram.</p>

<p>Unlike a Voronoi diagram I cannot simply find the nearest centroid to select a polygon, this returns the correct polygon most of the time but sometimes the point lies within a ne... | polygons | 1 | Selecting a polygon within an array of complex polygons -- (polygons)
<p>I have an array of polygons which are arrays of points. There are no gaps and none of them overlap like a Voronoi diagram.</p>

<p>Unlike a Voronoi diagram I cannot simply find the nearest centroid to select a polygon, this returns the cor... | habedi/stack-exchange-dataset |
113,484 | Is properly quantified 3SAT complete for PSPACE and all PH levels? | <p>I know 3SAT is NP-complete and QSAT is PSPACE-complete. However, is it true that</p>

<p><span class="math-container">$$\exists X_1 \forall X_2 \cdots Q_k X_k \colon \varphi(X_1, \ldots, X_k)$$</span></p>

<p>is complete for <span class="math-container">$\Sigma_k$</span>, the existential side of leve... | complexity theory satisfiability | 1 | Is properly quantified 3SAT complete for PSPACE and all PH levels? -- (complexity theory satisfiability)
<p>I know 3SAT is NP-complete and QSAT is PSPACE-complete. However, is it true that</p>

<p><span class="math-container">$$\exists X_1 \forall X_2 \cdots Q_k X_k \colon \varphi(X_1, \ldots, X_k)$$</span></p>... | habedi/stack-exchange-dataset |
113,485 | Recurrence relation (not solvable by the master theorem) | <p>Consider the following recursion:
<span class="math-container">$\begin{cases}
T(n) = 2T(\frac{n}{2}) + \frac{n}{\log n} &n > 1 \\
 O(1) &n = 1
\end{cases}$</span>.</p>

<p>The master theorem doesn't work, as the exponent of <span class="math-container">$\log n$</span> is ne... | time complexity | 1 | Recurrence relation (not solvable by the master theorem) -- (time complexity)
<p>Consider the following recursion:
<span class="math-container">$\begin{cases}
T(n) = 2T(\frac{n}{2}) + \frac{n}{\log n} &n > 1 \\
 O(1) &n = 1
\end{cases}$</span>.</p>

<p>The master theorem doesn... | habedi/stack-exchange-dataset |
113,500 | Decidability of decision problems | <p>Can somebody give intuition how to answer those questions? From one side I can say that most of them are undecidable because we can reduce the halting problem to them (or halting problem can appear because we don't know about given TM anything so it can behave unpredictably, can simply loop on any input), but on ano... | turing machines undecidability decision problem semi decidability rice theorem | 1 | Decidability of decision problems -- (turing machines undecidability decision problem semi decidability rice theorem)
<p>Can somebody give intuition how to answer those questions? From one side I can say that most of them are undecidable because we can reduce the halting problem to them (or halting problem can appear b... | habedi/stack-exchange-dataset |
113,511 | Longest path in a directed acyclic graph with constraints | <p>Given a directed weighted acyclic graph <em>G=(V,D,W)</em> and a subset of edges <em>D'</em> of <em>D</em>. The problem is to find the longest path in <em>G</em> that passes by exactly one edge of <em>D'</em>. </p>

<p>What is the complexity of this problem?</p>
 | algorithms complexity theory graphs weighted graphs | 1 | Longest path in a directed acyclic graph with constraints -- (algorithms complexity theory graphs weighted graphs)
<p>Given a directed weighted acyclic graph <em>G=(V,D,W)</em> and a subset of edges <em>D'</em> of <em>D</em>. The problem is to find the longest path in <em>G</em> that passes by exactly one edge of <em>D... | habedi/stack-exchange-dataset |
113,515 | How to schedule events optimally given when the events are available? | <p>Suppose I had a dictionary that contains events and the corresponding periods they are occurring. For example:</p>

<p><span class="math-container">$$
\begin{align}
\textrm{Event 1} &\rightarrow \textrm{[1, 2, 3]} \\
\textrm{Event 2} &\rightarrow \textrm{[2, 4]} \\
\textrm{Event 3} &a... | algorithms scheduling | 1 | How to schedule events optimally given when the events are available? -- (algorithms scheduling)
<p>Suppose I had a dictionary that contains events and the corresponding periods they are occurring. For example:</p>

<p><span class="math-container">$$
\begin{align}
\textrm{Event 1} &\rightarrow \text... | habedi/stack-exchange-dataset |
113,529 | Maximizing total value given bound on total cost | <p>I have a list of pairs with values and costs:</p>

<pre><code> | value | cost | 
 11, 1000 
 7, 700
 7, 700
 6, 700
 2, 400
 2, 500
 1, 600
</code></pre>

<p>The list is ordered by value/cost decreasingly.
The task is, given a budge... | algorithms | 1 | Maximizing total value given bound on total cost -- (algorithms)
<p>I have a list of pairs with values and costs:</p>

<pre><code> | value | cost | 
 11, 1000 
 7, 700
 7, 700
 6, 700
 2, 400
 2, 500
 1, 600
</code></pre>

<p>The list is o... | habedi/stack-exchange-dataset |
113,531 | Are these 2 equivalent? | <p>Is <strong>∀x∀y∀z[φ(x,y)∧p(y,z)->p(x,z)]</strong> equivalent to <strong>∀x∀y∀z[φ(x,y)∧p(x,z)->p(y,z)]</strong> ?</p>

<p>The only thing I can think of is that this question can be answered if we show that <code>p->q</code> is equals (↔) το <code>q->p</code>, but that's not true because <code>p->q ↔ ... | logic discrete mathematics propositional logic | 1 | Are these 2 equivalent? -- (logic discrete mathematics propositional logic)
<p>Is <strong>∀x∀y∀z[φ(x,y)∧p(y,z)->p(x,z)]</strong> equivalent to <strong>∀x∀y∀z[φ(x,y)∧p(x,z)->p(y,z)]</strong> ?</p>

<p>The only thing I can think of is that this question can be answered if we show that <code>p->q</code> is equa... | habedi/stack-exchange-dataset |
113,542 | Byte addressable vs Word addressable | <p>I am trying to understand the difference between byte addressing and word addressing.</p>

<blockquote>
 <p>A 4-way set-associative cache memory unit with a capacity of 16 KB is built using a block size of 8 words. The word length is 32 bits. The size of the physical address space is 4 GB. </p>
</bl... | memory access cache | 1 | Byte addressable vs Word addressable -- (memory access cache)
<p>I am trying to understand the difference between byte addressing and word addressing.</p>

<blockquote>
 <p>A 4-way set-associative cache memory unit with a capacity of 16 KB is built using a block size of 8 words. The word length is 32 bits.... | habedi/stack-exchange-dataset |
113,547 | Are computers infallible? | <p>(Not sure if this is the right place to ask this question.)</p>

<p>Let's say I get a computer to calculate 1+1. It should give 2, obviously. Will it always give 2? Is there any possible combination of circumstances that could cause a computer to, after finishing its calculations, give a number other than 2?... | turing machines | 1 | Are computers infallible? -- (turing machines)
<p>(Not sure if this is the right place to ask this question.)</p>

<p>Let's say I get a computer to calculate 1+1. It should give 2, obviously. Will it always give 2? Is there any possible combination of circumstances that could cause a computer to, after finishin... | habedi/stack-exchange-dataset |
113,555 | How to prove that in an AVL tree with height h, the depth of every leaf node is at least $\lceil h/2 \rceil$ | <p>I have an AVL tree with height h. I understand how to get h <span class="math-container">$\thickapprox$</span> 1.440 log N. However, I can't figure out how to calculate the minimum depth of a leaf node from root. I tried constructing a recursive formula where <code>d = 1 + min(dL, dR)</code> where dL and dR are the ... | data structures binary trees balanced search trees avl trees | 1 | How to prove that in an AVL tree with height h, the depth of every leaf node is at least $\lceil h/2 \rceil$ -- (data structures binary trees balanced search trees avl trees)
<p>I have an AVL tree with height h. I understand how to get h <span class="math-container">$\thickapprox$</span> 1.440 log N. However, I can't f... | habedi/stack-exchange-dataset |
113,558 | Maximum flow with maximum flow on specific edge | <p>I am trying to solve the following problem:</p>

<p>We're given a network flow <span class="math-container">$(V,E,c,s,t)$</span> and an edge <span class="math-container">$(u,v)$</span>. We have to provide an algorithm that computes the maximum flow which has maximum flow on <span class="math-container">$(u,v... | network flow | 1 | Maximum flow with maximum flow on specific edge -- (network flow)
<p>I am trying to solve the following problem:</p>

<p>We're given a network flow <span class="math-container">$(V,E,c,s,t)$</span> and an edge <span class="math-container">$(u,v)$</span>. We have to provide an algorithm that computes the maximum... | habedi/stack-exchange-dataset |
113,573 | With a grammar, does precedence and associativity change the accepted language? | <p>When parsing, certainly precedence and associativity effect the AST. But, do precedence and associativity alter the set of accepted sentences? In other words, can precedence and associativity be "ignored" (defined in some random precedence all associating left, say) in the grammar, and then the AST fixed later based... | formal grammars parsers | 1 | With a grammar, does precedence and associativity change the accepted language? -- (formal grammars parsers)
<p>When parsing, certainly precedence and associativity effect the AST. But, do precedence and associativity alter the set of accepted sentences? In other words, can precedence and associativity be "ignored" (de... | habedi/stack-exchange-dataset |
113,598 | Why is LinkedList useful? | <p>If you implement a stack with a dynamic array-based with LinkedList you need more memory than with a dynamic array, and with dynamic array for insert in amortized cost is O(1), so the advantage of the LinkedList now is not and advantage, so why you should use a LinkedList, and why is this a useful data structure?</p... | data structures arrays linked lists | 1 | Why is LinkedList useful? -- (data structures arrays linked lists)
<p>If you implement a stack with a dynamic array-based with LinkedList you need more memory than with a dynamic array, and with dynamic array for insert in amortized cost is O(1), so the advantage of the LinkedList now is not and advantage, so why you s... | habedi/stack-exchange-dataset |
113,600 | Lexicographic Order of Expression [Automata Theory] | <p>what will be kleene star "expansion" of expression <span class="math-container">$a^*b^*$</span> in lexicographic order?
I'm confused and I really want to clear my concepts so I can proceed further</p>
 | automata regular expressions kleene star | 1 | Lexicographic Order of Expression [Automata Theory] -- (automata regular expressions kleene star)
<p>what will be kleene star "expansion" of expression <span class="math-container">$a^*b^*$</span> in lexicographic order?
I'm confused and I really want to clear my concepts so I can proceed further</p>
 | habedi/stack-exchange-dataset |
113,608 | Choosing which workers (limited number) to use in a binary assignment problem? | <p>First of all, I am not completely sure whether this problem belong to the category of assignment problems so feel free to correct me in this case.</p>

<p>The problem:</p>

<p>We are given a set of <span class="math-container">$m$</span> workers <span class="math-container">$A = \{ a_1, a_2,...a_m \}... | algorithms optimization assignment problem | 1 | Choosing which workers (limited number) to use in a binary assignment problem? -- (algorithms optimization assignment problem)
<p>First of all, I am not completely sure whether this problem belong to the category of assignment problems so feel free to correct me in this case.</p>

<p>The problem:</p>

<... | habedi/stack-exchange-dataset |
114,628 | Coloring book. Finding region by point | <p>Let me explain what I want to achieve. I'm working on the coloring book project. On the input, I'm getting transparent images with black borders (Like <a href="https://imgur.com/bEhvYzL" rel="nofollow noreferrer">this</a>). Currently, I've created the 2D <code>Matrix</code> with colors in points. And basing on this ... | algorithms matrix | 1 | Coloring book. Finding region by point -- (algorithms matrix)
<p>Let me explain what I want to achieve. I'm working on the coloring book project. On the input, I'm getting transparent images with black borders (Like <a href="https://imgur.com/bEhvYzL" rel="nofollow noreferrer">this</a>). Currently, I've created the 2D ... | habedi/stack-exchange-dataset |
114,634 | P/NP - Polynomial Reduction vs Certificate | <p>I am learning about the P/NP problem right now, and I don't understand when to use polynomial reduction and when to use a certificate.</p>

<hr>

<p>How I understand polynomial reduction is that you can use it to show that:</p>

<ul>
<li>Problem A is in P if: </li>
</ul>

<p>B... | np decision problem polynomial time p vs np polynomial time reductions | 1 | P/NP - Polynomial Reduction vs Certificate -- (np decision problem polynomial time p vs np polynomial time reductions)
<p>I am learning about the P/NP problem right now, and I don't understand when to use polynomial reduction and when to use a certificate.</p>

<hr>

<p>How I understand polynomial reduc... | habedi/stack-exchange-dataset |
114,635 | Minimum Path cover in a Directed Acyclic Graph | <p>Given a weighted directed acyclic graph <span class="math-container">$G=(V,D,W)$</span> and a set of arcs <span class="math-container">$D'$</span> of <span class="math-container">$D$</span>, where the weights of <span class="math-container">$W$</span> are on the vertices. The problem is to partition <span class="mat... | algorithms complexity theory graphs weighted graphs hamiltonian path | 1 | Minimum Path cover in a Directed Acyclic Graph -- (algorithms complexity theory graphs weighted graphs hamiltonian path)
<p>Given a weighted directed acyclic graph <span class="math-container">$G=(V,D,W)$</span> and a set of arcs <span class="math-container">$D'$</span> of <span class="math-container">$D$</span>, where... | habedi/stack-exchange-dataset |
114,640 | Why does Coq include let-expressions in its core language | <p>Coq includes let-expressions in its core language.
We can translate let-expressions to applications like this:
<code>let x : t = v in b ~> (\(x:t). b) v</code>
I understand that this does not always work because the value <code>v</code> would not be available when typechecking <code>b</code>. However ... | type theory dependent types type checking coq | 1 | Why does Coq include let-expressions in its core language -- (type theory dependent types type checking coq)
<p>Coq includes let-expressions in its core language.
We can translate let-expressions to applications like this:
<code>let x : t = v in b ~> (\(x:t). b) v</code>
I understand that this does not a... | habedi/stack-exchange-dataset |
114,650 | Prove that a language is bounded if and only if it's finite | <p>Let's assume <span class="math-container">$L$</span> is a language. <span class="math-container">$L$</span> is <em>bounded</em> if for some natural number <span class="math-container">$n \in \mathbb N$</span> applies <span class="math-container">$|x| ≤ n$</span>, where <span class="math-container">$|x|$</span> is a ... | formal languages regular languages finite automata | 1 | Prove that a language is bounded if and only if it's finite -- (formal languages regular languages finite automata)
<p>Let's assume <span class="math-container">$L$</span> is a language. <span class="math-container">$L$</span> is <em>bounded</em> if for some natural number <span class="math-container">$n \in \mathbb N$... | habedi/stack-exchange-dataset |
114,664 | What time complexity is more significant? | <p>A certain algorithm executes <span class="math-container">$n$</span> operations of three types: insert, delete, and find.
We know that <span class="math-container">$n/10$</span> of the operations are inserts, and the rest are deletes and finds.</p>

<p>You are given two implementations of the algorithm. ... | runtime analysis amortized analysis | 1 | What time complexity is more significant? -- (runtime analysis amortized analysis)
<p>A certain algorithm executes <span class="math-container">$n$</span> operations of three types: insert, delete, and find.
We know that <span class="math-container">$n/10$</span> of the operations are inserts, and the rest are dele... | habedi/stack-exchange-dataset |
114,673 | Is it possible to have high compression but low predictability? | <p>Can you have a process that generates a binary sequence with high compression rate (low entropy) but impossible to predict next symbol?</p>

<p>'impossible to predict' - sequence cannot be predicted theoretically. But I was also asking about the real life example (no polynomial algorithm).</p>
 | complexity theory information theory data compression | 1 | Is it possible to have high compression but low predictability? -- (complexity theory information theory data compression)
<p>Can you have a process that generates a binary sequence with high compression rate (low entropy) but impossible to predict next symbol?</p>

<p>'impossible to predict' - sequence cannot ... | habedi/stack-exchange-dataset |
114,676 | Planar regular languages | <p>In my class a student asked whether all finite automata could be drawn without crossing edges (it seems all my examples did). Of course the answer is negative, the obvious automaton for the language <span class="math-container">$\{\; x\in\{a,b\}^* \mid \#_a(x)+2\#_b(x) \equiv 0 \mod 5 \;\}$</span> has the structure ... | regular languages finite automata planar graphs | 1 | Planar regular languages -- (regular languages finite automata planar graphs)
<p>In my class a student asked whether all finite automata could be drawn without crossing edges (it seems all my examples did). Of course the answer is negative, the obvious automaton for the language <span class="math-container">$\{\; x\in\... | habedi/stack-exchange-dataset |
114,690 | What is the Time complexity of this sorting algo? | <p>So i was trying to write an efficient sorting algorithm and i came up with this method,</p>

<blockquote>
 <p>Sorting an array in ascending order by flipping (exchanging) 2
 adjacent integers not in the correct order until there is no such
 pair.</p>
 
 <p>The leftmost swappable pair... | algorithms sorting | 1 | What is the Time complexity of this sorting algo? -- (algorithms sorting)
<p>So i was trying to write an efficient sorting algorithm and i came up with this method,</p>

<blockquote>
 <p>Sorting an array in ascending order by flipping (exchanging) 2
 adjacent integers not in the correct order until th... | habedi/stack-exchange-dataset |
114,694 | Language containing all unambiguous grammars | <p>Suppose <span class="math-container">$L$</span> is the language of the <em>unambiguous grammars</em>. That is, a sentence <span class="math-container">$w\in{}L$</span> if it is a string that describes an unambiguous context-free grammar.</p>

<p>Considering that deciding whether a context-free grammar is amb... | formal languages formal grammars undecidability | 1 | Language containing all unambiguous grammars -- (formal languages formal grammars undecidability)
<p>Suppose <span class="math-container">$L$</span> is the language of the <em>unambiguous grammars</em>. That is, a sentence <span class="math-container">$w\in{}L$</span> if it is a string that describes an unambiguous con... | habedi/stack-exchange-dataset |
114,704 | What are some decidable problems which cannot be solved in real life(due to time and memory constraints)? | <p>The first line of Sipser book for the Chapter- 'Time complexity', says that:</p>

<p>Even when a problem is decidable and thus computationally solvable in principle, it may not be solvable in practice if the solution requires an inordinate amount of time or memory.</p>

<p>My question is, yes we do h... | time complexity undecidability space complexity | 1 | What are some decidable problems which cannot be solved in real life(due to time and memory constraints)? -- (time complexity undecidability space complexity)
<p>The first line of Sipser book for the Chapter- 'Time complexity', says that:</p>

<p>Even when a problem is decidable and thus computationally solvabl... | habedi/stack-exchange-dataset |
114,709 | Is following grammar has language which is inherently ambiguous? | <p>Grammar is as follow:</p>

<p><span class="math-container">$S \rightarrow aaAb | aab | A$</span></p>

<p><span class="math-container">$A \rightarrow aaAb | aAb | \epsilon$</span></p>

<p>I think that this grammar has equivalent unambiguous grammar as follow.</p>

<p>Let’s first rewrit... | context free formal grammars ambiguity | 1 | Is following grammar has language which is inherently ambiguous? -- (context free formal grammars ambiguity)
<p>Grammar is as follow:</p>

<p><span class="math-container">$S \rightarrow aaAb | aab | A$</span></p>

<p><span class="math-container">$A \rightarrow aaAb | aAb | \epsilon$</span></p>

... | habedi/stack-exchange-dataset |
114,722 | Algorithm to find a simple path with maximum weight less than a constant in DAG | <p>Given a weighted directed acyclic graph <span class="math-container">$G=(V,E,W)$</span>, where the weights are non-negative and are on the vertices. I am searching for a simple path of maximum total weight, but this total weight should not exceed a given constant <span class="math-container">$K$</span>.</p>

... | algorithms complexity theory graphs np hard | 1 | Algorithm to find a simple path with maximum weight less than a constant in DAG -- (algorithms complexity theory graphs np hard)
<p>Given a weighted directed acyclic graph <span class="math-container">$G=(V,E,W)$</span>, where the weights are non-negative and are on the vertices. I am searching for a simple path of max... | habedi/stack-exchange-dataset |
114,723 | Smallest integer i stored as a float such that i+1=i | <p>So I had an assignment which asked me to find the smallest integer <span class="math-container">$i$</span> which when represented as a float is such that <span class="math-container">$i+1=i$</span></p>

<p>My approach- By making a simple C++ program , we get <span class="math-container">$i=16777216$</span> o... | floating point | 1 | Smallest integer i stored as a float such that i+1=i -- (floating point)
<p>So I had an assignment which asked me to find the smallest integer <span class="math-container">$i$</span> which when represented as a float is such that <span class="math-container">$i+1=i$</span></p>

<p>My approach- By making a simpl... | habedi/stack-exchange-dataset |
114,726 | What is the relation between the formal definition of strictness and its intuitive notion | <p>I am currently reading <em>Functional Programming in Scala</em> and have encountered a statement in the book I cannot quite make sense of.</p>

<p>On page 67, we are told the formal definition of strictness:</p>

<p>"If the evaluation of an expression runs forever or throws an error instead of return... | functional programming | 1 | What is the relation between the formal definition of strictness and its intuitive notion -- (functional programming)
<p>I am currently reading <em>Functional Programming in Scala</em> and have encountered a statement in the book I cannot quite make sense of.</p>

<p>On page 67, we are told the formal definitio... | habedi/stack-exchange-dataset |
114,734 | Why does Bellman-Ford algorithm use < rather than ≤? | <p>The <a href="https://en.wikipedia.org/wiki/Bellman%E2%80%93Ford_algorithm" rel="nofollow noreferrer">Bellman-Ford Algorithm</a> uses a less-than symbol rather than a less-than-or-equal-to symbol. How does this identify that there is a negative cycle? </p>

<p>For instance, say I have the below example going ... | algorithms graphs algorithm analysis | 1 | Why does Bellman-Ford algorithm use < rather than ≤? -- (algorithms graphs algorithm analysis)
<p>The <a href="https://en.wikipedia.org/wiki/Bellman%E2%80%93Ford_algorithm" rel="nofollow noreferrer">Bellman-Ford Algorithm</a> uses a less-than symbol rather than a less-than-or-equal-to symbol. How does this identify tha... | habedi/stack-exchange-dataset |
114,745 | Generate all combinations of values that are less than array's elements and have a sum = target | <p>I want to find a way to generate sets that contain elements that sum to a certain target. Initially, I have an array that contains elements representing the maximum value that can be stored in that index.</p>

<p>For example, the input is [8,6,1] and the target is 10. The algorithm should produce all sets th... | algorithms subset sum | 1 | Generate all combinations of values that are less than array's elements and have a sum = target -- (algorithms subset sum)
<p>I want to find a way to generate sets that contain elements that sum to a certain target. Initially, I have an array that contains elements representing the maximum value that can be stored in t... | habedi/stack-exchange-dataset |
114,751 | Show that $L:=\{(a^{k}b)^{i}|i,k \epsilon \mathbb{N}_{+} \}$ is context-sensitve. (With context-sensitive/noncontracting grammar) | <p>I am studying for an upcoming exam and this is an old exam question from two years ago (all exams were made available through our lecturer):</p>

<p>Show that <span class="math-container">$L:=\{(a^{k}b)^{i}|i,k \epsilon \mathbb{N}_{+} \}$</span> is context-sensitve.</p>

<p>I could easily construct a... | formal languages formal grammars context sensitive | 1 | Show that $L:=\{(a^{k}b)^{i}|i,k \epsilon \mathbb{N}_{+} \}$ is context-sensitve. (With context-sensitive/noncontracting grammar) -- (formal languages formal grammars context sensitive)
<p>I am studying for an upcoming exam and this is an old exam question from two years ago (all exams were made available through our l... | habedi/stack-exchange-dataset |
114,754 | Finding partition with maximum number of edges between sets | <p>Given a graph (say in adjacency list form), is there an algorithm to find a partition of vertices such that the number of edges between the two sets of the partition is the maximum possible?</p>

<p>For example, for the following set of edges of a graph with vertex set <span class="math-container">$\{1, 2, 3... | graphs partitions | 1 | Finding partition with maximum number of edges between sets -- (graphs partitions)
<p>Given a graph (say in adjacency list form), is there an algorithm to find a partition of vertices such that the number of edges between the two sets of the partition is the maximum possible?</p>

<p>For example, for the follow... | habedi/stack-exchange-dataset |
114,776 | Proving with co-induction principles | <p>I'm going through Adam Chlipala's "Certified Programming with Dependent Types" (available <a href="http://adam.chlipala.net/cpdt/html/Coinductive.html" rel="nofollow noreferrer">here</a> for convenience), and I'm a bit stuck at internalizing the introduction of co-induction principle for the <code>stream_eq</code> p... | proof techniques formal methods coq coinduction | 1 | Proving with co-induction principles -- (proof techniques formal methods coq coinduction)
<p>I'm going through Adam Chlipala's "Certified Programming with Dependent Types" (available <a href="http://adam.chlipala.net/cpdt/html/Coinductive.html" rel="nofollow noreferrer">here</a> for convenience), and I'm a bit stuck at... | habedi/stack-exchange-dataset |
114,778 | Busy-Beaver-like question for WHILE-Programs (Theoretical CS) | <p>So this is exam-task is called "Busy WHILE-Programs"</p>

<p>In our lecture it was proven that WHILE-Programs are turing-complete. In short a WHILE-Program only allows the following:</p>

<pre><code>Variables x1,x2,... (initially all 0 and can only be positive)
Constants c ... | computability halting problem busy beaver | 1 | Busy-Beaver-like question for WHILE-Programs (Theoretical CS) -- (computability halting problem busy beaver)
<p>So this is exam-task is called "Busy WHILE-Programs"</p>

<p>In our lecture it was proven that WHILE-Programs are turing-complete. In short a WHILE-Program only allows the following:</p>

<pre... | habedi/stack-exchange-dataset |
114,779 | Maximum-cardinality matching in unbalanced bipartite graphs | <p>Let <span class="math-container">$G = (X+Y, E)$</span> be a bipartite graph, and suppose we want to find a maximum-cardinality matching in <span class="math-container">$G$</span>.
The <a href="https://en.wikipedia.org/wiki/Hopcroft%E2%80%93Karp_algorithm" rel="nofollow noreferrer">Hopcroft-Karp algorithm</a> run... | optimization reference request runtime analysis bipartite matching | 1 | Maximum-cardinality matching in unbalanced bipartite graphs -- (optimization reference request runtime analysis bipartite matching)
<p>Let <span class="math-container">$G = (X+Y, E)$</span> be a bipartite graph, and suppose we want to find a maximum-cardinality matching in <span class="math-container">$G$</span>.
T... | habedi/stack-exchange-dataset |
114,780 | Random restarts for unsatisfiable instances | <p>In the worst case, Boolean satisfiability (assuming P!=NP) takes exponential time. Nonetheless, modern SAT solvers using variants of DPLL, are able to solve enough instances to be useful in practice.</p>

<p>One technique used, that has shown good results in practice, is random restart. Intuitively, randomly... | satisfiability randomized algorithms 3 sat sat solvers | 1 | Random restarts for unsatisfiable instances -- (satisfiability randomized algorithms 3 sat sat solvers)
<p>In the worst case, Boolean satisfiability (assuming P!=NP) takes exponential time. Nonetheless, modern SAT solvers using variants of DPLL, are able to solve enough instances to be useful in practice.</p>

... | habedi/stack-exchange-dataset |
114,797 | How can any non-primitive-recursive function like the Ackermann function be implemented on hardware? | <p>If for-loops and function calls both boil down to jump instructions when implemented on a real machine, then how is "The Ackermann function isn't implementable with for-loops" a meaningful phrase?</p>
 | computer architecture recursion | 1 | How can any non-primitive-recursive function like the Ackermann function be implemented on hardware? -- (computer architecture recursion)
<p>If for-loops and function calls both boil down to jump instructions when implemented on a real machine, then how is "The Ackermann function isn't implementable with for-loops" a m... | habedi/stack-exchange-dataset |
114,802 | How can $A \cup B$ be decidable if $B$ is undecidable? | <p>My assignment says:</p>

<p>"Determine if the following statement is correct:
If <span class="math-container">$A$</span> and <span class="math-container">$A \cup B$</span> are decidable, then <span class="math-container">$B$</span> is decidable."</p>

<p>The solution says: </p>

<p>"Incor... | turing machines undecidability sets | 1 | How can $A \cup B$ be decidable if $B$ is undecidable? -- (turing machines undecidability sets)
<p>My assignment says:</p>

<p>"Determine if the following statement is correct:
If <span class="math-container">$A$</span> and <span class="math-container">$A \cup B$</span> are decidable, then <span class="math... | habedi/stack-exchange-dataset |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.