instruction
stringlengths
0
29.8k
⌀
Running time of 01-Knapsack-like with negative weight/values, absolute value weight constraint, and volume constraint?
|complexity-theory|dynamic-programming|knapsack-problems|
I understand the @user326210 algorithm and on basis of my understanding I design the below NPDA. [![enter image description here][1]][1] [1]: https://i.stack.imgur.com/h4R4x.jpg
null
Yes and no. Ignoring special-purpose CPUs (e.g. stack machines, which still matter), most instruction set architectures (ISA for short) fall into one of two fuzzy categories: - [Load/store architectures][1], such as ARM, have separate memory instructions (i.e. loads and stores) and ALU instructions. - [Registe...
In the **[MTD-f][1]** algorithm: ``` function MTDF(root : node_type; f : integer; d : integer) : integer; g := f; upperbound := +INFINITY; lowerbound := -INFINITY; repeat if g == lowerbound then beta := g + 1 else beta := g; g := AlphaBetaWithMemory(root, beta - 1, beta, d); ...
Understanding MTD-f
|algorithms|algorithm-analysis|search-algorithms|
Suppose I have a set of N*L elements. I wish to generate a sequence of k partitions of size L such that I maximize the number of pairs of elements that share membership of the same partition. What kind of algorithm would optimize this? To make it easier to understand, imagine an icebreaker situation: Suppose I have ...
"Icebreaker problem": Dividing set into partitions that maximize pairwise shared memberships?
|algorithms|partitions|
Suppose I have a set of N*L elements. I wish to generate a sequence of k partitions of size L such that I maximize the number of pairs of elements that share membership of the same partition. What kind of algorithm would optimize this? To make it easier to understand, imagine an icebreaker situation: Suppose I have ...
An NFA (with $\epsilon$-moves or not) can be viewed naturally as a directed multi-graph. <!-- a natural forgetful functor --> We will use "state" and "node" interchangeably. Whether an NFA accepts an infinite language is the same as whether there is a path from the initial state to an accepting state that contains a...
More out of curiosity than anything else. I know you can always generate a list of random numbers and then sort it, but I was wondering if there exists a (pseudo)random number generator whose output is already in sorted order? I found [this][1], but it and everything else I found only generates integer lists. Is there ...
Algorithm for generating sorted lists of random floats
|algorithms|sorting|pseudo-random-generators|
null
First, there are many more registers in a modern CPU than the ones that are visible to the program. Your iPhone has about 500 of each type of register per CPU; they are needed to perform out-of-order execution so you don’t have to wait forever for registers to become available. Second, arithmetic is not performed w...
You can’t calculate any runtime except for some very simple model of a CPU. You can calculate the exact number of comparisons, or the exact number of operations moving array elements of a particular implementation of an algorithm, but it’s practically impossible to predict how many seconds or microseconds the algorithm...
{"OriginalQuestionIds":[151382],"Voters":[{"Id":755,"DisplayName":"D.W."}]}
null
Consider a deterministic finite automaton $M(k) = (Q, Σ, \delta, 0, F)$, with $k ≥ 2$ and $Q = \{0,1,...,k-1\}$ $Σ = \{0,1\}$ $\delta(q,a) = (q+a) \space mod \space k$ $F = \{0\}$ If $L$ is the language recognised by $M(k)$, describe a deterministic finite automaton that recognises the concatenation $L ...
Finding a DFA for concatenation
null
{"Voters":[{"Id":755,"DisplayName":"D.W."}],"SiteSpecificCloseReasonIds":[]}
I came across the below question where the polynomial time solution to the "Set Cover Problem" is discussed when the subsets are of size EXACTLY 2. https://cs.stackexchange.com/questions/77575/set-cover-problem-with-sets-of-size-2 The solution described involves constructing an Edge Cover for a slightly different g...
I've been going through some questions on old homework and faced a question that confused me somehow. ***Question:*** Given a language $$L=\{\langle M\rangle\ |\ M \text{ is a Turing machine. } M \text{ goes through some configuration } (q,s,i) \text{ infinite times on input } \epsilon\}$$ determine whether it's dec...
null
Language of Turing machines that go through some configuration infinitely many times on empty input
Link shorteners don't face this problem. When they generate a word for you, they use a fixed-length words, so it suffices to keep a dictionary of all words that are currently in use. Also most words are not in use, so for their purpose it suffices for them to pick a random word, check that it is not in use, and if it ...
Link shorteners don't face this problem. When they generate a word for you, they use a fixed-length words, so it suffices to keep a dictionary of all words that are currently in use. Also most words are not in use, so for their purpose it suffices for them to pick a random word, check that it is not in use, and if it ...
For concreteness, let's first work out the solution when $k=3$; the same approach generalizes to arbitrary $k$. Observe that the language $L$ is the set of all binary strings whose number of $1$'s is a multiple of $3$. Thus, $L = \{\epsilon, 0, 00, 000, 111, 1101, \ldots\}$, where $\epsilon$ is the empty string in $\{...
No, it is not decidable. ------ Towards a contradiction suppose $L$ is decidable. Given a Turing machine $T$, let us construct $U$ so that $U$ is in $L$ iff $T$ halt on empty input. We can view $T$'s actions upon empty input as a sequence of transitions from configuration $c_k=(q_k, s_k, i_k)$ to $c_{k+1}...
null
I've been going through some questions on old homework. Here was a question that confused me somehow. ***Question:*** Given a language $$L=\{\langle M\rangle\ |\ M \text{ is a Turing machine. } M \text{ goes through some configuration } (q,s,i) \text{ infinite times on input } \epsilon\}$$ determine whether it's dec...
|formal-languages|turing-machines|semi-decidability|decidability|
For concreteness, let's first work out the solution when $k=3$; the same approach generalizes to arbitrary $k$. Observe that the language $L$ is the set of all binary strings whose number of $1$'s is a multiple of $3$. Thus, $L = \{\epsilon, 0, 00, 000, 111, 1101, \ldots\}$, where $\epsilon$ is the empty string in $\{...
It turns out that the same DFA given for $L$ also accepts the language $L^7$ because $L=L^7$. Note that while a DFA $M$ can accept many strings, it accepts only one language, called the language accepted by $M$, and denoted $L(M)$. It was possible for the given DFA to accept both $L$ and $L^7$ because these two langua...
It turns out that the same DFA given for $L$ also accepts the language $L^7$ because $L=L^7$. Note that while a DFA $M$ can accept many strings, it accepts only one language, called the language accepted by $M$, and denoted $L(M)$. It was possible for the given DFA to accept both $L$ and $L^7$ because these two langua...
I need a layout algorithm and use it in the GUI, but I can't use existing GUI toolkits at the moment, so I would like to find a layout algorithm. I only need to do a single row layout, and here is the description of the algorithm. ### Input Data First, there are three sequences. $$\begin{split} A &= x_1,x_2,...
It turns out that the same DFA given for $L$ also accepts the language $L^7$ because $L=L^7$. Note that while a DFA $M$ can accept many strings, it accepts only one language, called the language accepted by $M$, and denoted $L(M)$. It was possible for the given DFA to accept both $L$ and $L^7$ because these two langua...
I need a layout algorithm and use it in the GUI, but I can't use existing GUI toolkits at the moment, so I would like to find a layout algorithm. I only need to do a single row layout, and here is the description of the algorithm. ### Input Data First, there are three sequences. $$\begin{split} A &= x_1,x_2,...
I need a layout algorithm and use it in the GUI, but I can't use existing GUI toolkits at the moment, so I would like to find a layout algorithm. I only need to do a single row layout, and here is the description of the algorithm. ### Input Data First, there are three sequences. $$\begin{split} A &= x_1,x_2,...
null
I need a layout algorithm and use it in the GUI, but I can't use existing GUI toolkits at the moment, so I would like to find a layout algorithm. I only need to do a single row layout, and here is the description of the algorithm. ### Input Data First, there are three sequences. $$\begin{split} A &= x_1,x_2,...
**Solution 1** Given an instance $\Pi$ of set cover with non-empty subsets of size at most 2, consider two instances of set cover with subsets of size exactly 2: - $\Pi'$ contains all subsets in $\Pi$ of size exactly 2. - $\Pi''$ contains all subsets in $\Pi$ of size exactly 2, and in addition, for each singleto...
null
The Myhill-Nerode relation with respect to a given language $L \subseteq \Sigma^*$ is an equivalence relation on $\Sigma^*$ and hence gives a partition of $\Sigma^*$. Because this is a partition, the equivalence classes must be pairwise disjoint and their union must be all of $\Sigma^*$. Two strings $x, y \in \Sigma^...
null
If nothing precise was specified, you can enumerate all operations by type, such as addition, comparison, swap... and give a detailed account of their numbers. That assumes the the basic operations take some constant (but unknown) time each. In practice, you prefer to limit the evaluation to a single type of operati...
null
Consider the bubble sort algorithm shown below: function sort(A) n = A.length for i = 1 to n-1 for j = n downto i+1 if A[j] < A[j-1] swap A[j] with A[j-1] One way to measure the performance of this algorithm is to count the number of swaps p...
null
null
I want to prove that the language of all regular expressions is not a regular language. I'm having trouble to approach this problem. I thought maybe to show that the parenthesis language is a part of it, and then I can rule out the regularity.
Prove that the language of regular expressions is not regular
|regular-languages|regular-expressions|pumping-lemma|
In Michael Sipser's *Introduction to the Theory of Computation*, Example 1.56 shows how to convert $\left(\text{ab }\cup\text{ a}\right)^*$ to an NFA. It builds up from the smallest subexpression to larger subexpressions until the required NFA is obtained: [![the process, step-by-step][1]][1] My question is: why ...
NFA to recognize the language ${ab}$
|finite-automata|regular-expressions|nondeterminism|
It is because of the method used for the construction. The NFA that results from the concatenation of two automata $A_1$ and $A_2$ is the juxtaposition of $A_1$ and $A_2$ with $\varepsilon$-transitions from the final states of $A_2$ to the initial state of $A_2$. Given the automata for the regular expressions $a$ an...
It is because of the method used for the construction. The NFA that results from the concatenation of the languages of two automata $A_1$ and $A_2$ is the juxtaposition of $A_1$ and $A_2$ with $\varepsilon$-transitions from the final states of $A_1$ to the initial state of $A_2$. Given the automata for the regular e...
null
Suppose that $f\colon \{\pm1\}^n \to \{\pm1\}$ and that $g\colon \{\pm1\}^m \to \{\pm1\}$ is balanced. The composed function $f \circ g\colon \{\pm1\}^{nm} \to \{\pm1\}$ is given by $$ (f \circ g)(x) = f\bigl(g(x_{1,1},\ldots,x_{1,m}),\ldots g(x_{n,1},\ldots,x_{n,m})\bigr). $$ The influence of $x_{i,j}$ is the probab...
Notation: $\Sigma:=\{a_1,\cdots ,a_\Delta\}$ finite alphabet $\Sigma^n= \underbrace{\Sigma \times \Sigma \times \cdots \times \Sigma}_{n}$ Words of length $=n$ $\Sigma^*= \bigcup \limits_{n\geq0} \Sigma^n$ Set of all finite words $L \subseteq \Sigma^*$ Language I'm trying to prove, that the following sta...
The procedure described in the text is a *systematic method* for converting a regular expression to an NFA. It’s a recipe that works, and so you don’t have to think much to prove that the language of every regular expression is accepted by some DFA. However, the machine obtained in this manner would generally not have...
I'm trying to prove, that the following statements are either true or false. Unfortunately, I'm having a hard time finding formal proofs for my answers. I hope you can help me out a bit. Let $A,B$ be two subsets of $\{0,1\}^*$ 1. If $A$ is regular pumpable and $B \subseteq A$, then B is regular pumpable too. ...
null
Graph Homomorphism is a well-known NP-complete problem. Given graph $G$ and $H$, $G$ is said to be homomorphic to $H$ if there is a mapping $f: V(G) \mapsto V(H)$ such that $(u,v) \in E(G) \implies (f(u), f(v)) \in E(H)$. The mapping in above is unrestricted -- and hence, multiple nodes of $G$ can map to a single n...
Graph Injective-Homomorphism Problem
|graphs|colorings|
I'm trying to flip a triangle like this in the following image:\ [![enter image description here][1]][1]\ there are two constraints in flipping it:\ 1- flip it with the minimum circles moves\ 2- the circles is sliding from a place to another and can't jump over another circle. The triangle can be of any size.\ ...
What is the best algorithm to flip a triangle?
|algorithms|
Let us be given a function $f(x_1,\dots,x_{10})$ of multiple variables $x_1,\dots,x_{10}$ given that $\sum_{i=1}^{10} x_i \leq 7$. How do we solve the following problem: $$ \begin{equation} \begin{aligned} \max_{\{x_i\}, i=1,\dots,10} \quad & f(x_1,\dots,x_{10})\\ \textrm{s.t.} \quad & \sum_{i=1}^{10} x_i \leq 7...
Optimizing an arbitrary function using dynamic programming
|algorithms|optimization|dynamic-programming|
I need to define a grammar for $L=\{a^ib^ic^jd^j| i \ge j \ge 0\}$ as I wasn't told about any restrictions for the grammar, e.g context-free or context-sensitive, I assume any derivation rules can be used here. Because the number of $a$s and $b$s is greater than, or equals to, the number of $c$s and $d$s I have this...
Defining grammar for $L=\{a^ib^ic^jd^j| i \ge j \ge 0\}$
|formal-grammars|
I am assuming that the question is asking for maximal chains. (It's not too difficult to modify the below procedure to get all possible chains) Below is the step by step approach. 1. It is trivial to group the the given data by users (can use sorting or a hash table on the user id). Now, we can find the chains...
I do not see a dynamic programming solution. I highly doubt there is one (especially, a polynomial time).
null
null
Yes, this will work: if you may assume that the language of matching brackets is non-regular, it is sifficient to know that whenever a language is regular, erasing all occurrences of a particular character from all of its words produces a regular language. That isn't very hard to prove.
I need to define a grammar for $L=\{a^ib^ic^jd^j| i \ge j \ge 0\}$ as I wasn't told about any restrictions for the grammar, e.g context-free or context-sensitive, I assume any derivation rules can be used here. Because the number of $a$s and $b$s is greater than, or equals to, the number of $c$s and $d$s I have this...
No, $L$ is not decidable. ***Proof by contradiction*** Given a Turing machine $T$, we will construct another Turing machine $U$ algorithmically so that $U$ is in $L$ iff $T$ halts on empty input, in the next section, "Construction of $U$ from $T$". If $L$ is decidable, i.e., we can decide whether $U$ is in $L...
I'm trying to flip a triangle like this in the following image:\ [![enter image description here][1]][1]\ there are two constraints in flipping it:\ 1- flip it with the minimum circles moves\ 2- the circles is sliding from a place to another and can't jump over another circle.\ 3- the circle can move vertically or...
In the **[MTD-f][1]** algorithm: ``` function MTDF(root : node_type; f : integer; d : integer) : integer; g := f; upperbound := +INFINITY; lowerbound := -INFINITY; repeat if g == lowerbound then beta := g + 1 else beta := g; g := AlphaBetaWithMemory(root, beta - 1, beta, d); ...
null
As D.W. mentioned, $G$ is injective-homomorphic to $H$ if and only if $G$ is isomorphic to a subgraph of $H$. That is why you are "unable to find a single research paper on 'injective-homomorphic'". There are [plenty of paper about subgraphs](https://scholar.google.ca/scholar?q=subgraph) or [about subgraph isomorphism]...
As D.W. mentioned, $G$ is injective-homomorphic to $H$ if and only if $G$ is isomorphic to a subgraph of $H$. That is why you are "unable to find a single research paper on 'injective-homomorphic'". There are [plenty of paper about subgraphs](https://scholar.google.ca/scholar?q=subgraph) or [about subgraph isomorphism]...
As D.W. mentioned, $G$ is injective-homomorphic to $H$ if and only if $G$ is isomorphic to a subgraph of $H$. That is why you are "unable to find a single research paper on 'injective-homomorphism'". There are [plenty of paper about subgraphs](https://scholar.google.ca/scholar?q=subgraph) or [about subgraph isomorphism...
How would one count the amount of solutions to quantified formulas that have universal quantifiers? For example, for a boolean formula $\Phi(X)$ let's construct a quantified boolean formula $\forall y \ \exists X: y \lor \Phi(X)$. What would be the number of solutions to it? Either $0$ or $1$? If so, can we conlude $\m...
Universal quantification and the number of solutions
|logic|counting|
null
You haven't answered the question about what distribution, so I will assume you want the uniform distribution on [0,1]. Yes, this can be done. However, I doubt that the result will be better in practice than just generating $n$ numbers uniformly at random and sorting them. Based on the [order statistics of the u...
null
null