instruction stringlengths 0 29.8k ⌀ |
|---|
|complexity-theory|reference-request|satisfiability| |
Let $B$ be a boolean formula consisting of the usual AND, OR, and NOT operators and some variables. I would like to count the number of satisfying assignments for $B$. That is, I want to find the number of different assignments of truth values to the variables of $B$ for which $B$ assumes a true value. For example, th... |
Is there a sometimes-efficient algorithm to compute the number of satisfying assignments for a boolean formula? |
In the case of SAT, the naive idea would be to use a local search. This method gives no guarantees ofcourse, but might very well find multiple assignments.
If you restrict your attention to $2$-SAT or $3$-SAT, you can do better. There are algorithms that run in $O(1.3247^n)$ and $O(1.6894^n)$ for these problems resp... |
You can try to use pushdown automata. Given a pushdown automaton for the original language, we construct one for the cyclic shift. The new automaton operates in two stages, corresponding to the $y$ and the $x$ part of the word $yx$ (where $xy$ is in the original language). In the first stage, whenever the automaton wou... |
C's strings cannot contain character 0 and its library functions are unsuitable for dealing with data
Filenames on Unix systems cannot contain character 0 or character 47 (the slash).
In the original implementation of Unix, filenames were limited to 14 characters. Later versions only relaxed this distinction; th... |
Let $B$ be a boolean formula consisting of the usual AND, OR, and NOT operators and some variables. I would like to count the number of satisfying assignments for $B$. That is, I want to find the number of different assignments of truth values to the variables of $B$ for which $B$ assumes a true value. For example, th... |
Is there a sometimes-efficient algorithm to solve #SAT? |
The problem you are interested in is known as #SAT, or model counting. In a sense, it is the classical #P-complete problem. Model counting is hard, even for $2$-SAT! Not surprisingly, the exact methods can only handle instances with around hundreds of variables. Approximate methods exist too, and they might be able to ... |
The problem you are interested in is known as #SAT, or model counting. In a sense, it is the classical #P-complete problem. Model counting is hard, even for $2$-SAT! Not surprisingly, the exact methods can only handle instances with around hundreds of variables. Approximate methods exist too, and they might be able to ... |
null |
This is my first question here. I was studying binomial heaps and it time analysis. Can there be any inputs that cause DELETE-MIN, DECREASE-KEY,and DELETE to run in Big-omega(log n) time for a binomial heap rather than Big-O(logn)
Thanks |
Inputs for Binomial Heaps |
|algorithms| |
The general case is indeed a bit complicated.
However, in the case of **4 disks** you can simplify it a lot; you do not really need to know any fancy math. You only need to know how to store **4 bits** redundantly, and then you already know everything; just repeat the same scheme for each group of 4 bits that you ne... |
I was studying binomial heaps and its time analysis. Are there any inputs that cause DELETE-MIN, DECREASE-KEY, and DELETE to run in $\Omega(\log n)$ time for a binomial heap rather than $O(\log n)$? |
Input that causes an operation on a binomial heap to run in $\Omega(\log n)$ time? |
|algorithms|time-complexity| |
Easy proof for context-free languages being closed under cyclic shift |
I would like to know in which classification is the R programming language. It has elements of the imperative paradigm and object oriented paradigm (some things like that even a number is an object and they can be freely mixed). I am not quite sure if it has functional programming characteristics. So it can be consider... |
What would be the classification of R according to paradigms? |
I ended up figuring it out, thanks all for the help.
![enter image description here][1]
[1]: https://i.stack.imgur.com/KtfsA.png |
null |
EDIT: this seems to be an interesting problem, and I had a little research about it. I suggest you read the following:
1. Darell Raymond. Partial order databases, PhD Thesis, University of Waterloo.
I suggest you read this paper:
Daskalakis, Constantinos, et al. "Sorting and selection in posets." SIAM Journal ... |
[This paper][1] shows that for each priority queue implementation satisfying some technical condition (which holds for binomial heaps) there is a sequence of operations consisting of $n$ INSERTs, $n$ DELETEs and $n$ FIND-MINs that takes time $\Omega(n\log n)$. Since INSERTs are amortized $O(1)$ in binomial heaps, the D... |
this is my first question!
My CS Theory Professor said that when proving that a language is not regular by the Pumping Lemma, that there are some 'tricks' for solving languages more complicated that something like L = {an bn: n is an integer}. Although I know that these come with practice, I wondered if this community... |
What are some good hints for proving nonregular with pumping lemma? |
|proof-techniques|pumping-lemma| |
this is my first question!
My CS Theory Professor said that when proving that a language is not regular by the Pumping Lemma, that there are some 'tricks' for solving languages more complicated that something like $L = \{a^{n} b^{n}\mid n \in\mathbb{N}\}$. Although I know that these come with practice, I wondered if t... |
null |
Always notice that you apply the *reverse direction* of the implication stated in the lemma when proving non-regularity. That is for any $k\in \mathbf{N}$ you pick a word $w\in L$ (depended on $k$) that has length at least $k$ and there is no way to split the word into three parts, such that pumping the middle parts in... |
|algorithms|data-structures|lower-bounds|heaps| |
Disclaimer: This is not a full-fledged answer, but - in my opinion - nevertheless relevant in the context of this question.
I once heard the following definition of what a *scripting language* as at some conference. Namely, if its main purpose is to orchestrate components that exist in their own rights outside of th... |
For the $n$-th prime number $p_n$ the *[primorial][1]* $p_n\#$ is defined as the product of the first $n$ primes.
<blockquote>
What is the complexity of testing if a given number $n$ is a primorial?<br>
Is it related in some way to the FACTORING problem?<br>
</blockquote>
[1]: http://en.wikipedia.org/wiki/... |
Complexity of testing if a number is a primorial |
|complexity-theory|reference-request| |
My CS Theory Professor said that when proving that a language is not regular by the Pumping Lemma, that there are some 'tricks' for solving languages more complicated that something like $L = \{a^{n} b^{n}\mid n \in\mathbb{N}\}$. Although I know that these come with practice, I wondered if this community would have s... |
What are some good hints for proving non-regularity with the pumping lemma? |
|formal-languages|proof-techniques|pumping-lemma| |
The term can at least be traced back to a publication by Carriero, Gelernter and Leichter from 1986: [Distributed Datastructures in Linda][1][Lin86]. The paper attributes the term to *Rob Bjornson* (which I believe to be [this guy][2]), but only cites personal communication as their mean of learning the term. [Lin86] a... |
This is simpler than factoring. You can simply multiply all prime numbers up to the point where you (a) reach $p_n$ or (b) get a product which is larger than $p_n$. In the first case, you answer `yes` otherwise you answer `no`.
The reason it is simpler is that the prime factorization is trivial, whereas in the FAC... |
I am studying primitive recursive functions and there's something that I don't quite understand: let's take the function that computes $x+y$, then, in order to show that $f(x,y)=x+y$ is primitive recursive, my lecture notes give the following equations:
\begin{cases}
f(x,0)=x \\
f(x,y+1) = f(x,y)+1
\end... |
Clarifications on primitive recursive function definition |
|computability| |
|computability|terminology|recursion| |
|computer-architecture| |
The interesting question is: what is the alternative? The only other method I know is testing/benchmarking. We program the algorithms, let them run on (a representative sample of) the finite input set and compare the results. There are a couple of problems with that.
* The results are not general in terms of machin... |
|formal-grammars|context-free|ambiguity| |
i don't think there is a fixed method of derivations to make a grammar unambiguous.
you have to try by trail and error method by adding new non-terminals to the grammar without changing the definition of that grammar. |
null |
The first equation is what you would normally write down as a mathematician if you were to define addition in terms of successor. The second equation is the same thing, except it is written in a precise manner so as to make it obvious that this indeed is a definition by primitive recursion. You have to pay close attent... |
As this thread title gives away I need to prove $x^y$ to be a primitive recursive function.
So mathematically speaking, I think the following are the recursion equations, well aware that I am assigning to $0^0$ the value $1$, which shouldn't be, since it is an "indeterminate" form.
\begin{cases}
x^0=1 \\
x... |
Show $x^y$ is a primitive recursive function |
|computability|recursion|check-my-proof| |
Here's (an attempt at) a polynomial-time algorithm for LMC on arbitrary binary DAGs $G$.
This answers Question #3. (Sorry for the messy write-up ahead of time. :))
To begin, throw out "forever" any vertex not reachable from $s$. We don't care about these, since they're not part of any $s$-$t$ path.
Next, defi... |
null |
As I wrote in the comments, you haven't actually proved anything. If you want to prove that $x^y$ is p.r., you need to write it in the scheme form, and then you need to prove that indeed $x^y = f(y,x)$ for your defined $f$ for all $x$ and $y$ (by double induction).
Consider the following definition of $f(y,x) = x^y... |
Here's a hint: Consider Vertex Cover, which is NP-complete. If $G = (V,E)$ has a vertex cover of size $k$, then you can remove $k$ vertices from $G$ to obtain $G'$ such that $G'$ is an edgeless graph on $n-k$ vertices. |
I have two graphs G1=(V1,E1) and G2=(V2,E2) and I have to find the minimum number of nodes to delete in order for the two graphs to become identical. I have to show that this problem in NP-complete.
Can somebody help me with this problem? It is school homework and I don't know how to solve it. |
How to prove a problem is NP-complete? |
|np| |
|complexity-theory|np-complete|reductions| |
Here's a hint: Consider Vertex Cover, which is NP-complete. If $G = (V,E)$ has a vertex cover of size $k$, then you can remove $k$ vertices from $G$ to obtain $G'$ such that $G'$ is an edgeless graph on $n-k$ vertices.
Edit: The correct reduction (by using Vertex Cover) shows the problem to be NP-hard. Given the... |
Consider the following problem: Given two graphs $G_1 = (V_1, E_1)$ and $G_2 = (V_2, E_2)$ and some non-negative integer $k \in \mathbb{N}$, is it possible to delete at most $k$ vertices from $G_1$ to obtain $G_1'$ such that $G_1' \cong G_2$, i.e. the resulting graph is isomorphic to $G_2$.
I have to show that this... |
null |
I'm thinking about the optimal algorithm for the following problem:
Input data:
- a **text**, say it's an article about 5-50 pages.
- a set of **ngrams** (ngram strings, n>2), of arbitrary length, could be more than 20k n-grams.
The algorithm should output the following:
- a dictionary of all ngrams tha... |
Optimal algorihtm for finding all ngrams from a pre-defined set in a text |
|time-complexity|strings|natural-language-processing| |
null |
You could construct a DFA that recognizes the given set of ngrams. Some of the states signify that a certain ngram has just been read, so if you keep track of all the states the DFA is in, you know all occurrences of the ngrams in the text. |
Just exhibit a TM accepting $0^n 1^n 2^n$, which isnt't context free (and thus there is no PDA accepting it). |
I'm thinking about the optimal algorithm for the following problem:
Input data:
- a **text**, say it's an article about 5-50 pages.
- a set of **ngrams** (ngram strings, n>2), of arbitrary length, could be more than 20k n-grams.
The algorithm should output the following:
- a dictionary of all ngrams tha... |
Optimal algorithm for finding all ngrams from a pre-defined set in a text |
|algorithms|time-complexity|strings|natural-language-processing| |
What you want to solve is a [string matching](https://en.wikipedia.org/wiki/String_matching) problem. Wikipedia (and any textbook on the matter) contains a rich list of algorithms with their respective runtimes.
Be aware that they give *worst-case* runtimes. Different algorithms behave differently on natural text; s... |
Following up on Yuval, I would build a tree structure so that you can find the $n$-grams. Store the number of matches of each $n$-gram in the corresponding leaf.
(It is similar to a DFA, but does not store links for 'missing' letters.)
In general my method for looking at multiple strings with overlap would be **A... |
Is it possible to use Warshall's algorithm (calculating the transitive closure) to determine if a directed graph is acyclic or not?
I'm trying to achieve this but getting stuck on the reflexive property of the transitive closure! |
Using transitive closure to determine acyclic property on directed graph |
|graphs| |
It is possible to use Warshall's algorithm for that also. If there is is a negative entry on the diagonal, then the graph contains a negative cycle. If both the shortest path from i to j and the shortest path from j to i is not infinite, then the graph contains a cycle. If there are no i and j with this property, then ... |
After running Warshall's algorithm (let's call the input graph $G$ and the resulting graph $G'$), we can reason that if there were a cycle $c_1\rightarrow c_2\rightarrow\ldots\rightarrow c_n\rightarrow c_1$ in $G$, then for every old edge of this cycle $c_i\rightarrow c_{i+1}$ there has to be a new, antisense edge $c_{... |
Let
* $A = \mathrm{R}$ be the set of all languages that are recursive,
* $B = \mathrm{RE} \setminus \mathrm{R}$ be the set of all languages that are recursively enumerable but not recursive and
* $C = \overline{\mathrm{RE}}$ be the set of all languages that are not recursively enumerable.
It is clear that f... |
null |
null |
It is possible to use Warshall's algorithm for that also. If there is is a negative entry on the diagonal, then the graph contains a negative cycle. If both the shortest path from i to j and the shortest path from j to i is not infinite, then the graph contains a cycle. If there are no i and j with this property, then ... |
A T/F question: If a DFA *M* contains a self-loop on some state *q*, then *M* must accept an infinite language.
The answer is F. I've read [this question][1], but I'm still wondering why *M* does not necessarily accept an infinite language. Isn't the language *b** infinite? Don't all self-loops look like *b**?
Th... |
DFA, finite and infinite languages |
|regular-languages|finite-automata| |
null |
the answer is False:
consider a DFA that has no accepting states at all: any loop is not relevant, the language will always be the empty set.
Another option - a loop on a *dead* state, etc.
However, if it contains a loop on an "accepting path", then indeed the language must be infinite. (this is actually the... |
I'm having difficulties understanding the solution to the following question:
> Consider the following description of a LAN:
>
> The main Internet connection is connected to our gateway router. This
> in turn is part of the backbone network on the 65.21.1.0/24 subnet.
> The backbone also supports two further ro... |
Simple routing table question |
|computer-networks| |
If the definition of Initial Algebra is:
"An object is initial if there exists a unique morphism from the object to every
object in the category"
Why do we need such object, and could any one give an example ?
|
Initial Algebra example |
|semantics|formal-methods|computer-algebra| |
I'm not sure if this statement is correct, but my friend said so.
The problem arose from this T/F question:
Let $F=\{f: f$ be a primitive recursive function from $\mathbb{N}$ to $\mathbb{N}\}$, then $2^F$ (Power set of $F$) is uncountable.
And its answer is True. The set of primitive recursive functions is count... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.