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
119,061
Find number of awesome substring of a given binary string
<p>A binary string is given to us and we need to find number of awesome substring of that string .Definition of awesome string : A string is awesome if its length is divisible by number of 1's in it.</p>&#xA;&#xA;<p>For example :111 has 6 awesome substrings.01010 has 10 awesome substrings .In "01010" one such awesome s...
algorithms data structures strings
1
Find number of awesome substring of a given binary string -- (algorithms data structures strings) <p>A binary string is given to us and we need to find number of awesome substring of that string .Definition of awesome string : A string is awesome if its length is divisible by number of 1's in it.</p>&#xA;&#xA;<p>For ex...
habedi/stack-exchange-dataset
119,071
How does a GPU get data from a CPU?
<p>From what I’ve read, the CPU has to send the data to the GPU before the GPU can do anything with it. But, if that’s the case, won’t any time saved using the GPU be negated by the time taken to transfer that data? Wouldn’t that kind of defeat the whole purpose of a GPU?</p>&#xA;
computer architecture
1
How does a GPU get data from a CPU? -- (computer architecture) <p>From what I’ve read, the CPU has to send the data to the GPU before the GPU can do anything with it. But, if that’s the case, won’t any time saved using the GPU be negated by the time taken to transfer that data? Wouldn’t that kind of defeat the whole pu...
habedi/stack-exchange-dataset
119,077
Assume that NP = DTIME(2^sqrt(n)), prove that DTIME(2^sqrt(n)) = DTIME(2^n)
<p>I tried using the padding argument to prove such a thing (as it appeared in Arora's book), but I am not sure how this technique will help me here. I am trying to get to a contradiction to the Time Hierarchy Theorem.</p>&#xA;&#xA;<p>After the assumption, I want to prove that <span class="math-container">$\mathsf{NP} ...
complexity theory turing machines time complexity np complexity classes
1
Assume that NP = DTIME(2^sqrt(n)), prove that DTIME(2^sqrt(n)) = DTIME(2^n) -- (complexity theory turing machines time complexity np complexity classes) <p>I tried using the padding argument to prove such a thing (as it appeared in Arora's book), but I am not sure how this technique will help me here. I am trying to ge...
habedi/stack-exchange-dataset
119,084
Textbook for understanding formal grammars
<p>I am looking to understand the Chomsky Hierarchy. I've read some textbooks that <em>touch</em> on formal grammars (textbooks on computability, which relate automata to specific sets of formal grammars, notably context-free grammars and regular grammars), but not one that specifically deals with formal grammars as an...
formal languages formal grammars reference request books
1
Textbook for understanding formal grammars -- (formal languages formal grammars reference request books) <p>I am looking to understand the Chomsky Hierarchy. I've read some textbooks that <em>touch</em> on formal grammars (textbooks on computability, which relate automata to specific sets of formal grammars, notably co...
habedi/stack-exchange-dataset
119,085
Dijkstra shortest path yields unintuitive results
<p>Considering the following nodes with edge weights in red, Dijkstra's shortest path algorithm seems to return incorrect results, at least by the definition of the steps on <a href="https://en.wikipedia.org/wiki/Dijkstra%27s_algorithm#Algorithm" rel="nofollow noreferrer">wikipedia</a>. By those rules, the distance fro...
graphs shortest path weighted graphs
1
Dijkstra shortest path yields unintuitive results -- (graphs shortest path weighted graphs) <p>Considering the following nodes with edge weights in red, Dijkstra's shortest path algorithm seems to return incorrect results, at least by the definition of the steps on <a href="https://en.wikipedia.org/wiki/Dijkstra%27s_al...
habedi/stack-exchange-dataset
119,097
Encoding set of At-Most-One constraints as a MAX-SAT problem
<p>Assume a set of variable <span class="math-container">$V$</span> = <span class="math-container">$\{v_1,...,v_m\}$</span>.</p>&#xA;<p>Given total <span class="math-container">$n$</span> at-most-one (AMO) constraints (at most one element in a given set is <em>true</em>) set [of the below form], over the variable set <...
optimization satisfiability discrete mathematics maxsat
1
Encoding set of At-Most-One constraints as a MAX-SAT problem -- (optimization satisfiability discrete mathematics maxsat) <p>Assume a set of variable <span class="math-container">$V$</span> = <span class="math-container">$\{v_1,...,v_m\}$</span>.</p>&#xA;<p>Given total <span class="math-container">$n$</span> at-most-on...
habedi/stack-exchange-dataset
119,099
Structure for getting $| \{ a,b \} \subset S : a+b \le d|$ in O(1)
<p>I am struggling with exercise from the old algorithmic exam: <br>&#xA;<span class="math-container">$d$</span> is const for the whole structure.&#xA;Propose a structure for which you can do:</p>&#xA;&#xA;<ul>&#xA;<li>Init(S) //called only 1 time</li>&#xA;<li>Insert(x, S):: <span class="math-container">$ S := S \cup ...
algorithms data structures avl trees
1
Structure for getting $| \{ a,b \} \subset S : a+b \le d|$ in O(1) -- (algorithms data structures avl trees) <p>I am struggling with exercise from the old algorithmic exam: <br>&#xA;<span class="math-container">$d$</span> is const for the whole structure.&#xA;Propose a structure for which you can do:</p>&#xA;&#xA;<ul>&...
habedi/stack-exchange-dataset
119,114
min vertex cover to access k edges in a tree
<p>I need to find the minimum number out of <span class="math-container">$N$</span> vertices on a tree with <span class="math-container">$N-1$</span> edges, so that at least <span class="math-container">$K$</span> edges of that tree are connected to these vertices.</p>&#xA;&#xA;<p>For example, if <span class="math-cont...
algorithms graphs dynamic programming vertex cover
1
min vertex cover to access k edges in a tree -- (algorithms graphs dynamic programming vertex cover) <p>I need to find the minimum number out of <span class="math-container">$N$</span> vertices on a tree with <span class="math-container">$N-1$</span> edges, so that at least <span class="math-container">$K$</span> edges...
habedi/stack-exchange-dataset
119,123
Proof for clustering in a network of friendship
<p>Consider an undirected graph <span class="math-container">$G = (V, E)$</span> representing the social network of friendship/trust between&#xA;students. We would like to form teams of three students that know each other. The question&#xA;is to decide whether the network allows for enough such teams, without checking ...
algorithms graphs clustering
1
Proof for clustering in a network of friendship -- (algorithms graphs clustering) <p>Consider an undirected graph <span class="math-container">$G = (V, E)$</span> representing the social network of friendship/trust between&#xA;students. We would like to form teams of three students that know each other. The question&#x...
habedi/stack-exchange-dataset
119,130
does a non-terminated string count as a token in c?
<p>so, I am preparing for an exam which includes lexical analysis from compiler design. I was wondering what is the number of tokens in the following code-</p>&#xA;&#xA;<pre><code>int main() {&#xA; /* comment&#xA; printf("Hello */ There ");*/&#xA; return 0;&#xA;}&#xA;</code></pre>&#xA;&#xA;<p>so, I am thinking upto ...
compilers c lexical analysis
1
does a non-terminated string count as a token in c? -- (compilers c lexical analysis) <p>so, I am preparing for an exam which includes lexical analysis from compiler design. I was wondering what is the number of tokens in the following code-</p>&#xA;&#xA;<pre><code>int main() {&#xA; /* comment&#xA; printf("Hello */ T...
habedi/stack-exchange-dataset
119,147
Partitioning a set based on binary predicate
<p>Given a collection of objects <span class="math-container">$X = (x_0,x_1,...,x_{N-1})$</span> and a binary predicate <span class="math-container">$F$</span> which takes as parameters elements of the collection, find a better than <span class="math-container">$\mathcal{O}(N^2)$</span> algorithm which partitions the s...
algorithms complexity theory algorithm analysis time complexity
1
Partitioning a set based on binary predicate -- (algorithms complexity theory algorithm analysis time complexity) <p>Given a collection of objects <span class="math-container">$X = (x_0,x_1,...,x_{N-1})$</span> and a binary predicate <span class="math-container">$F$</span> which takes as parameters elements of the coll...
habedi/stack-exchange-dataset
119,151
Search for maximal value smaller than V in an array composed of K linear functions
<p>Sorry for the lack of clarity in the question description.</p>&#xA;&#xA;<p>I have an array composed of length <span class="math-container">$N$</span> composed of <span class="math-container">$K$</span> linear subarrays. We define a linear subarray as a contiguous subarray of the array <span class="math-container">$[...
algorithms data structures search algorithms
1
Search for maximal value smaller than V in an array composed of K linear functions -- (algorithms data structures search algorithms) <p>Sorry for the lack of clarity in the question description.</p>&#xA;&#xA;<p>I have an array composed of length <span class="math-container">$N$</span> composed of <span class="math-cont...
habedi/stack-exchange-dataset
119,157
What's the difference between phi and lambda in regular expression?
<p>I've been learning on <em>Formal Languages and Automata</em> of Peter Linz(6th edition).<br>&#xA;In the chapter 3 of this book, it explains the <strong>primitive regular expression</strong>. </p>&#xA;&#xA;<p>But I don't know what is the difference between <span class="math-container">$\phi$</span> and <span class="...
formal languages terminology regular expressions
1
What's the difference between phi and lambda in regular expression? -- (formal languages terminology regular expressions) <p>I've been learning on <em>Formal Languages and Automata</em> of Peter Linz(6th edition).<br>&#xA;In the chapter 3 of this book, it explains the <strong>primitive regular expression</strong>. </p...
habedi/stack-exchange-dataset
119,167
Dynamic data structure that checks all prefix sums of a subsequence are >= 0 and sum is = 0
<p>Lets consider sequences whose elements are <span class="math-container">$-1,0,1$</span>. <br>&#xA;Subsequence <span class="math-container">$A[i...j]$</span> is <span class="math-container">$good$</span> if sum of its elements <span class="math-container">$=0$</span>. <br>&#xA;Example: for sequence <span class="math-...
data structures binary trees avl trees
1
Dynamic data structure that checks all prefix sums of a subsequence are >= 0 and sum is = 0 -- (data structures binary trees avl trees) <p>Lets consider sequences whose elements are <span class="math-container">$-1,0,1$</span>. <br>&#xA;Subsequence <span class="math-container">$A[i...j]$</span> is <span class="math-con...
habedi/stack-exchange-dataset
119,175
Exact meaning of metalinguistic variable
<p>Consider the following BNF</p>&#xA;&#xA;<pre><code>&lt;join-command&gt; ::= &lt;string&gt; + &lt;string&gt;&#xA;</code></pre>&#xA;&#xA;<p>In this context <code>&lt;join-command&gt;</code> and <code>&lt;string&gt;</code> are normally called <em>metalinguistic variables</em> or <em>syntactic categories</em>. Note that...
formal languages terminology programming languages
1
Exact meaning of metalinguistic variable -- (formal languages terminology programming languages) <p>Consider the following BNF</p>&#xA;&#xA;<pre><code>&lt;join-command&gt; ::= &lt;string&gt; + &lt;string&gt;&#xA;</code></pre>&#xA;&#xA;<p>In this context <code>&lt;join-command&gt;</code> and <code>&lt;string&gt;</code> ...
habedi/stack-exchange-dataset
119,186
how to proof ${ NPC \bigcap CO-NPC \ne \varnothing then NP = P ? }$
<p>how proof <span class="math-container">${\ \ NPC \ \ \bigcap \ \ CO-NPC \ne \varnothing }$</span> <br> then &#xA;<span class="math-container">${NP = P ? }$</span></p>&#xA;
complexity theory time complexity np complete complexity classes p vs np
1
how to proof ${ NPC \bigcap CO-NPC \ne \varnothing then NP = P ? }$ -- (complexity theory time complexity np complete complexity classes p vs np) <p>how proof <span class="math-container">${\ \ NPC \ \ \bigcap \ \ CO-NPC \ne \varnothing }$</span> <br> then &#xA;<span class="math-container">${NP = P ? }$</span></...
habedi/stack-exchange-dataset
119,191
Proof that $G$ is a yes-instance of IDS $\iff$ $f(G)$ is a yes-instance of SAT
<p>Consider the <strong>Independent Dominating Set</strong> problem with a directed graph <span class="math-container">$G=(V,E)$</span> as instance and the properties that:</p>&#xA;&#xA;<ol>&#xA;<li><span class="math-container">$\forall (u,v) \in E, \{u,v\}\nsubseteq S$</span></li>&#xA;<li><span class="math-container">...
complexity theory
1
Proof that $G$ is a yes-instance of IDS $\iff$ $f(G)$ is a yes-instance of SAT -- (complexity theory) <p>Consider the <strong>Independent Dominating Set</strong> problem with a directed graph <span class="math-container">$G=(V,E)$</span> as instance and the properties that:</p>&#xA;&#xA;<ol>&#xA;<li><span class="math-c...
habedi/stack-exchange-dataset
119,207
Third Normal Form and Boyce Code normal form
<p>I know that this is not a question answer site but for sake of explaining my doubt I have to post the entire question..</p>&#xA;&#xA;<blockquote>&#xA; <p>Consider the following statements.</p>&#xA;&#xA;<pre><code>If relation R is in 3NF and every key is simple, then R is in BCNF&#xA;If relation R is in 3NF and R ha...
databases
1
Third Normal Form and Boyce Code normal form -- (databases) <p>I know that this is not a question answer site but for sake of explaining my doubt I have to post the entire question..</p>&#xA;&#xA;<blockquote>&#xA; <p>Consider the following statements.</p>&#xA;&#xA;<pre><code>If relation R is in 3NF and every key is si...
habedi/stack-exchange-dataset
119,212
Closure properties of non-context-free languages (concatenation & complement)
<p>I am trying to proof the properties of the complement and concatenation of two non-context-free languages <span class="math-container">$L_1$</span> and <span class="math-container">$L_2$</span>.<br>&#xA;I believe that both of these languages are closed under complement and concatenation but can't seem to find a soli...
formal languages context free
1
Closure properties of non-context-free languages (concatenation & complement) -- (formal languages context free) <p>I am trying to proof the properties of the complement and concatenation of two non-context-free languages <span class="math-container">$L_1$</span> and <span class="math-container">$L_2$</span>.<br>&#xA;I...
habedi/stack-exchange-dataset
119,219
Are every 2 DFAs with $n$ states for a language $L$ isomorphic to each other?
<p>Consider 2 DFAs both determining a language <span class="math-container">$L$</span>. Both DFAs have the same number of states <span class="math-container">$n$</span>. Can I then conclude that these two DFAs are isomorphic? </p>&#xA;&#xA;<p>I think the answer is yes, because if I'd make an <span class="math-containe...
regular languages finite automata
1
Are every 2 DFAs with $n$ states for a language $L$ isomorphic to each other? -- (regular languages finite automata) <p>Consider 2 DFAs both determining a language <span class="math-container">$L$</span>. Both DFAs have the same number of states <span class="math-container">$n$</span>. Can I then conclude that these tw...
habedi/stack-exchange-dataset
119,225
Why is there a precision loss for floating-point numbers?
<p>It could be a silly question, yet I'm not able to understand.&#xA;In modern day, computers, we have integers with million digits length. Even in my ordinary 2GB laptop, I can calculate values of numbers up to thousand digits long, but the value of a floating-point calculation is often limited to 15 digits or worse, ...
floating point
1
Why is there a precision loss for floating-point numbers? -- (floating point) <p>It could be a silly question, yet I'm not able to understand.&#xA;In modern day, computers, we have integers with million digits length. Even in my ordinary 2GB laptop, I can calculate values of numbers up to thousand digits long, but the ...
habedi/stack-exchange-dataset
119,241
Understanding How Double Precision Numbers are Stored in a Computer
<p>I am reading <em>Numerical Analysis</em> by Walter Gautschi. I am somewhat confused by the following quote from page <span class="math-container">$5$</span>:</p>&#xA;&#xA;<blockquote>&#xA; <p>To increase the precision, one can use two machine registers to represent a machine number. In effect, one then embeds <span...
computer architecture floating point
1
Understanding How Double Precision Numbers are Stored in a Computer -- (computer architecture floating point) <p>I am reading <em>Numerical Analysis</em> by Walter Gautschi. I am somewhat confused by the following quote from page <span class="math-container">$5$</span>:</p>&#xA;&#xA;<blockquote>&#xA; <p>To increase th...
habedi/stack-exchange-dataset
119,242
Prove/disprove: If $_1$ is a finite language but not empty and $_2$ is NOT regular then $_1 \circ _2$ is NOT regular
<p>That what I have so far, but I am not sure at all.</p>&#xA;&#xA;<p>Assume toward contradiction that <span class="math-container">$_1 \circ _2$</span> is regular.</p>&#xA;&#xA;<p>Define <span class="math-container">$\Sigma' = \{\sigma'|\sigma\in\Sigma\} $</span>.</p>&#xA;&#xA;<p>Define a regular substitution <span cl...
automata regular languages finite automata context free closure properties
1
Prove/disprove: If $_1$ is a finite language but not empty and $_2$ is NOT regular then $_1 \circ _2$ is NOT regular -- (automata regular languages finite automata context free closure properties) <p>That what I have so far, but I am not sure at all.</p>&#xA;&#xA;<p>Assume toward contradiction that <span class="math-co...
habedi/stack-exchange-dataset
119,265
Hindley-Milner system with let expansion
<p>I'm reading <a href="http://www.csc.kth.se/~austrin/DD3350/slides/types_poly.pdf" rel="nofollow noreferrer">these slides</a> that present Hindley-Milner type inference. In the system HM, we have the following let rule:</p>&#xA;&#xA;<p><span class="math-container">$\dfrac{\Gamma \vdash t:S \;\; \Gamma,x:S \vdash t':T...
programming languages lambda calculus type inference
1
Hindley-Milner system with let expansion -- (programming languages lambda calculus type inference) <p>I'm reading <a href="http://www.csc.kth.se/~austrin/DD3350/slides/types_poly.pdf" rel="nofollow noreferrer">these slides</a> that present Hindley-Milner type inference. In the system HM, we have the following let rule:...
habedi/stack-exchange-dataset
119,270
Upper bound on the average number of overlaps for an interval within a set of intervals
<p>Let <span class="math-container">$\mathcal{I}$</span> be a set of intervals with cardinality <span class="math-container">$L$</span>, where each interval <span class="math-container">$I_i \in \mathcal{I}$</span> is of the form <span class="math-container">$[a_i, b_i]$</span> and <span class="math-container">$a_i, b_...
algorithms reference request scheduling upper bound
1
Upper bound on the average number of overlaps for an interval within a set of intervals -- (algorithms reference request scheduling upper bound) <p>Let <span class="math-container">$\mathcal{I}$</span> be a set of intervals with cardinality <span class="math-container">$L$</span>, where each interval <span class="math-...
habedi/stack-exchange-dataset
119,274
Why do we need/use operator precedence for Arithmetic operators?
<p>Why do we use operator precedence rule for <strong>Arithmatic operators</strong>? Can't we simply just do the operation in a linear manner from left to right or vice-versa and deal with the operator that comes first.&#xA;For e.g. 2+3*4 = (2+3)*4 , if we do the operation from left to right.</p>&#xA;&#xA;<p>My guess w...
arithmetic mathematical programming
1
Why do we need/use operator precedence for Arithmetic operators? -- (arithmetic mathematical programming) <p>Why do we use operator precedence rule for <strong>Arithmatic operators</strong>? Can't we simply just do the operation in a linear manner from left to right or vice-versa and deal with the operator that comes f...
habedi/stack-exchange-dataset
119,284
Why aren’t distributed computing and/or GPU considered non-deterministic Turing machines if they can run multiple jobs at once?
<p>So we know a nondeterministic Turing machine (NTM) is just a theoretical model of computation. They are used in thought experiments to examine the abilities and limitations of computers. Commonly used to dicuss P vs NP, and how NP problems cannot be solved in polynomial time UNLESS the computation was done on the hy...
turing machines distributed systems parallel computing
1
Why aren’t distributed computing and/or GPU considered non-deterministic Turing machines if they can run multiple jobs at once? -- (turing machines distributed systems parallel computing) <p>So we know a nondeterministic Turing machine (NTM) is just a theoretical model of computation. They are used in thought experimen...
habedi/stack-exchange-dataset
119,290
Upper bound for set disjointness under product distributions
<p>For the set disjointness problem in the 2-party model of communication complexity, Alice is given an input <span class="math-container">$X$</span> and Bob is given input <span class="math-container">$Y$</span>, <span class="math-container">$X$</span> and <span class="math-container">$Y$</span> are <span class="math-...
information theory communication complexity
1
Upper bound for set disjointness under product distributions -- (information theory communication complexity) <p>For the set disjointness problem in the 2-party model of communication complexity, Alice is given an input <span class="math-container">$X$</span> and Bob is given input <span class="math-container">$Y$</spa...
habedi/stack-exchange-dataset
119,293
Minimum number of swaps in sorting sequence
<p>Given an array of N integer elements (<strong>not necessarily distinct</strong>), what is the minimum number of swaps (<strong>not necessarily adjacent</strong>) needed to sort the array?</p>&#xA;&#xA;<p>I've been struggling with this problem for a few months now. I know that the elements are distinct, the answer is...
algorithms graphs sorting
1
Minimum number of swaps in sorting sequence -- (algorithms graphs sorting) <p>Given an array of N integer elements (<strong>not necessarily distinct</strong>), what is the minimum number of swaps (<strong>not necessarily adjacent</strong>) needed to sort the array?</p>&#xA;&#xA;<p>I've been struggling with this problem...
habedi/stack-exchange-dataset
119,317
PSPACE-completeness of DFA intersection problem
<p>Let some deterministic finite automata be given. There is a problem of determining whether the intersection of these DFA is empty, and I want to show its PSPACE-completeness. </p>&#xA;&#xA;<p>It seems to me that I understand, why this problem lies in PSPACE: if <span class="math-container">$ n_1,\dots, n_k $</span> ...
complexity theory turing machines automata finite automata space complexity
1
PSPACE-completeness of DFA intersection problem -- (complexity theory turing machines automata finite automata space complexity) <p>Let some deterministic finite automata be given. There is a problem of determining whether the intersection of these DFA is empty, and I want to show its PSPACE-completeness. </p>&#xA;&#xA...
habedi/stack-exchange-dataset
119,322
Calculating match % and ranking according to that
<p>I'm creating a website like where users will answer some yes/no questions set by me, up to them how many of those questions they want to answer. After a user submits his answer(s), he will be shown top 5 matches along with their match percentages. If two users have 10 common questions and their answers match for 8 o...
algorithms complexity theory approximation
1
Calculating match % and ranking according to that -- (algorithms complexity theory approximation) <p>I'm creating a website like where users will answer some yes/no questions set by me, up to them how many of those questions they want to answer. After a user submits his answer(s), he will be shown top 5 matches along w...
habedi/stack-exchange-dataset
119,324
Generating all equal-sized set partitions
<p>Minor disclaimer: This is my first question here, so I hope it is the &#xA;right place to put it. </p>&#xA;&#xA;<hr>&#xA;&#xA;<p>Question: Is there an algorithm to exhaustively generate all set &#xA;partitions of equal size? That is, I want to list all possible ways to &#xA;divide a set of <span class="math-containe...
algorithms enumeration
1
Generating all equal-sized set partitions -- (algorithms enumeration) <p>Minor disclaimer: This is my first question here, so I hope it is the &#xA;right place to put it. </p>&#xA;&#xA;<hr>&#xA;&#xA;<p>Question: Is there an algorithm to exhaustively generate all set &#xA;partitions of equal size? That is, I want to lis...
habedi/stack-exchange-dataset
119,325
Algorithm for breaking a graph into sub-graphs based on an attribute
<p>I am a biologist doing some computational work. I encountered a problem and need some help since I don't have much algorithmic background. </p>&#xA;&#xA;<p><strong>The problem:</strong><br>&#xA;Assume we have a non-directed, weighted graph, in which every node has some categorical attribute, e.g. color. I want to b...
graphs weighted graphs
1
Algorithm for breaking a graph into sub-graphs based on an attribute -- (graphs weighted graphs) <p>I am a biologist doing some computational work. I encountered a problem and need some help since I don't have much algorithmic background. </p>&#xA;&#xA;<p><strong>The problem:</strong><br>&#xA;Assume we have a non-dire...
habedi/stack-exchange-dataset
119,327
How do I simplify $O\left({n^2}/{\log{\frac{n(n+1)}{2}}}\right)$
<p>I'm not very certain about how to deal with asymptotics when they are in the denominator. For <span class="math-container">$$O\left(\frac{n^2}{\log{\frac{n(n+1)}{2}}}\right)$$</span>, my intuition tells me that it should be treated in a similar way as little o. Would that be correct?</p>&#xA;&#xA;<p>Also, is this in...
asymptotics landau notation big o notation
1
How do I simplify $O\left({n^2}/{\log{\frac{n(n+1)}{2}}}\right)$ -- (asymptotics landau notation big o notation) <p>I'm not very certain about how to deal with asymptotics when they are in the denominator. For <span class="math-container">$$O\left(\frac{n^2}{\log{\frac{n(n+1)}{2}}}\right)$$</span>, my intuition tells m...
habedi/stack-exchange-dataset
119,331
Expected length of a random walk on a line
<p>I am given the following randomized algorithm for SAT,</p>&#xA;&#xA;<ul>&#xA;<li>Input: A satisfiable CNF-formula <span class="math-container">$\varphi$</span>.</li>&#xA;<li>Output: An assignment <span class="math-container">$\rho$</span>, such that <span class="math-container">$\rho \models \varphi$</span>.</li>&#x...
algorithms probability theory randomized algorithms 2 sat random walks
1
Expected length of a random walk on a line -- (algorithms probability theory randomized algorithms 2 sat random walks) <p>I am given the following randomized algorithm for SAT,</p>&#xA;&#xA;<ul>&#xA;<li>Input: A satisfiable CNF-formula <span class="math-container">$\varphi$</span>.</li>&#xA;<li>Output: An assignment <s...
habedi/stack-exchange-dataset
119,338
Improving time complexity from O(log n/loglog n) to O((log ((nloglog n)/log n))/loglog ((nloglog n)/log n))
<p>Suppose I have an algorithm whose running time is &#xA; <span class="math-container">$O(f(n))$</span> where <span class="math-container">$f(n) = O\left(\frac{\log n}{\log\log n}\right)$</span></p>&#xA;&#xA;<p>And suppose I can change this running time in <span class="math-container">$O(1)$</span> steps into <span cl...
algorithms time complexity big o notation
1
Improving time complexity from O(log n/loglog n) to O((log ((nloglog n)/log n))/loglog ((nloglog n)/log n)) -- (algorithms time complexity big o notation) <p>Suppose I have an algorithm whose running time is &#xA; <span class="math-container">$O(f(n))$</span> where <span class="math-container">$f(n) = O\left(\frac{\log...
habedi/stack-exchange-dataset
119,339
Efficiently computing minimal elements over partially ordered sets
<p>I have a list of sets that I would like to sort into a partial order based on the subset relation.</p>&#xA;&#xA;<p>In fact, I do not require the complete ordering, only the minimal elements.</p>&#xA;&#xA;<p>If I am not mistaken, each minimal elements should define one separate component of the respective graph - an...
lower bounds partial order lattices finite sets
1
Efficiently computing minimal elements over partially ordered sets -- (lower bounds partial order lattices finite sets) <p>I have a list of sets that I would like to sort into a partial order based on the subset relation.</p>&#xA;&#xA;<p>In fact, I do not require the complete ordering, only the minimal elements.</p>&#x...
habedi/stack-exchange-dataset
119,349
Algorithm for sorting pairs of items
<p>I have a real world problem where I have a list of nodes. Each ones contains a name and the name of the node before it in order. I am trying to devise an algorithm to sort these in order. The problem is that any two random nodes will not tell me anything about their order unless they happen to lie next to each other...
algorithms sorting
1
Algorithm for sorting pairs of items -- (algorithms sorting) <p>I have a real world problem where I have a list of nodes. Each ones contains a name and the name of the node before it in order. I am trying to devise an algorithm to sort these in order. The problem is that any two random nodes will not tell me anything a...
habedi/stack-exchange-dataset
119,350
Are problems in NP $\cap$ coNP less difficult than those in NP-complete?
<p>I am taking a complexity class now, and I struggle to understand the concept of "hardness":<br>&#xA;Assume that <span class="math-container">$L \in \textsf{NP } \cap \textsf{coNP}$</span>. In means that under the assumption <span class="math-container">$\mathsf{NP} \neq \textsf{coNP}$</span>, <span class="math-conta...
complexity theory time complexity np complete np
1
Are problems in NP $\cap$ coNP less difficult than those in NP-complete? -- (complexity theory time complexity np complete np) <p>I am taking a complexity class now, and I struggle to understand the concept of "hardness":<br>&#xA;Assume that <span class="math-container">$L \in \textsf{NP } \cap \textsf{coNP}$</span>. I...
habedi/stack-exchange-dataset
119,359
How can I improve my algorithmic ingenuity?
<p>During undergrad I felt my education was mostly comprised of applying existing theory to real world problems (ie. algorithm design/analysis). I've seen derivations of many algorithms and proofs of their complexity, but I'm often left bothered by the question of how one comes to discover an algorithm. It seems daunti...
algorithms education
1
How can I improve my algorithmic ingenuity? -- (algorithms education) <p>During undergrad I felt my education was mostly comprised of applying existing theory to real world problems (ie. algorithm design/analysis). I've seen derivations of many algorithms and proofs of their complexity, but I'm often left bothered by t...
habedi/stack-exchange-dataset
119,389
Understanding the state vector in Quantum Computing
<p>I have just started to learn QC. It is said that </p>&#xA;&#xA;<blockquote>&#xA; <p>The quantum state of <span class="math-container">$N$</span> qubits can be expressed as a vector in a space&#xA; of dimension <span class="math-container">$2^N$</span></p>&#xA;</blockquote>&#xA;&#xA;<p>If there is <span class="math...
quantum computing
1
Understanding the state vector in Quantum Computing -- (quantum computing) <p>I have just started to learn QC. It is said that </p>&#xA;&#xA;<blockquote>&#xA; <p>The quantum state of <span class="math-container">$N$</span> qubits can be expressed as a vector in a space&#xA; of dimension <span class="math-container">$...
habedi/stack-exchange-dataset
119,404
What do the ∀ and ∃ symbols mean in the Axiom of Choice?
<p>On the Wikipedia page for the <a href="https://en.wikipedia.org/wiki/Axiom_of_choice#Axiom_of_choice_in_type_theory" rel="nofollow noreferrer">Axiom of Choice</a> the following statement is given:</p>&#xA;&#xA;<p><span class="math-container">$(\forall x^\sigma)(\exists y^\tau)R(x,y)\rightarrow(\exists f^{\sigma \rig...
type theory
1
What do the ∀ and ∃ symbols mean in the Axiom of Choice? -- (type theory) <p>On the Wikipedia page for the <a href="https://en.wikipedia.org/wiki/Axiom_of_choice#Axiom_of_choice_in_type_theory" rel="nofollow noreferrer">Axiom of Choice</a> the following statement is given:</p>&#xA;&#xA;<p><span class="math-container">$...
habedi/stack-exchange-dataset
119,422
Compare two complexity functions having the same asymptotic complexity
<p>For a certain problem two solution algorithms (A1 and A2) with the following execution times have been found:</p>&#xA;&#xA;<ul>&#xA;<li><span class="math-container">$A1: T_{A1}(n)=4n^2 +7log(n^2)$</span></li>&#xA;<li><span class="math-container">$A2: T_{A2}(n) = 4T(n/2) + log(n)$</span></li>&#xA;</ul>&#xA;&#xA;<p>Sa...
complexity theory time complexity computability master theorem
1
Compare two complexity functions having the same asymptotic complexity -- (complexity theory time complexity computability master theorem) <p>For a certain problem two solution algorithms (A1 and A2) with the following execution times have been found:</p>&#xA;&#xA;<ul>&#xA;<li><span class="math-container">$A1: T_{A1}(n...
habedi/stack-exchange-dataset
119,427
Assignment problem or something else?
<p>My primary goal with this question is to identify the type of problem I have so I know what solution to pursue. I think it's either an instance of the <a href="https://en.wikipedia.org/wiki/Assignment_problem" rel="nofollow noreferrer">assignment problem</a> or the <a href="https://en.wikipedia.org/wiki/Fair_item_al...
assignment problem
1
Assignment problem or something else? -- (assignment problem) <p>My primary goal with this question is to identify the type of problem I have so I know what solution to pursue. I think it's either an instance of the <a href="https://en.wikipedia.org/wiki/Assignment_problem" rel="nofollow noreferrer">assignment problem<...
habedi/stack-exchange-dataset
119,432
Pseudo code of recursive method of printing all permutations of $n$ given integers
<p>I really don't understand this pseudo code. The function prints all permutations of <span class="math-container">$n$</span> given integers, assuming that all numbers are different. </p>&#xA;&#xA;<p>Is there a way to explain this code more easily as I really don't get the purpose of the swapping.</p>&#xA;&#xA;<pre><c...
recursion permutations pseudocode
1
Pseudo code of recursive method of printing all permutations of $n$ given integers -- (recursion permutations pseudocode) <p>I really don't understand this pseudo code. The function prints all permutations of <span class="math-container">$n$</span> given integers, assuming that all numbers are different. </p>&#xA;&#xA;...
habedi/stack-exchange-dataset
119,441
Maximum number of similar groups of a given size that can be made from a given array
<p>I am given an array of numbers, not necessarily unique, and the size of a group. Let the array be denoted by <span class="math-container">$B$</span> and the size of the group be <span class="math-container">$A$</span>.</p>&#xA;&#xA;<p>I need to find the maximum number of groups with the exact same contents and of si...
dynamic programming greedy algorithms mathematical analysis algorithm design
1
Maximum number of similar groups of a given size that can be made from a given array -- (dynamic programming greedy algorithms mathematical analysis algorithm design) <p>I am given an array of numbers, not necessarily unique, and the size of a group. Let the array be denoted by <span class="math-container">$B$</span> a...
habedi/stack-exchange-dataset
119,442
Algorithm for finding an irreducible kernel of a DAG in O(V*e) time, where e is number of edges in output
<p>An irreducible kernel is the term used in Handbook of Theoretical Computer Science (HTCS), Volume A "Algorithms and Complexity" in the chapter on graph algorithms. Given a directed graph <span class="math-container">$G=(V,E)$</span>, an irreducible kernel is a graph <span class="math-container">$G'=(V,E')$</span> w...
algorithms graphs dag
1
Algorithm for finding an irreducible kernel of a DAG in O(V*e) time, where e is number of edges in output -- (algorithms graphs dag) <p>An irreducible kernel is the term used in Handbook of Theoretical Computer Science (HTCS), Volume A "Algorithms and Complexity" in the chapter on graph algorithms. Given a directed gr...
habedi/stack-exchange-dataset
119,462
Sorting algorithm
<p><a href="https://i.stack.imgur.com/sfsEy.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/sfsEy.jpg" alt="enter image description here"></a></p>&#xA;&#xA;<p>I want to know from this picture which one is bubble sort, insertion sort and selection sort?</p>&#xA;&#xA;<p>My answer is:</p>&#xA;&#xA;<ol>&...
algorithms sorting
1
Sorting algorithm -- (algorithms sorting) <p><a href="https://i.stack.imgur.com/sfsEy.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/sfsEy.jpg" alt="enter image description here"></a></p>&#xA;&#xA;<p>I want to know from this picture which one is bubble sort, insertion sort and selection sort?</p>&#x...
habedi/stack-exchange-dataset
119,463
In which paper is written that you can transform one problem to another to show NP-completeness?
<p>For example in this post they discuss how to construct a reduction between problems to show that one probleme is NP-Hard:&#xA;<a href="https://cs.stackexchange.com/questions/1240/how-do-i-construct-reductions-between-problems-to-prove-a-problem-is-np-complete">Post</a></p>&#xA;&#xA;<p>I am searching for a scientific...
complexity theory np complete
1
In which paper is written that you can transform one problem to another to show NP-completeness? -- (complexity theory np complete) <p>For example in this post they discuss how to construct a reduction between problems to show that one probleme is NP-Hard:&#xA;<a href="https://cs.stackexchange.com/questions/1240/how-do...
habedi/stack-exchange-dataset
119,482
solving a problem with induction
<p>The original question is the following</p>&#xA;&#xA;<blockquote>&#xA; <p>prove that <span class="math-container">$2·\sum_{i=0}^{n-1} 3^{i} = 3^n-1$</span> for all n <span class="math-container">$\geq$</span> 1</p>&#xA;</blockquote>&#xA;&#xA;<p>I know that I have to prove by induction and have successfully done the ...
induction
1
solving a problem with induction -- (induction) <p>The original question is the following</p>&#xA;&#xA;<blockquote>&#xA; <p>prove that <span class="math-container">$2·\sum_{i=0}^{n-1} 3^{i} = 3^n-1$</span> for all n <span class="math-container">$\geq$</span> 1</p>&#xA;</blockquote>&#xA;&#xA;<p>I know that I have to pr...
habedi/stack-exchange-dataset
119,494
How to find the loop invariant in hoare triples
<p>Hey I am new to Hoare triples, and I can't understand on finding the loop invariants in hypothesis. For example this while loop</p>&#xA;&#xA;<pre><code>[x&gt;1 &amp; y&gt;1] WHILE x&gt;0 DO x:=x-1; y:=y+2 END [x+y&gt;5].&#xA;</code></pre>&#xA;&#xA;<p>The invariant is [2x + y > 5] but I don't understand on how to fin...
hoare logic
1
How to find the loop invariant in hoare triples -- (hoare logic) <p>Hey I am new to Hoare triples, and I can't understand on finding the loop invariants in hypothesis. For example this while loop</p>&#xA;&#xA;<pre><code>[x&gt;1 &amp; y&gt;1] WHILE x&gt;0 DO x:=x-1; y:=y+2 END [x+y&gt;5].&#xA;</code></pre>&#xA;&#xA;<p>T...
habedi/stack-exchange-dataset
119,512
Optimality of a Greedy Algorithm
<p>If you designed a greedy algorithm to obtain an optimal solution and the algorithm can produce different combinations of values but still, any of theses combination is an optimal solution. How you prove it is optimality?</p>&#xA;&#xA;<p>For example you have a set of numbers <span class="math-container">$\mathcal{M}=...
proof techniques correctness proof greedy algorithms
1
Optimality of a Greedy Algorithm -- (proof techniques correctness proof greedy algorithms) <p>If you designed a greedy algorithm to obtain an optimal solution and the algorithm can produce different combinations of values but still, any of theses combination is an optimal solution. How you prove it is optimality?</p>&#...
habedi/stack-exchange-dataset
119,514
Generate code from automata
<p>I am trying to figure out the process of generating code (set of instructions, implementation language specifics dont matter at this time) from an automaton.</p>&#xA;&#xA;<p>The description of my intent is vague because although I am an electrical engineer, with extensive coding experience, I have no theoretical CS ...
automata code generation
1
Generate code from automata -- (automata code generation) <p>I am trying to figure out the process of generating code (set of instructions, implementation language specifics dont matter at this time) from an automaton.</p>&#xA;&#xA;<p>The description of my intent is vague because although I am an electrical engineer, w...
habedi/stack-exchange-dataset
119,522
Why is my algorithm version so slow with this input?
<p>Here I'm trying to do a comparison of two simple as possible algorithms, solving the symmetric travelling salesman problem, finding the optimal solution without the support of heuristics. I'm showing (or just referencing) the code of both algorithms only to better specify the implementation details, which could be r...
algorithm analysis search algorithms shortest path graph traversal
1
Why is my algorithm version so slow with this input? -- (algorithm analysis search algorithms shortest path graph traversal) <p>Here I'm trying to do a comparison of two simple as possible algorithms, solving the symmetric travelling salesman problem, finding the optimal solution without the support of heuristics. I'm ...
habedi/stack-exchange-dataset
119,533
Comparing asymptotic running time of two algorithms $\sqrt n$ and $2^{\sqrt{\log _{2}n}}$
<p>Given two algorithms with their time-complexity <span class="math-container">$t_a(n)=\sqrt{n}$</span> and <span class="math-container">$t_b(n) = 2^{\sqrt{\log _{2}n}}$</span> and i have to show <span class="math-container">$t_b(n) = O(t_a(n)) $</span>.</p>&#xA;&#xA;<p>I´ve made a program to check this statement an...
algorithm analysis time complexity complexity classes big o notation
1
Comparing asymptotic running time of two algorithms $\sqrt n$ and $2^{\sqrt{\log _{2}n}}$ -- (algorithm analysis time complexity complexity classes big o notation) <p>Given two algorithms with their time-complexity <span class="math-container">$t_a(n)=\sqrt{n}$</span> and <span class="math-container">$t_b(n) = 2^{\sq...
habedi/stack-exchange-dataset
119,542
Is there a naming convention for the left child of a right child (and vice versa)?
<p>That is, the right child of a left child, or the left child of a right child. The best that I can come up with is the "opposing child" but I was wondering if anyone has come across an existing naming convention for this.</p>&#xA;
binary trees
1
Is there a naming convention for the left child of a right child (and vice versa)? -- (binary trees) <p>That is, the right child of a left child, or the left child of a right child. The best that I can come up with is the "opposing child" but I was wondering if anyone has come across an existing naming convention for t...
habedi/stack-exchange-dataset
119,547
Is the Clique Problem polynomial time reducible to the graph-Homomorphism Problem and if so what does the reduction look like?
<p>Is the k-Clique Problem (given a Graph G and a natural number k does G kontain a Clique of size k)<br>&#xA;polynomial time reduzible to the graph-Homomorphism Problem (given two graphs, G and H, is there a Homomorphism from G to H) </p>&#xA;&#xA;<p>And if so what would the reduction look like?</p>&#xA;&#xA;<p>Since...
complexity theory graphs np complete reductions
1
Is the Clique Problem polynomial time reducible to the graph-Homomorphism Problem and if so what does the reduction look like? -- (complexity theory graphs np complete reductions) <p>Is the k-Clique Problem (given a Graph G and a natural number k does G kontain a Clique of size k)<br>&#xA;polynomial time reduzible to t...
habedi/stack-exchange-dataset
119,549
Even Odd problem
<p>"A" represents all the odd natural numbers and "B" represents all the even natural numbers. For a given integer v, we can reduce it either by A0 or (A0)+1 then B0 or (B0)+1 and so on until the value of v becomes &lt;=0. Considering that we chose (Ai) or (Ai)+1 and (Bi) or (Bi)+1 optimally where i is the index, we wa...
algorithms
1
Even Odd problem -- (algorithms) <p>"A" represents all the odd natural numbers and "B" represents all the even natural numbers. For a given integer v, we can reduce it either by A0 or (A0)+1 then B0 or (B0)+1 and so on until the value of v becomes &lt;=0. Considering that we chose (Ai) or (Ai)+1 and (Bi) or (Bi)+1 opti...
habedi/stack-exchange-dataset
119,556
Dominating set in bounded degeneracy and bounded degree graphs
<p>I believe Minimum Dominating Set (MDS) is NP-hard for bounded&#xA;degeneracy and their subset bounded degree graphs, but&#xA;a paper appear to suggest tractability.&#xA;<a href="http://fc.isima.fr/~limouzy/papers/FCT11.pdf" rel="nofollow noreferrer">Enumeration of Minimal Dominating Sets and Variants p.5</a></p>&#xA...
algorithms complexity theory graphs
1
Dominating set in bounded degeneracy and bounded degree graphs -- (algorithms complexity theory graphs) <p>I believe Minimum Dominating Set (MDS) is NP-hard for bounded&#xA;degeneracy and their subset bounded degree graphs, but&#xA;a paper appear to suggest tractability.&#xA;<a href="http://fc.isima.fr/~limouzy/papers/...
habedi/stack-exchange-dataset
119,562
Find vertices of a convex polytope, defined by intersecting half-spaces
<p>I am looking for a algorithm that returns the vertices of a polytope if provided with the set of intersecting half-spaces that define it.</p>&#xA;&#xA;<p>In my special case the polytope is constructed by the following constraints on <span class="math-container">$x \in \mathbb{R}^d$</span>:</p>&#xA;&#xA;<ul>&#xA;<li...
algorithms computational geometry
1
Find vertices of a convex polytope, defined by intersecting half-spaces -- (algorithms computational geometry) <p>I am looking for a algorithm that returns the vertices of a polytope if provided with the set of intersecting half-spaces that define it.</p>&#xA;&#xA;<p>In my special case the polytope is constructed by t...
habedi/stack-exchange-dataset
119,566
Fastest algorithm for transforming points into graph
<p>Given a set of <span class="math-container">$n$</span> two-dimensional points in the plane&#xA;<span class="math-container">$$\{ (x_1, y_1), (x_2, y_2), \dots, (x_n, y_n)\}$$</span>&#xA;and a real number <span class="math-container">$M$</span>, I want to transform this set of points into a graph with the points as v...
graphs time complexity
1
Fastest algorithm for transforming points into graph -- (graphs time complexity) <p>Given a set of <span class="math-container">$n$</span> two-dimensional points in the plane&#xA;<span class="math-container">$$\{ (x_1, y_1), (x_2, y_2), \dots, (x_n, y_n)\}$$</span>&#xA;and a real number <span class="math-container">$M$...
habedi/stack-exchange-dataset
119,577
NFA equality for automata with partial transition functions and all states accepting
<p>Given two nondeterministic finite state automata with partial transition functions, such that all states are accepting, except for the implicit failure sink state, is it possible to decide in polynomial time whether the two automata recognize the same language? Or is it perhaps PSPACE-hard, like the same problem for...
automata finite automata theory
1
NFA equality for automata with partial transition functions and all states accepting -- (automata finite automata theory) <p>Given two nondeterministic finite state automata with partial transition functions, such that all states are accepting, except for the implicit failure sink state, is it possible to decide in pol...
habedi/stack-exchange-dataset
119,600
Primitive word and cyclic rotations
<p><strong>Definition.</strong> A word <span class="math-container">$w \in \Sigma^*$</span> is primitive if <span class="math-container">$w=u^n \rightarrow n=1$</span>.</p>&#xA;&#xA;<p>Is it true that a word is primitive if and only if its all cyclic rotations are dstinct?</p>&#xA;
strings word combinatorics
1
Primitive word and cyclic rotations -- (strings word combinatorics) <p><strong>Definition.</strong> A word <span class="math-container">$w \in \Sigma^*$</span> is primitive if <span class="math-container">$w=u^n \rightarrow n=1$</span>.</p>&#xA;&#xA;<p>Is it true that a word is primitive if and only if its all cyclic r...
habedi/stack-exchange-dataset
119,607
Can a DFA have an unreachable state?
<p>I am trying to prove or disprove the following statement:</p>&#xA;&#xA;<blockquote>&#xA; <p>If <span class="math-container">$A = (\Sigma, Q, \delta, q_0, F)$</span> is a complete DFA where <span class="math-container">$F \neq \emptyset$</span> then <span class="math-container">$L(A) \neq \emptyset$</span></p>&#xA;<...
regular languages finite automata
1
Can a DFA have an unreachable state? -- (regular languages finite automata) <p>I am trying to prove or disprove the following statement:</p>&#xA;&#xA;<blockquote>&#xA; <p>If <span class="math-container">$A = (\Sigma, Q, \delta, q_0, F)$</span> is a complete DFA where <span class="math-container">$F \neq \emptyset$</sp...
habedi/stack-exchange-dataset
119,626
Finding lost bottle (algorithm problem)
<p>The question is as follows:</p>&#xA;&#xA;<blockquote>&#xA; <p>A scientist creates a new compound, called compound A, that will explode 10 days after being mixed with compound B. This compound A was stored in a label-less bottle on a shelf with <span class="math-container">$n-1$</span> bottles of non-reactive materi...
search problem algorithm design
1
Finding lost bottle (algorithm problem) -- (search problem algorithm design) <p>The question is as follows:</p>&#xA;&#xA;<blockquote>&#xA; <p>A scientist creates a new compound, called compound A, that will explode 10 days after being mixed with compound B. This compound A was stored in a label-less bottle on a shelf ...
habedi/stack-exchange-dataset
119,628
Using a point as an input for a perceptron
<p>Can a point be used as the input for a perceptron/neural net?</p>&#xA;&#xA;<p>The relationship between the two numbers that make up a 2D point does not affect the output, but does this not matter when the satisfactory weights are found?</p>&#xA;&#xA;<p>If I wanted to use a point <span class="math-container">$(x,y)$<...
machine learning neural networks perceptron neural computing
1
Using a point as an input for a perceptron -- (machine learning neural networks perceptron neural computing) <p>Can a point be used as the input for a perceptron/neural net?</p>&#xA;&#xA;<p>The relationship between the two numbers that make up a 2D point does not affect the output, but does this not matter when the sat...
habedi/stack-exchange-dataset
119,631
Time complexity of combinations of n pairs of parentheses
<p>I have the following code snippet for combinations of n pairs of parentheses.</p>&#xA;&#xA;<pre><code>def parens(n):&#xA; if n &lt;= 0:&#xA; return ['']&#xA; else:&#xA; combinations = []&#xA; helper('', n, n, combinations)&#xA; return combinations&#xA;&#xA;&#xA;def helper(string, le...
algorithms time complexity
1
Time complexity of combinations of n pairs of parentheses -- (algorithms time complexity) <p>I have the following code snippet for combinations of n pairs of parentheses.</p>&#xA;&#xA;<pre><code>def parens(n):&#xA; if n &lt;= 0:&#xA; return ['']&#xA; else:&#xA; combinations = []&#xA; helper('...
habedi/stack-exchange-dataset
119,646
Given a network flow find if there's a min cut that only one of the given edges lay on it
<p>Given a network flow <span class="math-container">$G=(V,E)$</span> with capacity function <span class="math-container">$C$</span> source <span class="math-container">$s$</span> and hole <span class="math-container">$t$</span>,&#xA;and given 2 edges <span class="math-container">$e_1 , e_2 $</span>.</p>&#xA;&#xA;<p>Fi...
algorithms graphs network flow minimum cuts
1
Given a network flow find if there's a min cut that only one of the given edges lay on it -- (algorithms graphs network flow minimum cuts) <p>Given a network flow <span class="math-container">$G=(V,E)$</span> with capacity function <span class="math-container">$C$</span> source <span class="math-container">$s$</span> a...
habedi/stack-exchange-dataset
119,649
How can I apply Rice's theorem?
<p>I am learning for my computability and complexity exam in which there is always an exercise to decide whether some problem is decidable or not. </p>&#xA;&#xA;<p>In one of the past exams, there was the following problem:</p>&#xA;&#xA;<p><em>Given Turing Machine M, decide whether there exists a prime number on which M...
undecidability rice theorem
1
How can I apply Rice's theorem? -- (undecidability rice theorem) <p>I am learning for my computability and complexity exam in which there is always an exercise to decide whether some problem is decidable or not. </p>&#xA;&#xA;<p>In one of the past exams, there was the following problem:</p>&#xA;&#xA;<p><em>Given Turing...
habedi/stack-exchange-dataset
119,665
Status on Naoki Katoh's "Rectangle Wiring Problem" (minimum length tree to cover a partitioned rectangle)?
<p>I have found this interesting problem in graph theory and geometry which is allegedly an open problem but latest status seems to be from 01/25/02. I can't seem to find any more information about it, not even other papers describing it.</p>&#xA;&#xA;<p><a href="https://i.stack.imgur.com/jT7Ub.png" rel="nofollow noref...
graphs computational geometry
1
Status on Naoki Katoh's "Rectangle Wiring Problem" (minimum length tree to cover a partitioned rectangle)? -- (graphs computational geometry) <p>I have found this interesting problem in graph theory and geometry which is allegedly an open problem but latest status seems to be from 01/25/02. I can't seem to find any mor...
habedi/stack-exchange-dataset
119,674
if there is no reduction from A to B
<p>I'm facing the following question :</p>&#xA;&#xA;<blockquote>&#xA; <p>If there is no <span class="math-container">$\leq_$</span> reduction,</p>&#xA; &#xA; <p>does this necessarily mean that A is not decidable?</p>&#xA;</blockquote>&#xA;&#xA;<p>for any choice of B.</p>&#xA;&#xA;<p>thanks in advance.</p>&#xA;
computability reductions
1
if there is no reduction from A to B -- (computability reductions) <p>I'm facing the following question :</p>&#xA;&#xA;<blockquote>&#xA; <p>If there is no <span class="math-container">$\leq_$</span> reduction,</p>&#xA; &#xA; <p>does this necessarily mean that A is not decidable?</p>&#xA;</blockquote>&#xA;&#xA;<p>for...
habedi/stack-exchange-dataset
119,676
Is Google search personalized?
<p>Pardon me if this is a very naive question.</p>&#xA;&#xA;<p>Suppose I search for something on Google and my next-door neighbour searches for the same thing (on Google) at the same time. Do we get the same or different results?</p>&#xA;
search
1
Is Google search personalized? -- (search) <p>Pardon me if this is a very naive question.</p>&#xA;&#xA;<p>Suppose I search for something on Google and my next-door neighbour searches for the same thing (on Google) at the same time. Do we get the same or different results?</p>&#xA;
habedi/stack-exchange-dataset
119,679
Streaming digit-to-digit conversion from decimal to hexadecimal
<p>I am looking for a <a href="https://en.wikipedia.org/wiki/Streaming_algorithm" rel="nofollow noreferrer">streaming algorithm</a> for converting a decimal number to a hexadecimal number. I am assuming the input is a string represention of a decimal number (i.e., each character is a decimal digit) in digit-reversed o...
substrings string matching base conversion numeral representations
1
Streaming digit-to-digit conversion from decimal to hexadecimal -- (substrings string matching base conversion numeral representations) <p>I am looking for a <a href="https://en.wikipedia.org/wiki/Streaming_algorithm" rel="nofollow noreferrer">streaming algorithm</a> for converting a decimal number to a hexadecimal num...
habedi/stack-exchange-dataset
119,681
Separating the snakes
<p>In a two-dimensional grid, there are <span class="math-container">$n$</span> "snakes" (sets of contiguous grid-blocks). The snakes do not touch each other. The goal is to cut the grid into <span class="math-container">$n$</span> rectangles using <span class="math-container">$n-1$</span> "fences" (horizontal or verti...
computational geometry discrete mathematics
1
Separating the snakes -- (computational geometry discrete mathematics) <p>In a two-dimensional grid, there are <span class="math-container">$n$</span> "snakes" (sets of contiguous grid-blocks). The snakes do not touch each other. The goal is to cut the grid into <span class="math-container">$n$</span> rectangles using ...
habedi/stack-exchange-dataset
119,684
Show that UPrime = {1^n : n ∈ N is prime} is in P
<p>I have this question to solve. According to my understanding, it basically requires a turing machine that outputs lines on the tape, with the number of the lines being any prime number. </p>&#xA;&#xA;<p>My idea is to take the <a href="https://en.wikipedia.org/wiki/AKS_primality_test" rel="nofollow noreferrer">AKS te...
algorithms complexity theory
1
Show that UPrime = {1^n : n ∈ N is prime} is in P -- (algorithms complexity theory) <p>I have this question to solve. According to my understanding, it basically requires a turing machine that outputs lines on the tape, with the number of the lines being any prime number. </p>&#xA;&#xA;<p>My idea is to take the <a href...
habedi/stack-exchange-dataset
119,686
Is "imperative computing" just a fancy way of saying "scripting"? Or is there more to it?
<p>Maybe this is a very ignorant question. I don't understand imperative computing very well, would it be correct to think of it as simply scripting (as in, running one or a few commands at a time, typically run through a shell language, as opposed to writing a fully fledged program)?</p>&#xA;
imperative programming
1
Is "imperative computing" just a fancy way of saying "scripting"? Or is there more to it? -- (imperative programming) <p>Maybe this is a very ignorant question. I don't understand imperative computing very well, would it be correct to think of it as simply scripting (as in, running one or a few commands at a time, typi...
habedi/stack-exchange-dataset
119,692
How many different languages over the unary alphabet {a} are recognized by 2-state DFAs?
<p>I am struggling to answer the following question:</p>&#xA;&#xA;<blockquote>&#xA; <p>How many different languages over the unary alphabet {a} are&#xA; recognized by 2-state DFAs?</p>&#xA;</blockquote>&#xA;&#xA;<p>According to the textbook, the hint was to first calculate the number of 2-state DFAs over that alphabe...
automata regular languages finite automata sets
1
How many different languages over the unary alphabet {a} are recognized by 2-state DFAs? -- (automata regular languages finite automata sets) <p>I am struggling to answer the following question:</p>&#xA;&#xA;<blockquote>&#xA; <p>How many different languages over the unary alphabet {a} are&#xA; recognized by 2-state D...
habedi/stack-exchange-dataset
119,698
Time complexity of algorithm inversely proportional to size of sub problem?
<p>Let's say I have an algorithm with time complexity <span class="math-container">$T_n = T_\frac{n-1}2 + 1$</span>, <span class="math-container">$T_0 = 0, T_1 = 1$</span>.</p>&#xA;&#xA;<p>Assume (Induction hypothesis) <span class="math-container">$T_n = C\log_2(n+1)$</span> for some <span class="math-container">$C$</s...
time complexity master theorem
1
Time complexity of algorithm inversely proportional to size of sub problem? -- (time complexity master theorem) <p>Let's say I have an algorithm with time complexity <span class="math-container">$T_n = T_\frac{n-1}2 + 1$</span>, <span class="math-container">$T_0 = 0, T_1 = 1$</span>.</p>&#xA;&#xA;<p>Assume (Induction h...
habedi/stack-exchange-dataset
119,707
Thought process to solve tree based Dynamic Programming problems
<p>I am having a very hard time understanding tree based DP problems. I am fairly comfortable with array based DP problems but I cannot come up with the correct thought process for tree based problems and I was hoping somebody could please explain their thought process.</p>&#xA;&#xA;<p>I will talk about my thought proc...
algorithms trees dynamic programming recurrence relation recursion
1
Thought process to solve tree based Dynamic Programming problems -- (algorithms trees dynamic programming recurrence relation recursion) <p>I am having a very hard time understanding tree based DP problems. I am fairly comfortable with array based DP problems but I cannot come up with the correct thought process for tr...
habedi/stack-exchange-dataset
119,711
Why the most dominant programming languages didn't follow CSP thread model?
<blockquote>&#xA;<p>I was trying to ask this question in StackOverflow, but later realized that this question is more relevant to general computer science, not specific engineering problems. If you think it's not, please let me know.</p>&#xA;</blockquote>&#xA;<p>Recently I've found out what CSP(Communicating Sequential...
formal languages parallel computing concurrency threads
1
Why the most dominant programming languages didn't follow CSP thread model? -- (formal languages parallel computing concurrency threads) <blockquote>&#xA;<p>I was trying to ask this question in StackOverflow, but later realized that this question is more relevant to general computer science, not specific engineering pr...
habedi/stack-exchange-dataset
119,729
Similarly colored paths in a DAG
<p>Is there an algorithm that can efficiently solve the following question?</p>&#xA;&#xA;<p>Given a directed acyclic graph G with n vertices each assigned a random color from a set of size &lt;= n - 1 colors, a source vertex s, and two distinct vertices a and b both having the same color and reachable from s. </p>&#xA;...
algorithms graphs
1
Similarly colored paths in a DAG -- (algorithms graphs) <p>Is there an algorithm that can efficiently solve the following question?</p>&#xA;&#xA;<p>Given a directed acyclic graph G with n vertices each assigned a random color from a set of size &lt;= n - 1 colors, a source vertex s, and two distinct vertices a and b bo...
habedi/stack-exchange-dataset
119,735
Max clique in interval graph
<p>According to <a href="https://onlinelibrary.wiley.com/doi/abs/10.1002/net.3230120410" rel="nofollow noreferrer">Efficient algorithms for interval graphs and circular arc graphs</a> there is an <span class="math-container">$O(n \log n)$</span> algorithm for finding the max clique in an interval graph, assuming you ha...
graphs intervals clique
1
Max clique in interval graph -- (graphs intervals clique) <p>According to <a href="https://onlinelibrary.wiley.com/doi/abs/10.1002/net.3230120410" rel="nofollow noreferrer">Efficient algorithms for interval graphs and circular arc graphs</a> there is an <span class="math-container">$O(n \log n)$</span> algorithm for fi...
habedi/stack-exchange-dataset
119,740
Why doesn't Dijkstra's use a shortest-path first search?
<p>When using BFS search on an unweighted graph to find the single-source shortest paths, no relaxation step is required because a breadth-first search guarantees that when we first make it to a node, we have found the shortest path to it.</p>&#xA;&#xA;<p>However, my understanding is that Dijkstra's algorithm has no su...
shortest path dijkstras algorithm
1
Why doesn't Dijkstra's use a shortest-path first search? -- (shortest path dijkstras algorithm) <p>When using BFS search on an unweighted graph to find the single-source shortest paths, no relaxation step is required because a breadth-first search guarantees that when we first make it to a node, we have found the short...
habedi/stack-exchange-dataset
119,744
How does a TLB lookup compare all keys simultaneously?
<p>I am reading OS Concepts dinosaur book which says, "Each entry in the TLB consists of two parts: a key (or tag) and a value. When the associative memory is presented with an item, the item is compared with all keys simultaneously."</p>&#xA;&#xA;<p>I checked <a href="https://cs.stackexchange.com/questions/18313/how-d...
memory access paging cache
1
How does a TLB lookup compare all keys simultaneously? -- (memory access paging cache) <p>I am reading OS Concepts dinosaur book which says, "Each entry in the TLB consists of two parts: a key (or tag) and a value. When the associative memory is presented with an item, the item is compared with all keys simultaneously....
habedi/stack-exchange-dataset
119,747
Does the callback concept of programming have any basis in computer science?
<p>Although I seriously code with computer languages in general since 2010 and as an amateur programmer with programming languages in particular since 2015 (primarily Bash and JavaScript imperative scripts) and codes I wrote are scattered through my Stack Exchange accounts, <a href="https://codereview.stackexchange.com...
terminology programming languages logic functional programming simulation
1
Does the callback concept of programming have any basis in computer science? -- (terminology programming languages logic functional programming simulation) <p>Although I seriously code with computer languages in general since 2010 and as an amateur programmer with programming languages in particular since 2015 (primari...
habedi/stack-exchange-dataset
119,768
Count total number of k length paths in a tree
<p>This is a question from a competitive programming competition.&#xA;Given a tree with n nodes and a number k, find the total number of paths of length k in that tree.</p>&#xA;&#xA;<p>I know for a fact that a solution can be found by using a centroid decomposition, however I am simply not sure on the exact relationshi...
graphs trees recursion counting
1
Count total number of k length paths in a tree -- (graphs trees recursion counting) <p>This is a question from a competitive programming competition.&#xA;Given a tree with n nodes and a number k, find the total number of paths of length k in that tree.</p>&#xA;&#xA;<p>I know for a fact that a solution can be found by u...
habedi/stack-exchange-dataset
119,775
Why is the type ∀t.t un-inhabited in System F?
<p>How do you prove that there exists no term with the type <span class="math-container">$\forall t. t$</span> in System F? </p>&#xA;&#xA;<p>I tried searching through Pierce's TAPL and Reynold's ToPL, but could not find anything. I suspect that the proof may involve some kind of model theoritic argument, but I fail to ...
programming languages type theory
1
Why is the type ∀t.t un-inhabited in System F? -- (programming languages type theory) <p>How do you prove that there exists no term with the type <span class="math-container">$\forall t. t$</span> in System F? </p>&#xA;&#xA;<p>I tried searching through Pierce's TAPL and Reynold's ToPL, but could not find anything. I su...
habedi/stack-exchange-dataset
119,792
What computational model supports arbitrarily sized integers?
<p>I want to do some research, but I don't think it's important the number of bits it takes to represent the integer input and arithmetic on the abstract machine. So what is the model that addresses this?</p>&#xA;&#xA;<p>Specifically, I want to prove that integer factorization is not in P. If the above is a bad idea,...
turing machines computability integers primes factoring
1
What computational model supports arbitrarily sized integers? -- (turing machines computability integers primes factoring) <p>I want to do some research, but I don't think it's important the number of bits it takes to represent the integer input and arithmetic on the abstract machine. So what is the model that address...
habedi/stack-exchange-dataset
119,795
Time complexity of optimal algorithm for solving this problem
<p>Given an <span class="math-container">$N\times N$</span> matrix <span class="math-container">$M$</span> whose elements are integers, find the largest element that occurs in each row of the matrix.</p>&#xA;&#xA;<p>I tried using hashtable as follow:</p>&#xA;&#xA;<p>Idea is to use hash-table(let's call it <span class="...
algorithms
1
Time complexity of optimal algorithm for solving this problem -- (algorithms) <p>Given an <span class="math-container">$N\times N$</span> matrix <span class="math-container">$M$</span> whose elements are integers, find the largest element that occurs in each row of the matrix.</p>&#xA;&#xA;<p>I tried using hashtable as...
habedi/stack-exchange-dataset
119,797
Why is the run time with a loop of this structure considered O(log n)
<p>I used the search function and a good amount of google searches, but wasn't able to get a straight answer on how a loop of the form below, is translated to a proper summation where the function derived from the summation is: <span class="math-container">$O(\log n)$</span>. </p>&#xA;&#xA;<p><strong>Example of the fo...
algorithms asymptotics runtime analysis
1
Why is the run time with a loop of this structure considered O(log n) -- (algorithms asymptotics runtime analysis) <p>I used the search function and a good amount of google searches, but wasn't able to get a straight answer on how a loop of the form below, is translated to a proper summation where the function derived ...
habedi/stack-exchange-dataset
119,803
Union of halting-like problem and non-halting-like problem
<p>I came across the following problem:</p>&#xA;<blockquote>&#xA;<p>Define languages <span class="math-container">$L_0$</span> and <span class="math-container">$L_1$</span> as follows :</p>&#xA;<p><span class="math-container">$L_0=\{⟨M,w,0⟩∣M\text{ halts on }w\}$</span><br />&#xA;<span class="math-container">$L_1=\{⟨M,...
formal languages undecidability halting problem semi decidability
1
Union of halting-like problem and non-halting-like problem -- (formal languages undecidability halting problem semi decidability) <p>I came across the following problem:</p>&#xA;<blockquote>&#xA;<p>Define languages <span class="math-container">$L_0$</span> and <span class="math-container">$L_1$</span> as follows :</p>&...
habedi/stack-exchange-dataset
119,807
Coloring a graph with odd number of vertices with $k$ (which is close to $\Delta$) colors in linear time
<p>We have an undirected simple connected graph with odd number of vertices. We also know the number <span class="math-container">$k$</span> which is actually the closest odd number greater than or equal to <span class="math-container">$\Delta$</span>. (So if <span class="math-container">$\Delta$</span> is even, <span ...
graphs time complexity greedy algorithms colorings
1
Coloring a graph with odd number of vertices with $k$ (which is close to $\Delta$) colors in linear time -- (graphs time complexity greedy algorithms colorings) <p>We have an undirected simple connected graph with odd number of vertices. We also know the number <span class="math-container">$k$</span> which is actually ...
habedi/stack-exchange-dataset
119,817
Do theorem provers demonstrate their own correctness?
<p>I am not very well-versed in the world of theorem proving, much less automated theorem proving, so please correct me if anything I say or assume in my question is wrong.</p>&#xA;&#xA;<p>Basically my question is: are automated theorem provers themselves every formally proven to work with another theorem prover, or is...
formal methods software verification automated theorem proving
1
Do theorem provers demonstrate their own correctness? -- (formal methods software verification automated theorem proving) <p>I am not very well-versed in the world of theorem proving, much less automated theorem proving, so please correct me if anything I say or assume in my question is wrong.</p>&#xA;&#xA;<p>Basically...
habedi/stack-exchange-dataset
119,834
Turing machine: errata in computable numbers paper?
<p>I'm reading Turing On Computable Number 1936, specifically the section pictured here:</p>&#xA;&#xA;<p><a href="https://i.stack.imgur.com/RUO6G.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/RUO6G.png" alt="Turing Description"></a></p>&#xA;&#xA;<p>Does anyone see errata here? Should the second m-...
turing machines
1
Turing machine: errata in computable numbers paper? -- (turing machines) <p>I'm reading Turing On Computable Number 1936, specifically the section pictured here:</p>&#xA;&#xA;<p><a href="https://i.stack.imgur.com/RUO6G.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/RUO6G.png" alt="Turing Description...
habedi/stack-exchange-dataset
119,835
If I walk through list and delete every out-of-order element I come across, on average how many elements will be left?
<p>I have a uniformly randomly permuted list of length <span class="math-container">$n$</span>. I walk through the list element-by-element, and delete an element if it's out-of-order (compared to the previous in-order elements of the list). What I'm left with is a shorter list that's guaranteed to be in-order.</p>&#xA;...
runtime analysis sorting probability theory randomized algorithms permutations
1
If I walk through list and delete every out-of-order element I come across, on average how many elements will be left? -- (runtime analysis sorting probability theory randomized algorithms permutations) <p>I have a uniformly randomly permuted list of length <span class="math-container">$n$</span>. I walk through the li...
habedi/stack-exchange-dataset
119,847
How many operations of flipping all brackets on a substring of a string of brackets are needed to make the string 'correct'?
<p>I call a string of brackets 'correct' if every opening bracket has a corresponding closing bracket somewhere after it and every closing bracket has a corresponding opening bracket somewhere before it. For example</p>&#xA;&#xA;<blockquote>&#xA; <p>(())()((()()))</p>&#xA;</blockquote>&#xA;&#xA;<p>is a correct string ...
strings substrings
1
How many operations of flipping all brackets on a substring of a string of brackets are needed to make the string 'correct'? -- (strings substrings) <p>I call a string of brackets 'correct' if every opening bracket has a corresponding closing bracket somewhere after it and every closing bracket has a corresponding open...
habedi/stack-exchange-dataset
119,858
Is O(n log n) exponential speedup over O(n^2)?
<p>I would like to know if <span class="math-container">$O(n \log n)$</span> is an exponential speedup over <span class="math-container">$O(n^2)$</span>? </p>&#xA;
complexity theory polynomials big o notation
1
Is O(n log n) exponential speedup over O(n^2)? -- (complexity theory polynomials big o notation) <p>I would like to know if <span class="math-container">$O(n \log n)$</span> is an exponential speedup over <span class="math-container">$O(n^2)$</span>? </p>&#xA;
habedi/stack-exchange-dataset
119,863
Kirchhoff's Spanning Tree Algorithm
<p>Recently I have studied <em>Kirchhoff's spanning tree algorithm</em> to count the number of spanning trees of a graph, which has the following steps: </p>&#xA;&#xA;<ol>&#xA;<li><p>Build an adjacency matrix</p></li>&#xA;<li><p>Replace the diagonal entries with the degrees of the corresponding nodes</p></li>&#xA;<li><...
algorithms algorithm analysis spanning trees
1
Kirchhoff's Spanning Tree Algorithm -- (algorithms algorithm analysis spanning trees) <p>Recently I have studied <em>Kirchhoff's spanning tree algorithm</em> to count the number of spanning trees of a graph, which has the following steps: </p>&#xA;&#xA;<ol>&#xA;<li><p>Build an adjacency matrix</p></li>&#xA;<li><p>Repla...
habedi/stack-exchange-dataset
119,871
Set which is easy to sample, but difficult to sample from its complement
<p>Given a set <span class="math-container">$S \subseteq \{0,1\}^*$</span>, the algorithm <span class="math-container">$A$</span> is a generator for <span class="math-container">$S$</span> if given <span class="math-container">$n$</span> random bits <span class="math-container">$x \in \{0,1\}^n$</span>, <span class="ma...
complexity theory discrete mathematics randomized algorithms pseudo random generators sampling
1
Set which is easy to sample, but difficult to sample from its complement -- (complexity theory discrete mathematics randomized algorithms pseudo random generators sampling) <p>Given a set <span class="math-container">$S \subseteq \{0,1\}^*$</span>, the algorithm <span class="math-container">$A$</span> is a generator fo...
habedi/stack-exchange-dataset
119,872
Analysing worst-case time complexity of quick-sort in different cases
<p>I am trying to understand worst case time complexity of <em>quick-sort</em> for various pivots. Here is what I came across:</p>&#xA;&#xA;<ol>&#xA;<li><p>When array is already sorted in either ascending order or descending order and we select either leftmost or rightmost element as pivot, then it results in worst cas...
algorithms runtime analysis sorting quicksort
1
Analysing worst-case time complexity of quick-sort in different cases -- (algorithms runtime analysis sorting quicksort) <p>I am trying to understand worst case time complexity of <em>quick-sort</em> for various pivots. Here is what I came across:</p>&#xA;&#xA;<ol>&#xA;<li><p>When array is already sorted in either asce...
habedi/stack-exchange-dataset