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
21,629
Context-free language and regular expressions
<p>I have the following context-free language:</p>&#xA;&#xA;<pre><code>S -&gt; ASa | b&#xA;A -&gt; aA | a&#xA;</code></pre>&#xA;&#xA;<p>I don't understand why this is not regular. I first said that it's generated by the regular expression <code>a+ba+</code>. The following is regular however</p>&#xA;&#xA;<pre><code>S -&...
regular languages context free regular expressions
1
Context-free language and regular expressions -- (regular languages context free regular expressions) <p>I have the following context-free language:</p>&#xA;&#xA;<pre><code>S -&gt; ASa | b&#xA;A -&gt; aA | a&#xA;</code></pre>&#xA;&#xA;<p>I don't understand why this is not regular. I first said that it's generated by th...
habedi/stack-exchange-dataset
21,636
Why is this function computable in $O(n^{1.5})$ time?
<p>My textbook says: "We define the function $f\colon \mathbb{N}\to\mathbb{N}$ as follows: $f(1)=2$ and $f(i+1)=2^{f(i)^{1.2}}$. Note that given $n$, we can easily find in $O(n^{1.5})$ time the number $i$ such that $n$ is sandwiched between $f(i)$ and $f(i+1)$."</p>&#xA;&#xA;<p>How can I convince myself that we can in ...
complexity theory algorithm analysis nondeterminism
1
Why is this function computable in $O(n^{1.5})$ time? -- (complexity theory algorithm analysis nondeterminism) <p>My textbook says: "We define the function $f\colon \mathbb{N}\to\mathbb{N}$ as follows: $f(1)=2$ and $f(i+1)=2^{f(i)^{1.2}}$. Note that given $n$, we can easily find in $O(n^{1.5})$ time the number $i$ such...
habedi/stack-exchange-dataset
21,639
Is this a well founded inductive type? Can I express this in Coq?
<p>the standard List type in Coq can be expressed as:</p>&#xA;&#xA;<pre><code>Inductive List (A:Set) : Set :=&#xA; nil : List A&#xA;| cons : A -&gt; List A -&gt; List A.&#xA;</code></pre>&#xA;&#xA;<p>as I understand, W-type express a well-founded tree of elements of this type. so, what if <code>nil</code> is not quali...
type theory dependent types coq inductive datatypes
1
Is this a well founded inductive type? Can I express this in Coq? -- (type theory dependent types coq inductive datatypes) <p>the standard List type in Coq can be expressed as:</p>&#xA;&#xA;<pre><code>Inductive List (A:Set) : Set :=&#xA; nil : List A&#xA;| cons : A -&gt; List A -&gt; List A.&#xA;</code></pre>&#xA;&#xA...
habedi/stack-exchange-dataset
21,649
Correct nomenclature: Hamilton path, Hamilton's path or Hamiltonian path?
<p>What is the correct way?&#xA;Hamilton path, Hamilton's path or Hamiltonian path?&#xA;To be clear, I am referring to the correct way to name a graph such that there exists a single path (without repeated vertices) through all the vertices.</p>&#xA;&#xA;<p>In Wikipedia it says "Hamiltonian path", whereas in an article...
hamiltonian path
1
Correct nomenclature: Hamilton path, Hamilton's path or Hamiltonian path? -- (hamiltonian path) <p>What is the correct way?&#xA;Hamilton path, Hamilton's path or Hamiltonian path?&#xA;To be clear, I am referring to the correct way to name a graph such that there exists a single path (without repeated vertices) through ...
habedi/stack-exchange-dataset
21,659
2 cases for P = NP
<p>As we all know the million dollar question in Computer Science P=NP or not. I was trying to understand it and got some doubts please tell me whether I'm right or wrong</p>&#xA;&#xA;<p>N=NP in two cases </p>&#xA;&#xA;<blockquote>&#xA; <p>Case 1: We have found an algorithm which can solve a NP-Complete problem in P-T...
complexity theory
1
2 cases for P = NP -- (complexity theory) <p>As we all know the million dollar question in Computer Science P=NP or not. I was trying to understand it and got some doubts please tell me whether I'm right or wrong</p>&#xA;&#xA;<p>N=NP in two cases </p>&#xA;&#xA;<blockquote>&#xA; <p>Case 1: We have found an algorithm wh...
habedi/stack-exchange-dataset
21,664
Find all non-decreasing sequences given lenght and size
<p>I'm trying to find a solution for this exercise:</p>&#xA;&#xA;<blockquote>&#xA; <p>Give the pseudocode of an algorithm which takes two positive integers&#xA; n and k and prints all the non-decreasing sequences of length k&#xA; (1,2,...,n).</p>&#xA; &#xA; <p>For example n=4, k=3:</p>&#xA; &#xA; <p>111 112 113 ...
algorithms backtracking
1
Find all non-decreasing sequences given lenght and size -- (algorithms backtracking) <p>I'm trying to find a solution for this exercise:</p>&#xA;&#xA;<blockquote>&#xA; <p>Give the pseudocode of an algorithm which takes two positive integers&#xA; n and k and prints all the non-decreasing sequences of length k&#xA; (1...
habedi/stack-exchange-dataset
21,665
How to build/recognise a deadlock-free order of resources
<p>I have been faced with a problem where three concurrent processes <strong>X</strong>, <strong>Y</strong> ,<strong>Z</strong> execute three different code segments that access and update certain shared variables. Before entering the respective code segments :</p>&#xA;&#xA;<ul>&#xA;<li><p>Process X executes the P oper...
process scheduling deadlocks
1
How to build/recognise a deadlock-free order of resources -- (process scheduling deadlocks) <p>I have been faced with a problem where three concurrent processes <strong>X</strong>, <strong>Y</strong> ,<strong>Z</strong> execute three different code segments that access and update certain shared variables. Before enteri...
habedi/stack-exchange-dataset
21,675
Big O relation between $2^n$ and $2^{2n}$
<p>I know that:</p>&#xA;&#xA;<p>If $f(n) = O(g(n))$ , then there are constants $M$ and $x_0$ , such that </p>&#xA;&#xA;<p>$f(n) &lt;= M*g(n), \forall n &gt; n_0$</p>&#xA;&#xA;<p>The other, plain English way of defining it is,</p>&#xA;&#xA;<p>If $f(n)=O(g(n))$ then for large $n$ , $f(n)$ would <em>grow</em> as fast as $...
complexity theory algorithm analysis asymptotics landau notation
1
Big O relation between $2^n$ and $2^{2n}$ -- (complexity theory algorithm analysis asymptotics landau notation) <p>I know that:</p>&#xA;&#xA;<p>If $f(n) = O(g(n))$ , then there are constants $M$ and $x_0$ , such that </p>&#xA;&#xA;<p>$f(n) &lt;= M*g(n), \forall n &gt; n_0$</p>&#xA;&#xA;<p>The other, plain English way o...
habedi/stack-exchange-dataset
21,679
How do I compute this non terminal positions evaluation, for tic-tac-toe?
<p>Looking at this <a href="http://www-scf.usc.edu/~csci460/docs/homework/solution2.pdf" rel="nofollow">solution on page 3</a> but having trouble understanding the evaluation function specifically. </p>&#xA;&#xA;<blockquote>&#xA; <p>For non terminal positions, we use a linear evaluation function&#xA; defined as</p>...
heuristics game theory board games
1
How do I compute this non terminal positions evaluation, for tic-tac-toe? -- (heuristics game theory board games) <p>Looking at this <a href="http://www-scf.usc.edu/~csci460/docs/homework/solution2.pdf" rel="nofollow">solution on page 3</a> but having trouble understanding the evaluation function specifically. </p>&#...
habedi/stack-exchange-dataset
21,682
MIPS Architecture : PC-relative addressing
<p>In case of branch Instructions such as <code>beq</code>, <code>bne</code>, we use PC-relative addressing. &#xA;But I am really not clear why it is said in most of the books that MIPS address(while calculating branch target) is actually relative to the address of following instruction <code>PC+4</code> as opposed to ...
computer architecture
1
MIPS Architecture : PC-relative addressing -- (computer architecture) <p>In case of branch Instructions such as <code>beq</code>, <code>bne</code>, we use PC-relative addressing. &#xA;But I am really not clear why it is said in most of the books that MIPS address(while calculating branch target) is actually relative to...
habedi/stack-exchange-dataset
21,684
Books to prepare before reading Knuth's The Art Of Computer Programming (TAOCP)
<p>Many people say that TAOCP is not supposed to be read as a book (actually a volume of books), but if I decide to go that way, which math/computer science books/topics do I need to study to help me follow it? There is a related <a href="https://stackoverflow.com/questions/3549401/what-math-do-you-need-to-read-the-art...
books
1
Books to prepare before reading Knuth's The Art Of Computer Programming (TAOCP) -- (books) <p>Many people say that TAOCP is not supposed to be read as a book (actually a volume of books), but if I decide to go that way, which math/computer science books/topics do I need to study to help me follow it? There is a related...
habedi/stack-exchange-dataset
21,705
An algorithm for making 2 carts meet
<p>Say I have 2 carts on an infinite railroad, each cart is initially under a lamp.&#xA;There are only 2 lamps, and they are at a fixed location, hence they don't change their location. The distance between them is D, but its not known.&#xA;Each cart has a processing unit, both will execute a copy of the same program o...
algorithms computer algebra pseudo polynomial
1
An algorithm for making 2 carts meet -- (algorithms computer algebra pseudo polynomial) <p>Say I have 2 carts on an infinite railroad, each cart is initially under a lamp.&#xA;There are only 2 lamps, and they are at a fixed location, hence they don't change their location. The distance between them is D, but its not kn...
habedi/stack-exchange-dataset
21,710
Where is the recursion, in the minimax-decision algorithm?
<p>The below is from an article titled: </p>&#xA;&#xA;<blockquote>&#xA; <p><strong>Minimax: Recursive Implementation</strong></p>&#xA;</blockquote>&#xA;&#xA;<p><img src="https://i.stack.imgur.com/l00le.png" alt="enter image description here"></p>&#xA;&#xA;<p>To be a recursive function, <a href="https://www.youtube.com...
heuristics game theory board games
1
Where is the recursion, in the minimax-decision algorithm? -- (heuristics game theory board games) <p>The below is from an article titled: </p>&#xA;&#xA;<blockquote>&#xA; <p><strong>Minimax: Recursive Implementation</strong></p>&#xA;</blockquote>&#xA;&#xA;<p><img src="https://i.stack.imgur.com/l00le.png" alt="enter im...
habedi/stack-exchange-dataset
21,711
Time complexity of proximity search in distance matrix
<p>I am a high school student computationally studying the 3-dimensional structure of chromosomes by 40 kilobase loci. In a nutshell, loci that are close in space tend to express their genes at the same time ― loci are different stops on a 3D-winding DNA chain.</p>&#xA;&#xA;<p>The best way to understand the 3D structur...
algorithms algorithm analysis runtime analysis search algorithms
1
Time complexity of proximity search in distance matrix -- (algorithms algorithm analysis runtime analysis search algorithms) <p>I am a high school student computationally studying the 3-dimensional structure of chromosomes by 40 kilobase loci. In a nutshell, loci that are close in space tend to express their genes at t...
habedi/stack-exchange-dataset
21,714
Asymptotic lower bound on the number of comparisons needed to find the intersection of unsorted arrays
<p>A homework problem in my current CS class asks us to produce a <em>comparison-based</em> procedure for taking (essentially—there are some poorly-specified rules about duplicates) the set intersection of <span class="math-container">$k$</span> unsorted arrays of at most <span class="math-container">$n$</span> element...
algorithms complexity theory sets
1
Asymptotic lower bound on the number of comparisons needed to find the intersection of unsorted arrays -- (algorithms complexity theory sets) <p>A homework problem in my current CS class asks us to produce a <em>comparison-based</em> procedure for taking (essentially—there are some poorly-specified rules about duplicat...
habedi/stack-exchange-dataset
21,724
How to deal with questions having two or more asymptotic notations
<p>The following was asked as part of a homework assignment and I am not asking for the solution to these but rather tips or resources on how to solve this and similar questions, </p>&#xA;&#xA;<p>Let $f(n)$ and $g(n)$ be two functions from $\mathbb{N}^+$ to $\mathbb{R}^+$. Prove or disprove the following assertions. To...
asymptotics landau notation
1
How to deal with questions having two or more asymptotic notations -- (asymptotics landau notation) <p>The following was asked as part of a homework assignment and I am not asking for the solution to these but rather tips or resources on how to solve this and similar questions, </p>&#xA;&#xA;<p>Let $f(n)$ and $g(n)$ be...
habedi/stack-exchange-dataset
21,727
Why and how is a quantum computer faster than a regular computer?
<p>I'm currently reading a book (and a lot of wikipedia) about quantum physics and I've yet to understand how a quantum computer can be faster than the computers we have today. </p>&#xA;&#xA;<p>How can a quantum computer solve a problem in sub-exponential time that a classic computer can only solve in exponential time?...
quantum computing
1
Why and how is a quantum computer faster than a regular computer? -- (quantum computing) <p>I'm currently reading a book (and a lot of wikipedia) about quantum physics and I've yet to understand how a quantum computer can be faster than the computers we have today. </p>&#xA;&#xA;<p>How can a quantum computer solve a pr...
habedi/stack-exchange-dataset
21,728
Dependent types vs refinement types
<p>Could somebody explain the difference between dependent types and refinement types? As I understand it, a refinement type contains all values of a type fulfilling a predicate. Is there a feature of dependent types which distinguishes them? </p>&#xA;&#xA;<p>If it helps, I came across Refined types via the Liquid Hask...
terminology programming languages type theory functional programming dependent types
1
Dependent types vs refinement types -- (terminology programming languages type theory functional programming dependent types) <p>Could somebody explain the difference between dependent types and refinement types? As I understand it, a refinement type contains all values of a type fulfilling a predicate. Is there a feat...
habedi/stack-exchange-dataset
21,744
Qubits Related to RAM?
<p>I read in <a href="http://www.cs.virginia.edu/~robins/The_Limits_of_Quantum_Computers.pdf" rel="nofollow">this article</a> that the amount of bits that can be emulated by a certain number of qubits is 2^(number of qubits). This is because each qubit can be in one of 2 states after it collapses, and so before all the...
memory management quantum computing
1
Qubits Related to RAM? -- (memory management quantum computing) <p>I read in <a href="http://www.cs.virginia.edu/~robins/The_Limits_of_Quantum_Computers.pdf" rel="nofollow">this article</a> that the amount of bits that can be emulated by a certain number of qubits is 2^(number of qubits). This is because each qubit can...
habedi/stack-exchange-dataset
21,746
Prove that languages which contain words whose lengths are multiples of a constant are regular
<p>This is a problem involving the theory of regular languages. I am stuck on this problem and do not know how to solve this type of problem. </p>&#xA;&#xA;<blockquote>&#xA; <p>Prove that the language $B_n = \{ a^k \mid k \text{ is a multiple of } n \}$ is a regular language for any $n \ge 1$.</p>&#xA;</blockquote>&...
formal languages regular languages
1
Prove that languages which contain words whose lengths are multiples of a constant are regular -- (formal languages regular languages) <p>This is a problem involving the theory of regular languages. I am stuck on this problem and do not know how to solve this type of problem. </p>&#xA;&#xA;<blockquote>&#xA; <p>Prove...
habedi/stack-exchange-dataset
21,753
What type of recursion is this?
<p>I was trying to rule out whether this was LL(1) by checking for left-recursion in the following grammar:</p>&#xA;&#xA;<p>$\qquad A \to 0 A 1 \mid 0 1$</p>&#xA;&#xA;<p>Which produces:</p>&#xA;&#xA;<p>$\qquad 0 A 1 \Rightarrow 0 0 A 1 1 \Rightarrow \dots$</p>&#xA;&#xA;<p>But I am unsure what type of recursion this is...
formal grammars parsers left recursion
1
What type of recursion is this? -- (formal grammars parsers left recursion) <p>I was trying to rule out whether this was LL(1) by checking for left-recursion in the following grammar:</p>&#xA;&#xA;<p>$\qquad A \to 0 A 1 \mid 0 1$</p>&#xA;&#xA;<p>Which produces:</p>&#xA;&#xA;<p>$\qquad 0 A 1 \Rightarrow 0 0 A 1 1 \Righ...
habedi/stack-exchange-dataset
21,765
Kleene star of an infinite unary language always yields a regular language
<p>Let $L = \{a^n \mid n \ge 0\}$, where $a^0 = \epsilon$ and $a^n = a^{n-1}a$ for all $n \ge 1$.</p>&#xA;&#xA;<p>Thus $L$ consists of sequences of $a$ of all lengths, including a sequence&#xA;of length $0$. Let $L_2$ be any infinite subset of $L$. I need to show there always exists a DFA to recognize $L_2^*$. </p>&#xA...
formal languages regular languages closure properties
1
Kleene star of an infinite unary language always yields a regular language -- (formal languages regular languages closure properties) <p>Let $L = \{a^n \mid n \ge 0\}$, where $a^0 = \epsilon$ and $a^n = a^{n-1}a$ for all $n \ge 1$.</p>&#xA;&#xA;<p>Thus $L$ consists of sequences of $a$ of all lengths, including a sequen...
habedi/stack-exchange-dataset
21,767
How can we minimize the total distance of cross pairs in an array
<p>Suppose we had 2 arrays of the same size with positive numbers and we wanted to pair up the elements of each array such that the total difference between the pairs is minimized.</p>&#xA;&#xA;<p>The first thought would be to choose pairs with the minimum difference and so on. But it turns out the correct algorithm is...
algorithms algorithm analysis optimization correctness proof permutations
1
How can we minimize the total distance of cross pairs in an array -- (algorithms algorithm analysis optimization correctness proof permutations) <p>Suppose we had 2 arrays of the same size with positive numbers and we wanted to pair up the elements of each array such that the total difference between the pairs is minim...
habedi/stack-exchange-dataset
21,786
Given $k$ sorted lists, $O(n \log k)$ complexity, Mergesort rather than Heapsort
<p>I was <em>convinced</em> that my idea for a solution to sort $k$ sorted lists into one list would work with a 'variation' on MergeSort. I was told this would not work and had to use Heapsort, but didn't get any explanation or intuition behind it. (I believe the assumption is that each of the $k$ lists had size $\fra...
algorithms sorting
1
Given $k$ sorted lists, $O(n \log k)$ complexity, Mergesort rather than Heapsort -- (algorithms sorting) <p>I was <em>convinced</em> that my idea for a solution to sort $k$ sorted lists into one list would work with a 'variation' on MergeSort. I was told this would not work and had to use Heapsort, but didn't get any e...
habedi/stack-exchange-dataset
21,802
Minimum number of states in DFA accepting strings where the numbers of a and b are divisible by X and Y respectively?
<p>While studying automata theory a typical problem that I face is of the following type:</p>&#xA;&#xA;<blockquote>&#xA; <p>Constructing a DFA with minimum number of states for all strings over&#xA; $\{a,b\}$ which have number of $a$’s divisible by $X$ and number of $b$’s&#xA; divisible by $Y$ (where $X$ and $Y$ are...
formal languages automata finite automata
1
Minimum number of states in DFA accepting strings where the numbers of a and b are divisible by X and Y respectively? -- (formal languages automata finite automata) <p>While studying automata theory a typical problem that I face is of the following type:</p>&#xA;&#xA;<blockquote>&#xA; <p>Constructing a DFA with minimu...
habedi/stack-exchange-dataset
21,812
Recurrence relation in 2 variables
<p>When analyzing an algorithm, the following recurrence relation popped up:</p>&#xA;&#xA;<p>$T(n,d)=2T(n/2,d)+T(n,d-1)+O(dn)$</p>&#xA;&#xA;<p>where $T(n,1)=O(n \log{n})$ and $T(1,d)=O(d)$.</p>&#xA;&#xA;<p>By applying the Master Theorem inductively, for any particular $d$, it holds that $T(n,d)=O(n (\log{n})^d)$. Howev...
time complexity asymptotics recurrence relation
1
Recurrence relation in 2 variables -- (time complexity asymptotics recurrence relation) <p>When analyzing an algorithm, the following recurrence relation popped up:</p>&#xA;&#xA;<p>$T(n,d)=2T(n/2,d)+T(n,d-1)+O(dn)$</p>&#xA;&#xA;<p>where $T(n,1)=O(n \log{n})$ and $T(1,d)=O(d)$.</p>&#xA;&#xA;<p>By applying the Master The...
habedi/stack-exchange-dataset
21,819
Proving the correctness of an algorithm, which computes the connectivity of a directed graph
<p>Let $G=(V,E)$ be a directed graph. The <strong>connectivity</strong> of a graph is the defined as the cardinality of a smallest separator of $G$. A <strong>separator</strong> of $G$ is a subset $U$ of $V$, such that $G-U$ is not strongly connected.</p>&#xA;&#xA;<p>Why does the following algorithm compute the connect...
algorithms graphs correctness proof
1
Proving the correctness of an algorithm, which computes the connectivity of a directed graph -- (algorithms graphs correctness proof) <p>Let $G=(V,E)$ be a directed graph. The <strong>connectivity</strong> of a graph is the defined as the cardinality of a smallest separator of $G$. A <strong>separator</strong> of $G$ i...
habedi/stack-exchange-dataset
21,825
What is the Inversion Lemma
<p>I am taking a programming languages course, and we have had to use the Inversion Lemma many times in our proofs of preservation. We have been given the Inversion Lemma in each of these examples, but is there a general statement of the inversion lemma that can be applied to any proof of preservation? Can someone writ...
programming languages typing
1
What is the Inversion Lemma -- (programming languages typing) <p>I am taking a programming languages course, and we have had to use the Inversion Lemma many times in our proofs of preservation. We have been given the Inversion Lemma in each of these examples, but is there a general statement of the inversion lemma that...
habedi/stack-exchange-dataset
21,829
How to find the cost of pseudocode with a nested loop and a nested if statement?
<p>How can I find the cost of pseudocode with a nested loop and a nested if statement?</p>&#xA;&#xA;<p><img src="https://i.stack.imgur.com/bk2g6.png" alt="Exercise"></p>&#xA;&#xA;<p>On the left hand side is an example from a textbook I am following. On the right hand side is pseudo code that I found. I took a guess, bu...
algorithm analysis asymptotics runtime analysis
1
How to find the cost of pseudocode with a nested loop and a nested if statement? -- (algorithm analysis asymptotics runtime analysis) <p>How can I find the cost of pseudocode with a nested loop and a nested if statement?</p>&#xA;&#xA;<p><img src="https://i.stack.imgur.com/bk2g6.png" alt="Exercise"></p>&#xA;&#xA;<p>On t...
habedi/stack-exchange-dataset
21,844
How many times an empty 4-cycle can be counted in an undirected graph?
<p>I have an undirected graph where each node is labelled with an integer key and I'm asked to detect every <em>simple</em> 4-cycle, which can be seen as an empty square (i.e. the two opposite nodes of the cycle have not to be connected).</p>&#xA;&#xA;<p>I know the labels of a generic square in the graph can be permute...
graphs
1
How many times an empty 4-cycle can be counted in an undirected graph? -- (graphs) <p>I have an undirected graph where each node is labelled with an integer key and I'm asked to detect every <em>simple</em> 4-cycle, which can be seen as an empty square (i.e. the two opposite nodes of the cycle have not to be connected)...
habedi/stack-exchange-dataset
21,857
minimizing the summed cardinality of set unions
<p>this optimization problem, I am working on, is kind of making me crazy. ;)</p>&#xA;&#xA;<p>Given is a list <code>o</code> of sets (with finite cardinality) of strictly positive integer values (Z>0), e.g.:</p>&#xA;&#xA;<pre><code>o_without_sizes =&#xA;[ {1, 2, 3, 4}&#xA;, {5, 6}&#xA;, {2, 3, 4, 5}&#xA;, {5, 6, 7}&#xA...
algorithms np complete optimization dynamic programming np hard
1
minimizing the summed cardinality of set unions -- (algorithms np complete optimization dynamic programming np hard) <p>this optimization problem, I am working on, is kind of making me crazy. ;)</p>&#xA;&#xA;<p>Given is a list <code>o</code> of sets (with finite cardinality) of strictly positive integer values (Z>0), e...
habedi/stack-exchange-dataset
21,858
Checking if there are 2 elements in an array that sum to X in O(n lg n)
<p>I have thought about the most useful way of checking an array for 2 elements that sum to X.&#xA;The trivial solution is to check the sum of every element with every element, and the complexity of this solution is $O(n^2)$.</p>&#xA;&#xA;<p>My solution is:&#xA;Say the array is A.&#xA;It's length is N.&#xA;Elements are...
algorithms algorithm analysis runtime analysis arrays
1
Checking if there are 2 elements in an array that sum to X in O(n lg n) -- (algorithms algorithm analysis runtime analysis arrays) <p>I have thought about the most useful way of checking an array for 2 elements that sum to X.&#xA;The trivial solution is to check the sum of every element with every element, and the comp...
habedi/stack-exchange-dataset
21,871
Does NP-Complete imply non-satisfiability?
<p>I've seen a lot of text concerning the first NP-Complete problem, Boolean Satisfiability. I guess I'm confused concerning the language. </p>&#xA;&#xA;<p>It sounds to me as though the problem could be difficult to compute (hence the NP-complete), however it still might be satisfiable. As in, there <em>exists</em> a s...
complexity theory terminology np complete satisfiability
1
Does NP-Complete imply non-satisfiability? -- (complexity theory terminology np complete satisfiability) <p>I've seen a lot of text concerning the first NP-Complete problem, Boolean Satisfiability. I guess I'm confused concerning the language. </p>&#xA;&#xA;<p>It sounds to me as though the problem could be difficult to...
habedi/stack-exchange-dataset
21,873
Proving 2P2N SAT is NP-Complete
<p>I hope I named this CNF Boolean sentence the correct way. The way I see it, a 2P2N is where each literal appears twice (or at most twice, but we can say twice without loss of generality). </p>&#xA;&#xA;<p>I am trying to prove it is Satisfiable. How do I do this? Do I need to try to reduce it to 3-SAT (might need som...
complexity theory np complete satisfiability
1
Proving 2P2N SAT is NP-Complete -- (complexity theory np complete satisfiability) <p>I hope I named this CNF Boolean sentence the correct way. The way I see it, a 2P2N is where each literal appears twice (or at most twice, but we can say twice without loss of generality). </p>&#xA;&#xA;<p>I am trying to prove it is Sat...
habedi/stack-exchange-dataset
21,895
What happens at the decode phase of the instruction cycle?
<p>I am reading about the various phases of the <a href="http://en.wikipedia.org/wiki/Instruction_cycle" rel="noreferrer">Instruction Execution</a>, I found out that we have three phases like below.</p>&#xA;&#xA;<ol>&#xA;<li>Fectch</li>&#xA;<li>Decode</li>&#xA;<li>Execute</li>&#xA;</ol>&#xA;&#xA;<p>Now if the part I do...
computer architecture
1
What happens at the decode phase of the instruction cycle? -- (computer architecture) <p>I am reading about the various phases of the <a href="http://en.wikipedia.org/wiki/Instruction_cycle" rel="noreferrer">Instruction Execution</a>, I found out that we have three phases like below.</p>&#xA;&#xA;<ol>&#xA;<li>Fectch</l...
habedi/stack-exchange-dataset
21,896
Algorithm Request: "Shortest non-existing substring over given alphabet"
<p>I'm looking for an (efficient) algorithm to solve the following problem:</p>&#xA;&#xA;<blockquote>&#xA; <p>Given a string $S$ and a set of characters $M$, find the shortest string composed only of characters in $M$ that is <em>not</em> contained in $S$.</p>&#xA;</blockquote>&#xA;&#xA;<p>Try as I might, I can't seem...
algorithms data structures strings substrings
1
Algorithm Request: "Shortest non-existing substring over given alphabet" -- (algorithms data structures strings substrings) <p>I'm looking for an (efficient) algorithm to solve the following problem:</p>&#xA;&#xA;<blockquote>&#xA; <p>Given a string $S$ and a set of characters $M$, find the shortest string composed onl...
habedi/stack-exchange-dataset
21,897
showing that the pair of Finite Automata are equivalent
<p>Here I am trying to show that the pair of Finite Automata are equivalent. I have tried something but I am not sure if I am in the right direction. This is what I have.</p>&#xA;&#xA;<p>These are pairs of FA's. Set theory formula in here is <code>(L1' + L2)' + (L2' + L2)'</code></p>&#xA;&#xA;<p><img src="https://i.sta...
formal languages finite automata
1
showing that the pair of Finite Automata are equivalent -- (formal languages finite automata) <p>Here I am trying to show that the pair of Finite Automata are equivalent. I have tried something but I am not sure if I am in the right direction. This is what I have.</p>&#xA;&#xA;<p>These are pairs of FA's. Set theory for...
habedi/stack-exchange-dataset
21,905
Time complexity of 8-queen, by placeing one by one without attack
<p>I am new to artificial intelligence. I have been trying to analyse the time complexity of 8-queen, by placing one by one without attack.</p>&#xA;&#xA;<p>One approach to achieve goal state is to "add a queen to any square in the leftmost empty column such that it is not attacked by any other queen". And this approach...
time complexity search problem board games
1
Time complexity of 8-queen, by placeing one by one without attack -- (time complexity search problem board games) <p>I am new to artificial intelligence. I have been trying to analyse the time complexity of 8-queen, by placing one by one without attack.</p>&#xA;&#xA;<p>One approach to achieve goal state is to "add a qu...
habedi/stack-exchange-dataset
21,910
Parallel algorithm for finding the maximum in $\log n$ time using $n / \log n$ processors
<p>We were presented in class with an algorithm for finding the maximum in an array in parallel in <span class="math-container">$O(1)$</span> time complexity with <span class="math-container">$n^2$</span> computers.</p>&#xA;<p>The algorithm was:</p>&#xA;<blockquote>&#xA;<p>Given an array A of length n:</p>&#xA;<ol>&#xA...
algorithms search algorithms parallel computing
1
Parallel algorithm for finding the maximum in $\log n$ time using $n / \log n$ processors -- (algorithms search algorithms parallel computing) <p>We were presented in class with an algorithm for finding the maximum in an array in parallel in <span class="math-container">$O(1)$</span> time complexity with <span class="m...
habedi/stack-exchange-dataset
21,918
What is the possible number of states in the DFA of intersection of two given FA?
<blockquote>&#xA; <p>Consider a DFA over $a,b$ accepting all strings having number of $a$ 's divible by 6 and number of $b$ 's divisble by 8. What is the minimum number of states in the resultant DFA ?</p>&#xA;</blockquote>&#xA;&#xA;<p>This problem can be solved by assuming 2 DFAs. One accepting the number of $a$ 's ...
automata finite automata
1
What is the possible number of states in the DFA of intersection of two given FA? -- (automata finite automata) <blockquote>&#xA; <p>Consider a DFA over $a,b$ accepting all strings having number of $a$ 's divible by 6 and number of $b$ 's divisble by 8. What is the minimum number of states in the resultant DFA ?</p>&...
habedi/stack-exchange-dataset
21,921
Definition of “infix” in formal languages
<p>I've got a simple question:</p>&#xA;&#xA;<p>Let's say we have the following definition of a language over some alphabet: $L = \{w \mid w \text{ contains the infix } aab\}$</p>&#xA;&#xA;<p>Does that mean $aab \in L$? or does "$aab$" have to be "wrapped" on both sides by other letters?</p>&#xA;
formal languages terminology
1
Definition of “infix” in formal languages -- (formal languages terminology) <p>I've got a simple question:</p>&#xA;&#xA;<p>Let's say we have the following definition of a language over some alphabet: $L = \{w \mid w \text{ contains the infix } aab\}$</p>&#xA;&#xA;<p>Does that mean $aab \in L$? or does "$aab$" have to b...
habedi/stack-exchange-dataset
21,937
Why Instruction Decode and Register Read are in the same stage of MIPS pipeline
<p>Why are instruction decoding and register read are combined in single stage of a 5-stage MIPS-pipeline, even though they serve two different operation?</p>&#xA;
computer architecture cpu pipelines
1
Why Instruction Decode and Register Read are in the same stage of MIPS pipeline -- (computer architecture cpu pipelines) <p>Why are instruction decoding and register read are combined in single stage of a 5-stage MIPS-pipeline, even though they serve two different operation?</p>&#xA;
habedi/stack-exchange-dataset
21,942
the height of a tree given n nodes and a condition
<p>I came across a question on which I got totally stuck :( a sort of homework question)</p>&#xA;&#xA;<p>A weight-balanced tree is a binary tree in which for each node. The number of nodes in the left sub tree is at least half and at most twice the number of nodes in the right sub tree. The maximum possible height (num...
combinatorics trees discrete mathematics
1
the height of a tree given n nodes and a condition -- (combinatorics trees discrete mathematics) <p>I came across a question on which I got totally stuck :( a sort of homework question)</p>&#xA;&#xA;<p>A weight-balanced tree is a binary tree in which for each node. The number of nodes in the left sub tree is at least h...
habedi/stack-exchange-dataset
21,944
Recognizing Horn clauses
<p>I am currently studying model theory and I am trying to decide if a clause is a Horn Clause. I know that a Horn Clause is a clause with at most one positive literal, but there are some clauses that it is not easy to decide whether they are Horn or not.</p>&#xA;&#xA;<p>E.g.,</p>&#xA;&#xA;<pre><code>(P-&gt;Q)-&gt;W&#x...
logic artificial intelligence boolean algebra
1
Recognizing Horn clauses -- (logic artificial intelligence boolean algebra) <p>I am currently studying model theory and I am trying to decide if a clause is a Horn Clause. I know that a Horn Clause is a clause with at most one positive literal, but there are some clauses that it is not easy to decide whether they are H...
habedi/stack-exchange-dataset
21,947
How to solve recurrences involving log?
<p>For example, </p>&#xA;&#xA;<p>$T(n) = \log {n} \cdot T(\frac{n}{\log{n}}) + \Theta(n)$</p>&#xA;&#xA;<p>I tried using the substitution method with $ n = 2^m $, but that got me nowhere, since it still ends up with a $m$ <em>and</em> $2^m$. The recurrence tree method also becomes rather complicated. Is there a general ...
asymptotics recurrence relation
1
How to solve recurrences involving log? -- (asymptotics recurrence relation) <p>For example, </p>&#xA;&#xA;<p>$T(n) = \log {n} \cdot T(\frac{n}{\log{n}}) + \Theta(n)$</p>&#xA;&#xA;<p>I tried using the substitution method with $ n = 2^m $, but that got me nowhere, since it still ends up with a $m$ <em>and</em> $2^m$. Th...
habedi/stack-exchange-dataset
21,948
Recurrence $T(n) = 2T(\sqrt{n}) + \log n$
<p>So I have a question for the recurrence $T(n) = 2T(\sqrt{n}) + \log n$. We are to use substitution method to figure out the solution. This is an example problem (not a exercise problem) in my book (<em>Introduction to Algorithms</em>, Third Edition pg. 86). I'm having a hard time understanding how they rename $m = \...
recurrence relation
1
Recurrence $T(n) = 2T(\sqrt{n}) + \log n$ -- (recurrence relation) <p>So I have a question for the recurrence $T(n) = 2T(\sqrt{n}) + \log n$. We are to use substitution method to figure out the solution. This is an example problem (not a exercise problem) in my book (<em>Introduction to Algorithms</em>, Third Edition p...
habedi/stack-exchange-dataset
21,952
Recurrence Problem $T(n) = 3T(n/3) + n$
<p>My question here is dealing with the residual that I get. We are trying to prove $T(n) = 3T(n/3) + n$ is $O(n*\log n)$. So where I get is $T(n) \le cn[\log n - \log 3] + n$. So my residual is $-cn\log 3 + n$. So if I minus it I get $-(cn\log 3 -n) \ge 0$ right? How do I figure out what values of c &amp; n are? Do I...
recurrence relation
1
Recurrence Problem $T(n) = 3T(n/3) + n$ -- (recurrence relation) <p>My question here is dealing with the residual that I get. We are trying to prove $T(n) = 3T(n/3) + n$ is $O(n*\log n)$. So where I get is $T(n) \le cn[\log n - \log 3] + n$. So my residual is $-cn\log 3 + n$. So if I minus it I get $-(cn\log 3 -n) \ge...
habedi/stack-exchange-dataset
21,970
How to use Artificial Intelligence in Computer Chess
<p>In some (historical) papers, chess has been referred to as the drosophila of artificial intelligence. While I suppose that in current research, the mere application of a search algorithm is at best <em>advanced computer science</em>, I believe that there are still area's where can apply (and practice) AI-techniques....
artificial intelligence board games
1
How to use Artificial Intelligence in Computer Chess -- (artificial intelligence board games) <p>In some (historical) papers, chess has been referred to as the drosophila of artificial intelligence. While I suppose that in current research, the mere application of a search algorithm is at best <em>advanced computer sci...
habedi/stack-exchange-dataset
21,974
Selection of parameters for genetic algorithm
<p>How can one select the proper number of parameters for a genetic algorithm to model a given system?</p>&#xA;&#xA;<p>For example, say you want to optimize production of cars, and you have 1,000 measurements of hourly efficiency at various tasks for each of 1,000 different employees. So, you have 1,000,000 data point...
genetic algorithms
1
Selection of parameters for genetic algorithm -- (genetic algorithms) <p>How can one select the proper number of parameters for a genetic algorithm to model a given system?</p>&#xA;&#xA;<p>For example, say you want to optimize production of cars, and you have 1,000 measurements of hourly efficiency at various tasks for...
habedi/stack-exchange-dataset
21,977
When should I move beyond k nearest neighbour
<p>For many machine learning projects that we do, we start with the k Nearest Neighbour classifier. This is an ideal starting classifier as we usually have sufficient time to calculate all distances and the number of parameters is limited (k, distance metric and weighting)</p>&#xA;&#xA;<p>However, this has often the ef...
neural networks classification
1
When should I move beyond k nearest neighbour -- (neural networks classification) <p>For many machine learning projects that we do, we start with the k Nearest Neighbour classifier. This is an ideal starting classifier as we usually have sufficient time to calculate all distances and the number of parameters is limited...
habedi/stack-exchange-dataset
21,981
A scoring approach to computer opponents that needs balancing
<p>This question is about an approach to computer opponents that I have created and are either currently being used, or are planned to be used, in several computer games.</p>&#xA;<h3>Background</h3>&#xA;<p>Last year, when trying to improve a computer opponent for a game called &quot;Minesweeper Flags&quot; <em>(short d...
algorithms artificial intelligence computer games
1
A scoring approach to computer opponents that needs balancing -- (algorithms artificial intelligence computer games) <p>This question is about an approach to computer opponents that I have created and are either currently being used, or are planned to be used, in several computer games.</p>&#xA;<h3>Background</h3>&#xA;...
habedi/stack-exchange-dataset
21,985
Basic action for every data structure O(1)
<p>My lecturer for Algorithms said that most of the data structures I will encounter in the algorithms course I am taking have a basic action which is of O(1).</p>&#xA;&#xA;<p>Ex: Binary heap.</p>&#xA;&#xA;<p>Basic action is:</p>&#xA;&#xA;<blockquote>&#xA; <ol>&#xA; <li>Compare 2 childen.</li>&#xA; <li>Compare the "...
algorithms data structures
1
Basic action for every data structure O(1) -- (algorithms data structures) <p>My lecturer for Algorithms said that most of the data structures I will encounter in the algorithms course I am taking have a basic action which is of O(1).</p>&#xA;&#xA;<p>Ex: Binary heap.</p>&#xA;&#xA;<p>Basic action is:</p>&#xA;&#xA;<block...
habedi/stack-exchange-dataset
21,986
What is the relation between correlation and causation in machine learning?
<p>It is a well-known fact that "Correlation doesn't equal causation", but machine learning seems to be almost entirely based on correlation. I'm working on a system to estimate the performance of students on questions based on their past performances. Unlike other tasks, like Google search, this doesn't seem like the ...
machine learning statistics
1
What is the relation between correlation and causation in machine learning? -- (machine learning statistics) <p>It is a well-known fact that "Correlation doesn't equal causation", but machine learning seems to be almost entirely based on correlation. I'm working on a system to estimate the performance of students on qu...
habedi/stack-exchange-dataset
21,993
What are the state-of-the-art algorithms for pathfinding on a continuous map of the Earth?
<p>Suppose I have got a solar-powered autonomous surface vessel somewhere in the fjords of Norway, supplied with a fairly recent set of maps, a GPS receiver, and no means of downlinking detailed commands from me. This vessel has to reach, say, the island of Hainan at the earliest possible moment.</p>&#xA;&#xA;<ul>&#xA;...
artificial intelligence search algorithms
1
What are the state-of-the-art algorithms for pathfinding on a continuous map of the Earth? -- (artificial intelligence search algorithms) <p>Suppose I have got a solar-powered autonomous surface vessel somewhere in the fjords of Norway, supplied with a fairly recent set of maps, a GPS receiver, and no means of downlink...
habedi/stack-exchange-dataset
22,000
Given 2 regular languages and their DFA's, how to construct the DFA of the union?
<p>Suppose $L1, L2$ are both regular languages and $A1, A2$ are their corresponding DFA's.&#xA;How can I construct a new DFA for the regular language $L1 \cup L2$?</p>&#xA;
regular languages finite automata
1
Given 2 regular languages and their DFA's, how to construct the DFA of the union? -- (regular languages finite automata) <p>Suppose $L1, L2$ are both regular languages and $A1, A2$ are their corresponding DFA's.&#xA;How can I construct a new DFA for the regular language $L1 \cup L2$?</p>&#xA;
habedi/stack-exchange-dataset
22,002
Advantage of the Monte Carlo method over a regular periodic sampling
<p>I am unclear on when to use the Monte Carlo random sampling method for algorithm design. The classic example that I keep seeing is using random points within some bounding rectangle to determine the area of some irregular figure. Wouldn't a regular periodic sampling provide more repeatable results for this applicati...
algorithms randomized algorithms monte carlo
1
Advantage of the Monte Carlo method over a regular periodic sampling -- (algorithms randomized algorithms monte carlo) <p>I am unclear on when to use the Monte Carlo random sampling method for algorithm design. The classic example that I keep seeing is using random points within some bounding rectangle to determine the...
habedi/stack-exchange-dataset
22,009
Tree : Forest :: Path :?
<p>A forest is a collection of trees. </p>&#xA;&#xA;<p>Is there a similar notion for paths? e.g., a <strong><em>_</em>__<em>_</em>__<em>_</em></strong> is a collection of paths.</p>&#xA;
graphs terminology
1
Tree : Forest :: Path :? -- (graphs terminology) <p>A forest is a collection of trees. </p>&#xA;&#xA;<p>Is there a similar notion for paths? e.g., a <strong><em>_</em>__<em>_</em>__<em>_</em></strong> is a collection of paths.</p>&#xA;
habedi/stack-exchange-dataset
22,011
How to write a many-one reduction proof
<p>Writing a proof by contradiction is fairly formulaic--first you assume the opposite, then derive a contradiction. I would like to know the steps and conventions for writing a many-one reduction proof. <a href="https://cs.stackexchange.com/a/4582/14650">This answer</a> was somewhat helpful, but like other explanati...
turing machines reductions
1
How to write a many-one reduction proof -- (turing machines reductions) <p>Writing a proof by contradiction is fairly formulaic--first you assume the opposite, then derive a contradiction. I would like to know the steps and conventions for writing a many-one reduction proof. <a href="https://cs.stackexchange.com/a/45...
habedi/stack-exchange-dataset
22,012
Why $R\circ\emptyset$ is not always equal to $\emptyset$
<p>I was going through the text Introduction to Theory of Computation by Michael Sipser. It is written that $R\circ\emptyset$ may not equal to $R$. I thought $R\circ\emptyset=\emptyset$ always. $R$ is any regular expression.</p>&#xA;&#xA;<p>Couldnt find any example that contradicts that</p>&#xA;
automata regular expressions
1
Why $R\circ\emptyset$ is not always equal to $\emptyset$ -- (automata regular expressions) <p>I was going through the text Introduction to Theory of Computation by Michael Sipser. It is written that $R\circ\emptyset$ may not equal to $R$. I thought $R\circ\emptyset=\emptyset$ always. $R$ is any regular expression.</p>&...
habedi/stack-exchange-dataset
22,020
Is human being a Turing Machine?
<p>We may not have a determinate answer to this question. But is there any evidence for or against this question? Or is there any study on it?</p>&#xA;
turing machines artificial intelligence
1
Is human being a Turing Machine? -- (turing machines artificial intelligence) <p>We may not have a determinate answer to this question. But is there any evidence for or against this question? Or is there any study on it?</p>&#xA;
habedi/stack-exchange-dataset
22,033
Why is the initial state of Zobrist hashing random?
<p>When generating a board for <a href="http://en.wikipedia.org/wiki/Zobrist_hashing" rel="nofollow">Zobrist hashing</a>, why are the initial elements random? How can you detect changes to elements later if the initial values are random?</p>&#xA;
algorithms artificial intelligence hash
1
Why is the initial state of Zobrist hashing random? -- (algorithms artificial intelligence hash) <p>When generating a board for <a href="http://en.wikipedia.org/wiki/Zobrist_hashing" rel="nofollow">Zobrist hashing</a>, why are the initial elements random? How can you detect changes to elements later if the initial valu...
habedi/stack-exchange-dataset
22,039
If a set S is infinite and recognizable, is there an infinite subset of S that is decidable?
<p>If a set S is infinite and recognizable, how can I prove that, if any, some subsets K is infinite and decidable? how about infinite and recognizable? </p>&#xA;
computability turing machines
1
If a set S is infinite and recognizable, is there an infinite subset of S that is decidable? -- (computability turing machines) <p>If a set S is infinite and recognizable, how can I prove that, if any, some subsets K is infinite and decidable? how about infinite and recognizable? </p>&#xA;
habedi/stack-exchange-dataset
22,049
Proving that collision is less likely if the table size is prime in case modulo arithmetic is used
<p>If suppose your hashCode function results in the following hashCodes among others {x , 2x, 3x, 4x, 5x, 6x...}, then all these are going to be clustered in just m number of buckets, </p>&#xA;&#xA;<pre><code> where m = table_length/GreatestCommonFactor(table_length, x)&#xA;</code></pre>&#xA;&#xA;<p>Can someone help m...
hash hash tables primes
1
Proving that collision is less likely if the table size is prime in case modulo arithmetic is used -- (hash hash tables primes) <p>If suppose your hashCode function results in the following hashCodes among others {x , 2x, 3x, 4x, 5x, 6x...}, then all these are going to be clustered in just m number of buckets, </p>&#xA...
habedi/stack-exchange-dataset
22,052
Issue understanding the reduction of SAT to 3-SAT in poly time
<p>Reading this <a href="http://classes.soe.ucsc.edu/cmps102/Spring10/lect/17/SAT-3SAT-and-other-red.pdf" rel="nofollow">http://classes.soe.ucsc.edu/cmps102/Spring10/lect/17/SAT-3SAT-and-other-red.pdf</a>, I came to know that reducing a clause $C_i$ from a $SAT$ instance containing more than 3 literals to a $3-SAT$ ins...
algorithms np complete satisfiability 3 sat boolean algebra
1
Issue understanding the reduction of SAT to 3-SAT in poly time -- (algorithms np complete satisfiability 3 sat boolean algebra) <p>Reading this <a href="http://classes.soe.ucsc.edu/cmps102/Spring10/lect/17/SAT-3SAT-and-other-red.pdf" rel="nofollow">http://classes.soe.ucsc.edu/cmps102/Spring10/lect/17/SAT-3SAT-and-other...
habedi/stack-exchange-dataset
22,059
What languages does a (1-way) quantum finite state automata recognize?
<p>Sorry if this is well known, but most of the research is paywalled.</p>&#xA;&#xA;<p>So far I know that it is a subset of the regular languages, but I cannot seem to find any (available) research which pins it down.</p>&#xA;&#xA;<p>Thanks!</p>&#xA;
finite automata quantum computing
1
What languages does a (1-way) quantum finite state automata recognize? -- (finite automata quantum computing) <p>Sorry if this is well known, but most of the research is paywalled.</p>&#xA;&#xA;<p>So far I know that it is a subset of the regular languages, but I cannot seem to find any (available) research which pins i...
habedi/stack-exchange-dataset
22,060
assertion in first order logic
<p>Can anybody give me an idea how to write this assertion in in first order logic?</p>&#xA;&#xA;<blockquote>&#xA; <p>X has not passed one or more of the prerequisites for A. </p>&#xA;</blockquote>&#xA;&#xA;<p>Here, X is the name of a person and A is a constant representing a course name.</p>&#xA;
logic
1
assertion in first order logic -- (logic) <p>Can anybody give me an idea how to write this assertion in in first order logic?</p>&#xA;&#xA;<blockquote>&#xA; <p>X has not passed one or more of the prerequisites for A. </p>&#xA;</blockquote>&#xA;&#xA;<p>Here, X is the name of a person and A is a constant representing a...
habedi/stack-exchange-dataset
22,078
Karnaugh map - assign variables to the inputs?
<p><img src="https://i.stack.imgur.com/28C5o.png" alt="http://i.imgur.com/ITPF7qU.png"></p>&#xA;&#xA;<p>I drew the map on the right, but what I drew doesn't work for what the question is asking me. I think I did something very wrong, and I don't really understand what this question is asking me. Am i suppose to re arra...
logic
1
Karnaugh map - assign variables to the inputs? -- (logic) <p><img src="https://i.stack.imgur.com/28C5o.png" alt="http://i.imgur.com/ITPF7qU.png"></p>&#xA;&#xA;<p>I drew the map on the right, but what I drew doesn't work for what the question is asking me. I think I did something very wrong, and I don't really understan...
habedi/stack-exchange-dataset
22,080
Why is determining the size of a maximum independent set or a clique in P?
<p>I read that determining the size of the maximum independent set (and also a clique of maximum size) is in P. The versions that find the actual solution are known to be NP-hard. </p>&#xA;&#xA;<p>With respect to finding clique size, you can sort the node degrees, decrement $i$ from $|V|$ to $0$, and each time check if...
algorithms complexity theory graphs time complexity
1
Why is determining the size of a maximum independent set or a clique in P? -- (algorithms complexity theory graphs time complexity) <p>I read that determining the size of the maximum independent set (and also a clique of maximum size) is in P. The versions that find the actual solution are known to be NP-hard. </p>&#xA...
habedi/stack-exchange-dataset
22,094
Are there dynamic programming examples that run in exponential time?
<p>Are there dynamic programming examples that run in exponential time? Every example that I've seen so far constructs the top half of a matrix in a bottom-up fashion ($n^2$) from the base case and evaluates $n$ expressions to optimize each entry.</p>&#xA;
algorithms runtime analysis dynamic programming
1
Are there dynamic programming examples that run in exponential time? -- (algorithms runtime analysis dynamic programming) <p>Are there dynamic programming examples that run in exponential time? Every example that I've seen so far constructs the top half of a matrix in a bottom-up fashion ($n^2$) from the base case and ...
habedi/stack-exchange-dataset
22,097
Is this NP-completeness proof correct?
<p>I want to prove that a problem $P_1$ is NP-complete. Let say that I want to do a reduction from SAT problem.</p>&#xA;&#xA;<p>If the instance of problem $P_1$ depends on $M$ and $N$, can I specify the sturcture of the instance of the SAT problem? </p>&#xA;&#xA;<p>More precisely, can I say that, for example, the insta...
complexity theory np complete satisfiability
1
Is this NP-completeness proof correct? -- (complexity theory np complete satisfiability) <p>I want to prove that a problem $P_1$ is NP-complete. Let say that I want to do a reduction from SAT problem.</p>&#xA;&#xA;<p>If the instance of problem $P_1$ depends on $M$ and $N$, can I specify the sturcture of the instance of...
habedi/stack-exchange-dataset
22,099
Doubt in the correctness of decision tree models for constructing a lower bound
<p>If we were to intuitively construct a lower bound for searching an element in a list $A$ containing $n$ integers, it would be in $\Omega(n)$.</p>&#xA;&#xA;<p>But with the decision tree model, the number of leafs is $n$, so we conclude that the lower bound is $\Omega(\log{n})$.</p>&#xA;&#xA;<p>This is the same as fin...
algorithms search algorithms decision problem trees lower bounds
1
Doubt in the correctness of decision tree models for constructing a lower bound -- (algorithms search algorithms decision problem trees lower bounds) <p>If we were to intuitively construct a lower bound for searching an element in a list $A$ containing $n$ integers, it would be in $\Omega(n)$.</p>&#xA;&#xA;<p>But with ...
habedi/stack-exchange-dataset
22,102
Help in geometrically understanding "Linear Decision Trees"
<p>In the words of (<a href="http://www.cs.utah.edu/~suresh/5962/lectures/17.pdf" rel="nofollow">http://www.cs.utah.edu/~suresh/5962/lectures/17.pdf</a>, section 17.2), "Each $f(x)$ can be interpreted as defining a hyperplane in $R^n$. Thus, tracing a path through the tree computes the intersection of the half-planes de...
algorithms search trees lower bounds
1
Help in geometrically understanding "Linear Decision Trees" -- (algorithms search trees lower bounds) <p>In the words of (<a href="http://www.cs.utah.edu/~suresh/5962/lectures/17.pdf" rel="nofollow">http://www.cs.utah.edu/~suresh/5962/lectures/17.pdf</a>, section 17.2), "Each $f(x)$ can be interpreted as defining a hype...
habedi/stack-exchange-dataset
22,106
How do you classify properties as Trivial and Non-trivial?
<p>I understand what Rice's theorem states and what Trivial and Non-trivial properties mean. However, when given some property, I am having a hard time seeing if it is Trivial or Non-trivial. Can someone help me understand this better, maybe with some good examples? </p>&#xA;
computability turing machines
1
How do you classify properties as Trivial and Non-trivial? -- (computability turing machines) <p>I understand what Rice's theorem states and what Trivial and Non-trivial properties mean. However, when given some property, I am having a hard time seeing if it is Trivial or Non-trivial. Can someone help me understand thi...
habedi/stack-exchange-dataset
22,109
Relation of Space and Time in Complexity?
<p>I'm looking for some clarification on some concepts/facts I came across while studying for a class.</p>&#xA;&#xA;<p>I was reading the following wikipedia article. The below specific section and statement intrigued me when looking it over.</p>&#xA;&#xA;<p><a href="http://en.wikipedia.org/wiki/Computational_complexity...
complexity theory time complexity space complexity
1
Relation of Space and Time in Complexity? -- (complexity theory time complexity space complexity) <p>I'm looking for some clarification on some concepts/facts I came across while studying for a class.</p>&#xA;&#xA;<p>I was reading the following wikipedia article. The below specific section and statement intrigued me wh...
habedi/stack-exchange-dataset
22,111
Algorithm for detection of overlaping between vectors
<p>I am currently developing a math-physics program and I need to calculate if two vectors overlap one another, the one is vertical and the other is horizontral. Is there any fast algorithm to do this because what I came up so far, has a lot of repeats. Eg lets say we have vector V1((0,1),(2,1)) and a V2((1,0),(1,2)) w...
algorithms
1
Algorithm for detection of overlaping between vectors -- (algorithms) <p>I am currently developing a math-physics program and I need to calculate if two vectors overlap one another, the one is vertical and the other is horizontral. Is there any fast algorithm to do this because what I came up so far, has a lot of repea...
habedi/stack-exchange-dataset
22,115
What CS Textbooks should I buy?
<p>I am preparing to graduate high school. Although I do not intend to study computer science in college, I feel like it might be useful to familiarize myself with the theoretical CS concepts taught in academia (eg. algorithms, structures, compilers). Can you recommend books that are either frequently used in current C...
books
1
What CS Textbooks should I buy? -- (books) <p>I am preparing to graduate high school. Although I do not intend to study computer science in college, I feel like it might be useful to familiarize myself with the theoretical CS concepts taught in academia (eg. algorithms, structures, compilers). Can you recommend books t...
habedi/stack-exchange-dataset
22,116
How is ARC consistency un-done after a recursive failure condition?
<p>Taking <a href="http://www.geeksforgeeks.org/backtracking-set-7-suduku/" rel="nofollow">this</a> as an example:</p>&#xA;&#xA;<pre><code>bool SolveSudoku(int grid[N][N])&#xA;{&#xA; int row, col;&#xA;&#xA; // If there is no unassigned location, we are done&#xA; if (!FindUnassignedLocation(grid, row, col))&#xA...
algorithms artificial intelligence recursion constraint programming backtracking
1
How is ARC consistency un-done after a recursive failure condition? -- (algorithms artificial intelligence recursion constraint programming backtracking) <p>Taking <a href="http://www.geeksforgeeks.org/backtracking-set-7-suduku/" rel="nofollow">this</a> as an example:</p>&#xA;&#xA;<pre><code>bool SolveSudoku(int grid[N...
habedi/stack-exchange-dataset
22,126
What are the justifications and historical reasons regarding the choice between the words 'calculus' and 'algebra'?
<p>The principles of calculus, historically, are differentials and integrals <a href="http://en.wikipedia.org/wiki/Calculus" rel="nofollow">[1]</a>, while those of algebra are operators and equation solving <a href="http://en.wikipedia.org/wiki/Algebra" rel="nofollow">[2]</a>. Contemporary principles are analysis and a...
terminology
1
What are the justifications and historical reasons regarding the choice between the words 'calculus' and 'algebra'? -- (terminology) <p>The principles of calculus, historically, are differentials and integrals <a href="http://en.wikipedia.org/wiki/Calculus" rel="nofollow">[1]</a>, while those of algebra are operators a...
habedi/stack-exchange-dataset
22,136
Bin packing problem or not?
<p>Suppose I have $N$ bins and $M$ items as depicted in the figure below (3 bins and 3 items):</p>&#xA;&#xA;<p>Suppose that every bin has unit capacity and the weights of the items depend on the bins used. I want to maximize the number of items in the bins subject to:</p>&#xA;&#xA;<ul>&#xA;<li>One bin contains at most ...
complexity theory np complete optimization np hard
1
Bin packing problem or not? -- (complexity theory np complete optimization np hard) <p>Suppose I have $N$ bins and $M$ items as depicted in the figure below (3 bins and 3 items):</p>&#xA;&#xA;<p>Suppose that every bin has unit capacity and the weights of the items depend on the bins used. I want to maximize the number ...
habedi/stack-exchange-dataset
22,137
Finding constants C and k for big-O of fraction of polynomials
<p>I am a teaching assistant on a course for computer science students where we recently talked about big-O notation. For this course I would like to teach the students a general method for finding the constants $C$ and $k$ in the definition of big-O&#xA;$$&#xA;|f(x)| \leq C|g(x)|, x &gt; k,&#xA;$$&#xA;when the functi...
asymptotics polynomials
1
Finding constants C and k for big-O of fraction of polynomials -- (asymptotics polynomials) <p>I am a teaching assistant on a course for computer science students where we recently talked about big-O notation. For this course I would like to teach the students a general method for finding the constants $C$ and $k$ in ...
habedi/stack-exchange-dataset
22,149
Asymptotic Runtime of Interrelated Functions
<p>I have two functions $S$ and $T$ which are interrelated and I want to find the asymptotic worst case runtime. The fact that they are interrelated is stumping me...</p>&#xA;&#xA;<p>How would I find the asymptotic runtime $S(n)$ and $T(n)$?</p>&#xA;&#xA;<p>$$&#xA;\begin{align*}&#xA;S(n) &amp;= 2S(n/4) + T(n/4) \\&#xA...
algorithms algorithm analysis asymptotics search algorithms master theorem
1
Asymptotic Runtime of Interrelated Functions -- (algorithms algorithm analysis asymptotics search algorithms master theorem) <p>I have two functions $S$ and $T$ which are interrelated and I want to find the asymptotic worst case runtime. The fact that they are interrelated is stumping me...</p>&#xA;&#xA;<p>How would I ...
habedi/stack-exchange-dataset
22,150
The number of executions of the count statement; how many?
<p>How many times does the statement count in line 5 executes in terms of $n$?</p>&#xA;&#xA;<pre><code>1. count=0; &#xA;2. for (i=1; i&lt;=n; i++) { &#xA;3. for (j=1; j&lt;=n; j*=2) { &#xA;4. for (k=1; k&lt;=j; k++) {&#xA;5. count = count + 1;&#xA;6. }&#xA;7. }&#xA;8. }&#xA;</code></pre>&#xA;&#xA;<p...
algorithms algorithm analysis time complexity runtime analysis
1
The number of executions of the count statement; how many? -- (algorithms algorithm analysis time complexity runtime analysis) <p>How many times does the statement count in line 5 executes in terms of $n$?</p>&#xA;&#xA;<pre><code>1. count=0; &#xA;2. for (i=1; i&lt;=n; i++) { &#xA;3. for (j=1; j&lt;=n; j*=2) { &#xA;4...
habedi/stack-exchange-dataset
22,161
What memory locations will the CPU fetch instructions from with instruction length of 16bits
<p>While reading Stallings OS Internals and Design, I run into problem. Here is example from the book. </p>&#xA;&#xA;<blockquote>&#xA; <p>For example, consider a simplified computer in which each instruction occupies one 16-bit word of memory. Assume that the PC is set to the location 300. On succeeding instruction cy...
operating systems memory management
1
What memory locations will the CPU fetch instructions from with instruction length of 16bits -- (operating systems memory management) <p>While reading Stallings OS Internals and Design, I run into problem. Here is example from the book. </p>&#xA;&#xA;<blockquote>&#xA; <p>For example, consider a simplified computer in ...
habedi/stack-exchange-dataset
22,167
Selecting random points at general position
<p>How will you find a random collection of $n$ points in the plane, all with integer coordinates in a specified range (e.g. -1000 to 1000), such that no 3 of them are on the same line?</p>&#xA;&#xA;<p>The following algorithm eventually works, but seems highly inefficient:</p>&#xA;&#xA;<ol>&#xA;<li>Select $n$ points at...
algorithms computational geometry randomized algorithms
1
Selecting random points at general position -- (algorithms computational geometry randomized algorithms) <p>How will you find a random collection of $n$ points in the plane, all with integer coordinates in a specified range (e.g. -1000 to 1000), such that no 3 of them are on the same line?</p>&#xA;&#xA;<p>The following...
habedi/stack-exchange-dataset
22,169
A string representation of any Turing machine
<p>The set of all Turing machines is said to be countable. The central idea of the proof of this fact is that every Turing machine can be written as a finite string of characters. I am having trouble seeing how this could be true.</p>&#xA;&#xA;<p>If we formally define a Turing machine as having a tape language $\{0, 1,...
turing machines encoding scheme
1
A string representation of any Turing machine -- (turing machines encoding scheme) <p>The set of all Turing machines is said to be countable. The central idea of the proof of this fact is that every Turing machine can be written as a finite string of characters. I am having trouble seeing how this could be true.</p>&#x...
habedi/stack-exchange-dataset
22,178
Do the polynomials in "polynomial time" have integer, real or complex coefficients?
<p>This is probably a very basic question but do the polynomials in "polynomial time" have integer, real or complex coefficients?</p>&#xA;&#xA;<p>Everywhere I looked it just says "polynomial expression". I am guessing the polynomial must have integer coefficients?</p>&#xA;
complexity theory
1
Do the polynomials in "polynomial time" have integer, real or complex coefficients? -- (complexity theory) <p>This is probably a very basic question but do the polynomials in "polynomial time" have integer, real or complex coefficients?</p>&#xA;&#xA;<p>Everywhere I looked it just says "polynomial expression". I am gues...
habedi/stack-exchange-dataset
22,188
How should $\lambda x. \lambda y. f z x y \stackrel{\eta}{=} \lambda x. f z x$ be read?
<p>I'm currently learning untyped $\lambda$-calculus and especially the $\eta$-reduction.</p>&#xA;&#xA;<p>The professor hat the following in his slides:</p>&#xA;&#xA;<p>$$\lambda x. \lambda y. f~z~x~y \stackrel{\eta}{=} \lambda x. f~z~x$$</p>&#xA;&#xA;<p>I don't know how to read and understand this. Could you please ex...
lambda calculus
1
How should $\lambda x. \lambda y. f z x y \stackrel{\eta}{=} \lambda x. f z x$ be read? -- (lambda calculus) <p>I'm currently learning untyped $\lambda$-calculus and especially the $\eta$-reduction.</p>&#xA;&#xA;<p>The professor hat the following in his slides:</p>&#xA;&#xA;<p>$$\lambda x. \lambda y. f~z~x~y \stackrel{...
habedi/stack-exchange-dataset
22,200
How is this problem related to the study of algorithms and big O notation?
<p>I'm taking a graduate computer science course on algorithms and analysis. The current subject is big O notation and recursion. How is the following problem related to the study of algorithms, recursion, and big O notation? I know and understand the solution to the problem, but I just don't see how this is relevant t...
algorithms asymptotics
1
How is this problem related to the study of algorithms and big O notation? -- (algorithms asymptotics) <p>I'm taking a graduate computer science course on algorithms and analysis. The current subject is big O notation and recursion. How is the following problem related to the study of algorithms, recursion, and big O n...
habedi/stack-exchange-dataset
22,204
Why doesn't a time cutoff convert NP problems into co-NP?
<p>Suppose you have an NP problem, and a polynomial time verifier which accepts valid solutions within $f(n)$ operations.</p>&#xA;&#xA;<p>You make a tweak to the verifier program, so that if it takes more than $f(n)$ operations, it unconditionally rejects. Then you place it into an NP machine and run it on all possible...
complexity theory np co np
1
Why doesn't a time cutoff convert NP problems into co-NP? -- (complexity theory np co np) <p>Suppose you have an NP problem, and a polynomial time verifier which accepts valid solutions within $f(n)$ operations.</p>&#xA;&#xA;<p>You make a tweak to the verifier program, so that if it takes more than $f(n)$ operations, i...
habedi/stack-exchange-dataset
22,216
How to stop genetic algorithm population converging to a single value
<p>I've written a genetic algorithm (GA) that solves a 7-dimensional optimisation problem. All seven variables are floating point numbers. The problem is that the entire population seems to converge to very nearly the same point in the solution space within about 20 generations, even if I increase the population size...
optimization genetic algorithms
1
How to stop genetic algorithm population converging to a single value -- (optimization genetic algorithms) <p>I've written a genetic algorithm (GA) that solves a 7-dimensional optimisation problem. All seven variables are floating point numbers. The problem is that the entire population seems to converge to very near...
habedi/stack-exchange-dataset
22,218
Mapping intuitionistic logic to the modal logic S4
<p>In his famous <a href="https://www.princeton.edu/~hhalvors/restricted/kripke_intuitionism.pdf" rel="noreferrer">Semantical Analysis of Intuitionistic Logic</a>,&#xA;S. Kripke speaks of the "well-known mappings of intuitionistic logic&#xA;into the modal system S4". I'm not sure which mappings Kripke means.&#xA;One gu...
reference request logic
1
Mapping intuitionistic logic to the modal logic S4 -- (reference request logic) <p>In his famous <a href="https://www.princeton.edu/~hhalvors/restricted/kripke_intuitionism.pdf" rel="noreferrer">Semantical Analysis of Intuitionistic Logic</a>,&#xA;S. Kripke speaks of the "well-known mappings of intuitionistic logic&#xA...
habedi/stack-exchange-dataset
22,227
What does an input string of epsilon mean?
<p>I am currently reading Introduction to the Theory of Computation (Sipser), and after introducing epsilon labeled transition arrows, the book shows the following NFA:</p>&#xA;<p><img src="https://i.stack.imgur.com/B8lUJ.jpg" alt="enter image description here" /></p>&#xA;<p>I was following it until I read the followin...
finite automata
1
What does an input string of epsilon mean? -- (finite automata) <p>I am currently reading Introduction to the Theory of Computation (Sipser), and after introducing epsilon labeled transition arrows, the book shows the following NFA:</p>&#xA;<p><img src="https://i.stack.imgur.com/B8lUJ.jpg" alt="enter image description ...
habedi/stack-exchange-dataset
22,233
Hardness of mixed 3-SAT and 2-SAT formula
<p>It is well known that 3-SAT is $\sf NP$-complete , but 2-SAT is in $\sf P$. Let there be a formula with $n-1$ clauses with 2 literals each and only 1 clause with 3 literals. </p>&#xA;&#xA;<p>We can solve this case in polynomial time, separating and solving in a brute force manner the 3 literal clause and then for...
complexity theory np complete satisfiability
1
Hardness of mixed 3-SAT and 2-SAT formula -- (complexity theory np complete satisfiability) <p>It is well known that 3-SAT is $\sf NP$-complete , but 2-SAT is in $\sf P$. Let there be a formula with $n-1$ clauses with 2 literals each and only 1 clause with 3 literals. </p>&#xA;&#xA;<p>We can solve this case in polyn...
habedi/stack-exchange-dataset
22,239
There is equivalence in an NP-hardness proof or not?
<p>I want to show that some problem $P_1$ is NP-hard. I have a problem $P_2$ that is NP-complete. From an instance of $P_2$ I created in polynomial time an instance of the problem $P_1$.</p>&#xA;&#xA;<p>My question is: Should I verify both direction ($\Leftrightarrow$) or only one direction ($\Rightarrow$)? More precis...
complexity theory np complete reductions np hard
1
There is equivalence in an NP-hardness proof or not? -- (complexity theory np complete reductions np hard) <p>I want to show that some problem $P_1$ is NP-hard. I have a problem $P_2$ that is NP-complete. From an instance of $P_2$ I created in polynomial time an instance of the problem $P_1$.</p>&#xA;&#xA;<p>My questio...
habedi/stack-exchange-dataset
22,242
Regular expression to show that all strings contain each symbol atleast once
<p>I'm studying for my exam and I came across the following exam question from last year, the only way I know how to solve this is build a regex that accounts for all six different series of letters so for example to recognize a string that has the letters a,b and c occur in that order:</p>&#xA;&#xA;<p>$(a+b+c)^*a(a+b+...
regular languages regular expressions
1
Regular expression to show that all strings contain each symbol atleast once -- (regular languages regular expressions) <p>I'm studying for my exam and I came across the following exam question from last year, the only way I know how to solve this is build a regex that accounts for all six different series of letters s...
habedi/stack-exchange-dataset
22,246
Proving NP-completeness of a graph coloring problem
<p>Given a graph $G=(V,E)$ and a set of colors $k&lt;V$. Find a assignment of colors to vertices that minimizes the number of adjacent vertices in conflict. (Two adjacent vertices are in conflict if they have the same color.)</p>&#xA;&#xA;<p>I want to prove the above problem is NP-complete. Call the above problem P1.</...
complexity theory graphs np complete reductions
1
Proving NP-completeness of a graph coloring problem -- (complexity theory graphs np complete reductions) <p>Given a graph $G=(V,E)$ and a set of colors $k&lt;V$. Find a assignment of colors to vertices that minimizes the number of adjacent vertices in conflict. (Two adjacent vertices are in conflict if they have the sa...
habedi/stack-exchange-dataset
22,255
Why are pushdown automata countable?
<p>I began a chapter in a textbook on computational theory where they begin to talk about decidable languages. </p>&#xA;&#xA;<p>The problems in this section are pretty confusing and I honestly don't know how to begin them because I'm not 100% on what they mean when they say "countable". </p>&#xA;&#xA;<p>Can anyone help...
terminology automata pushdown automata uncountability
1
Why are pushdown automata countable? -- (terminology automata pushdown automata uncountability) <p>I began a chapter in a textbook on computational theory where they begin to talk about decidable languages. </p>&#xA;&#xA;<p>The problems in this section are pretty confusing and I honestly don't know how to begin them be...
habedi/stack-exchange-dataset
22,256
Relaxed graph coloring, with penalties for assigning adjacent vertices the same color
<p>Consider a set of $N$ nodes. There is a $N\times N$ non-negative valued matrix $D$ where the $(i,j)$th element $d_{ij}$ gives the "positive metric" between node $i$ and $j$, where $i,j\in [N]$. Thus the diagonal entries of $D$ are all zero and $d_{ij}=d_{ji}$ so $D$ is symmetric. </p>&#xA;&#xA;<p>Then there is a set...
complexity theory reductions np hard colorings
1
Relaxed graph coloring, with penalties for assigning adjacent vertices the same color -- (complexity theory reductions np hard colorings) <p>Consider a set of $N$ nodes. There is a $N\times N$ non-negative valued matrix $D$ where the $(i,j)$th element $d_{ij}$ gives the "positive metric" between node $i$ and $j$, where...
habedi/stack-exchange-dataset
22,264
Impact on the order of elements on the cost of searching in a linked list
<p>I have the following homework question that I am struggling with. I have read the corresponding chapter from the book, but no guidance there.</p>&#xA;&#xA;<p>Consider a linked list $X: X_1 \to X_2 \to X_3 \ldots$.&#xA;Assume that the cost of examining a particular element $X_i$ is $C_i$. Note that to examine $X_i$, ...
algorithm analysis data structures linked lists
1
Impact on the order of elements on the cost of searching in a linked list -- (algorithm analysis data structures linked lists) <p>I have the following homework question that I am struggling with. I have read the corresponding chapter from the book, but no guidance there.</p>&#xA;&#xA;<p>Consider a linked list $X: X_1 \...
habedi/stack-exchange-dataset
22,272
If L is a non-regular language over {a}, are all Myhill-Nerode classes singletons?
<p>Is there a non-regular language over unary alphabet $\{a\}$ which has a Myhill-Nerode equivalence class that is not a singleton?</p>&#xA;
formal languages automata
1
If L is a non-regular language over {a}, are all Myhill-Nerode classes singletons? -- (formal languages automata) <p>Is there a non-regular language over unary alphabet $\{a\}$ which has a Myhill-Nerode equivalence class that is not a singleton?</p>&#xA;
habedi/stack-exchange-dataset