instruction stringlengths 0 29.8k ⌀ |
|---|
Is NAE-HORN-SAT in P or NP-hard? |
Given a tube with numbered balls (random). The tube has holes to remove a ball. Consider the following steps for one operation:
1. You can pick one or more balls from the holes and remember the order in which you picked the balls.
1. You need to tilt the pipe towards left side so that remaining balls in the pipe ... |
Interesting problem on sorting |
You can do it in $O(l + k \text{ log } l)$ time and $O(l)$ extra space as follows:
1. Build a binary heap with one entry for each of the arrays. The key for entry $i$ is the smallest element in array $A_i$. This takes $O(l)$ time.
2. Select the smallest entry from the heap and remove it (taking $O(\text{log } l$)... |
You can do it in $O(l + k \text{ log } l)$ time and $O(l)$ extra space as follows:
1. Build a binary heap with one entry for each of the arrays. The key for entry $i$ is the smallest element in array $A_i$. This takes $O(l)$ time.
2. Select the smallest entry from the heap and remove it (taking $O(\text{log } l$)... |
My solution uses 2 arrays 2 store the zero-counts and a 1D array to represent the grid of zeros and ones as a sequence of numbers. All 3 arrays are of size $N$. Queries take constant time (you return the value in the i'th col/row). An update operation takes linear time in $N$ because you have to set the i'th col to $N$... |
Your problem is $NP$-complete. Monotone NAE-SAT is $NP$-complete and it is a special case of your NAE-HORN-SAT. Literals in monotone SAT formula are either all positive or all negative. |
My solution uses 2 arrays (R and C) to store the zero-counts and a 1D array (Grid) to represent the grid of zeros and ones as a sequence of numbers. All 3 arrays are of size $N$. Queries take constant time (you return the value in the i'th col/row). An update operation takes linear time in $N$ because you have to set t... |
Your problem, NAE-HORN-SAT is $NP$-complete. Monotone NAE-SAT is $NP$-complete and it is a special case of your NAE-HORN-SAT. Literals in monotone SAT formula are either all positive or all negative. |
|complexity-theory|np-complete|satisfiability| |
Your problem, NAE-HORN-SAT is $NP$-complete. Monotone NAE-SAT is $NP$-complete and it is a special case of your NAE-HORN-SAT. Literals in monotone SAT formula are either all positive or all negative.
Take any instance of Monotone NAE-SAT problem (all its literals are negative) then this formula is an instance of NAE... |
null |
First, let me write the definition of big $O$ just to make things explicit.
$f(n)\in O(g(n))\iff \exists c, n_0\gt 0$ such that $0\le f(n)\le cg(n), \forall n\ge n_0$
Let's say we have a finite number of functions: $f_1,f_2,\dots f_n$ satisftying:
$f_1\in O(f_2)\dots \in O(f_n)$ (use $f_k$ as a representative ... |
Infinite chain of big $O's$ |
|asymptotics|landau-notation| |
Since $f_i \in \mathcal O(f_{i+1})$ holds, you also have $\mathcal O(f_i) \subseteq \mathcal O(f_{i+1})$ and $f_i \in \liminf_{k\rightarrow\infty} \mathcal O(f_k) = \bigcup_{n \in \mathbb{N}}\bigcap_{k>n}\mathcal O(f_k)$ for all $i \in \mathbb{N}$ (the sequence of sets is monotonically increasing). |
There are $2^3=8$ possibilities. What you need is that either two are even, or all three are odd because two odds and an even make an even; and three evens make an even so we are left with $4$ possibilities now. Let's say that all numbers are odd. An odd number of $a's$ translates to the regular expression: $a(aa)^*$ s... |
null |
What you need is that either exactly two of $k$, $m$, $n$ even, or all three odd, because two odds and an even make an even; and three evens make an even.
An odd number of $a$'s translates to the regular expression $a (a a)^*$, an even number to $(a a)^*$.
Pulling the above together:
$$
a (a a)^* (b b)^* (c c)^... |
First, let me write the definition of big $O$ just to make things explicit.
$f(n)\in O(g(n))\iff \exists c, n_0\gt 0$ such that $0\le f(n)\le cg(n), \forall n\ge n_0$
Let's say we have a finite number of functions: $f_1,f_2,\dots f_n$ satisftying:
$O(f_1)\subseteq O(f_2)\dots \subseteq n O(f_n)$
By transiti... |
I molded my problem as the following game (it is [congestion game][1] with varying price):
$N$ players share resources $E$,
$S_i$ is the strategy space of player $i$ which is in $2^E$ (in which $2^E$ is power set of resources).
($P_e^i$ ) is the price of resource $e \in E$ considering player $i$. **The price o... |
Congesstion Game with Varying Price |
|algorithms|optimization|game-theory| |
Since $f_i \in \mathcal O(f_{i+1})$ holds, you also have $\mathcal O(f_i) \subseteq \mathcal O(f_{i+1})$ and $f_i \in \liminf_{k\rightarrow\infty} \mathcal O(f_k) = \bigcup_{n \in \mathbb{N}}\bigcap_{k>n}\mathcal O(f_k)$ for all $i \in \mathbb{N}$ (the sequence of sets is monotonically increasing).
Note: The limes o... |
Define the *run-partition number* of a permutation $\pi$, denoted $r(\pi)$, using the following process. Let $k$ be the maximal integer such that the numbers $\min(\pi),\ldots,k$ appear in increasing order in $\pi$. Remove them from $\pi$, and repeat the process. The number of rounds it takes to consume the entire perm... |
First, let me write the definition of big $O$ just to make things explicit.
$f(n)\in O(g(n))\iff \exists c, n_0\gt 0$ such that $0\le f(n)\le cg(n), \forall n\ge n_0$
Let's say we have a finite number of functions: $f_1,f_2,\dots f_n$ satisftying:
$O(f_1)\subseteq O(f_2)\dots \subseteq O(f_n)$
By transitivi... |
null |
The algorithm I'm looking at is a V/C/P (Vowel/Consonant/Pause) classification algorithm on a digital speech signal. It is described as such:
1. Audio data is segmented into 20ms-long non-overlapping frames,
where features, including ZCR, Energy and Pitch, are extracted.
2. Energy and pitch curve ... |
Help understanding an audio processing algorithm |
|algorithms| |
Since $f_i \in \mathcal O(f_{i+1})$ holds, you also have $\mathcal O(f_i) \subseteq \mathcal O(f_{i+1})$ and $f_i \in \liminf_{k\rightarrow\infty} \mathcal O(f_k) = \bigcup_{n \in \mathbb{N}}\bigcap_{k>n}\mathcal O(f_k)$ for all $i \in \mathbb{N}$ (the sequence of sets is monotonically increasing).
Note: The limes o... |
Questions on genetic algorithms, a family of evolutionary search heuristics. |
null |
Questions on graph coloring, an assignment of colors to elements of a graph subject to specific constraints. |
null |
First of all, an array *is* and has *always been* a function. It is a function from the set of indices (1..10 in your example) to *memory locations* that hold the array elements. When we write $a[i]$ in the programming language, we are just using stylized notation for saying $a(i)$, i.e., apply the function $a$ to $i... |
There is a good paper titled "[The Case for Efficient File Access Pattern Modeling][1]" by Thomas M. Kroeger and Darrell D. E. Long. It reviews two classic model for file access pattern "The first model is based on a graph, that keeps frequency counts for all files accessed within a window following an access to each file.... |
null |
this paper finds at the end that a link-cut (LC) tree outperforms rake-compress (RC) trees for the Sleator/Tarjan max-flow algorithm using a standard Dimacs random graph generator.
the paper focuses on change propagation as one application of dynamic trees. eg, change propagation is similar to the way that excel sp... |
Since $f_i \in \mathcal O(f_{i+1})$ holds, you also have $\mathcal O(f_i) \subseteq \mathcal O(f_{i+1})$ and $f_i \in \liminf_{k\rightarrow\infty} \mathcal O(f_k) = \bigcup_{n \in \mathbb{N}}\bigcap_{k>n}\mathcal O(f_k)$ for all $i \in \mathbb{N}$ (the sequence of sets is monotonically increasing).
Note: The limits ... |
Yes, it's possible to have an infinite chain.
I'm sure you're already familiar with some examples:
$$
O(x) \subseteq O(x^2) \subseteq \ldots \subseteq O(x^{42}) \subseteq \ldots
$$
You have an infinite chain here: polynomials of growing degree. Can you go further? Sure! An exponential grows faster (asymptotical... |
I'm reading [“Speech segmentation without speech recognition” by Dong Wang, Lie Lu and Hong-Jiang Zhang](http://bero.freqvibez.net/public/segs/icassp03_senseg.pdf).
The algorithm I'm looking at is a V/C/P (Vowel/Consonant/Pause) classification algorithm on a digital speech signal. It is described as such:
1. Audio... |
|algorithms|machine-learning|natural-language-processing|signal-processing| |
the reduction only shows that X is at least as hard as SAT (NP-HARD). This could mean that X is in a class suspected to be harder than NP such as PSPACE or EXPTIME. To show that X is NP-complete you must show that it is also in NP. If you try it out you will see that you can easily reduce SAT to problems in EXPTIME tha... |
I am having problems resolving the following question:
> Given some problem $X$. If there exists a polynomial time reduction from (for example) $\mbox{SAT}$ to $X$, $(\mbox{SAT} \leq_{p} X)$ and since we know that $\mbox{SAT}$ is $\mbox{NP-complete}$, to show that $X$ is $\mbox{NP-complete}$ is it necessary to show ... |
Does reduction form an NP-complete problem to some problem $X$ imply that $X\in NP$? |
|reductions|np| |
Yes, it's possible to have an infinite chain.
I'm sure you're already familiar with some examples:
$$
O(x) \subseteq O(x^2) \subseteq \ldots \subseteq O(x^{42}) \subseteq \ldots
$$
You have an infinite chain here: polynomials of growing degree. Can you go further? Sure! An exponential grows faster (asymptotical... |
There is a paper titled "[Dynamic Trees in Practice][1]" which reviews the practical implementation.
The other categories that Link-Cut tree could be used efficiently is in **Database Indexing**.
You can find this in the book "[Database Index Techniques][2]".
[1]: http://www.cs.princeton.edu/~rwerneck/docs/T... |
Here's a good explanation for the $O(n\log^2n)$ algorithm: http://www.stanford.edu/class/cs97si/suffix-array.pdf. Actually, by using linear time sorting, the same approach gives $O(n\log n)$ time complexity.
If you have any specific question about it, you're welcome to ask.
I agree with A. Schultz that DC-3 is su... |
If I have some function whose time complexity is O(*mn*), where *m* and *n* are the sizes of its two inputs, would we call its time complexity "linear" (since it's linear in both *m* and *n*) or "quadratic" (since it's a product of two sizes)? Or something else?
I feel calling it "linear" is confusing because O(m + ... |
Is O(mn) considered "linear" or "quadratic" growth? |
|time-complexity| |
null |
Here is a very general negative answer. Consider the following language:
$$ L = \{\langle M,x,o \rangle : M \text{ outputs } o \text{ on input } x\}, $$
where $o \in \Sigma^* \cup \{ \bot \}$ and $\langle \cdot,\cdot,\cdot \rangle$ is any polytime pairing function (we can even demand it to be logspace, or even weaker... |
If you are measure the running time in $(m,n)$ then $O(mn)$ is **not** linear function in $(m,n)$. If there is no relation between $m$ and $n$ this function can grow *quadraticly* in general.
However it is a linear function in each of them separately, i.e. if you fix one of them and look at the growth in the other v... |
I need to consult about a homework from computer architecture class that I'm taking for ms in computer science. Not sure if this is the place, if not point me to a better forum.
Here is what I have - a two part problem. Now I've seen posts on other sites where users were totaly demoralized by asking for help with ho... |
What is the system MTTF |
|computer-architecture| |
Since $f_i \in \mathcal O(f_{i+1})$ holds, you also have $\mathcal O(f_i) \subseteq \mathcal O(f_{i+1})$ and $f_i \in \liminf_{k\rightarrow\infty} \mathcal O(f_k) = \bigcup_{n \in \mathbb{N}}\bigcap_{k>n}\mathcal O(f_k)$ for all $i \in \mathbb{N}$ (the sequence of sets is monotonically increasing).
Note: The limits ... |
To measure the complexity of the problems with **multiple inputs**, one way is to find the **dominant** variable and then bound other inputs based on that variable. With this approach you could have the complexity function based on **single variable**. |
We first need to clarify what we mean by "does this hold if we have an infinite chain?".
We interpret it as an infinite sequence of functions $\{f_i:\mathbb{N}\to\mathbb{N} \mid 1\leq i\}$ such that for all $i$ we have $f_i(n) = O(f_{i+1}(n))$. Such a sequence might not have a last function.
We can look at the limi... |
If you are measuring the running time in $(m,n)$ then $O(mn)$ is **not** a linear function in $(m,n)$. If there is no relation between $m$ and $n$ this function can grow *quadraticly* in general.
However it is a linear function in each of them separately, i.e. if you fix one of them and look at the growth in the oth... |
This is nice homework problem about Mahaney's theorem.
Note that the complement of a "dense" language is a sparse language. Moreover if a language is $\mathsf{NP}$-complete it's complement is $\mathsf{coNP}$-complete.
If there is a "dense" $\mathsf{NP}$-complete language, there is a [sparse][1] $\mathsf{coNP}$-c... |
This is nice homework problem about Mahaney's theorem.
Note that the complement of a "dense" language is a sparse language. Moreover if a language is $\mathsf{NP}$-complete it's complement is $\mathsf{coNP}$-complete.
If there is a "dense" $\mathsf{NP}$-complete language, there is a [sparse][1] $\mathsf{coNP}$-c... |
Suppose $X,Y$ are exponential random variables with means $\lambda^{-1},\mu^{-1}$. Then
$$
\Pr[\max(X,Y) < t] = (1-e^{-\lambda t})(1-e^{-\mu t}) = 1 - e^{-\lambda t} - e^{-\mu t} + (\lambda + \mu)e^{-(\lambda+\mu)t},
$$
and from this one can compute
$$
\begin{align*}
\mathbb{E}[\max(X,Y)] &= \int_0^{\infty} t \f... |
Suppose we have a set $A$ of pairs $(a,b)$ such that $a$ and $b$ are real numbers and $a < b$. What is the most efficient algorithm to find the smallest subset $B \subseteq A$ such that for any value within the range of any pair in $A$ is also within the range of any pair in $B$.
I am currently considering setting ... |
Algorithm to find the minimum subset |
|algorithms| |
I have the following homework problem:
>A 10 TB disk drive has an MTTF of 6,000,000 hours. How much data can we store in a system comprised of these disks, if we want the system MTTF to be at least 1.2M hours?
>If we are allowed to make it redundant (i.e., two of them operating in a parallel mode), and if the MT... |
|complexity-theory|satisfiability|average-case| |
Suppose we have a set $A$ of pairs $(a,b)$ such that $a$ and $b$ are real numbers and $a < b$. What is the most efficient algorithm to find the smallest subset $B \subseteq A$ such that, for any value within the range of any pair in $A$, the value is also within the range of any pair in $B$.
I am currently consider... |
Suppose I have a decision tree in which there is a label L under which is the attribute A as shown below. I am given that the shannon entropy of label L is $H(L) = 0.95$.
![enter image description here][1]
I must find the shannon entropy of L given A ($H(L|A)$). Here's what I have tried.
$$
H(L|A) = -(\frac{6... |
Why is the shannon entropy 0.94? |
|artificial-intelligence|entropy| |
**Stage 1:** find the union of pairs in $A$.
Sort the intervals in $A$ by their starting position.
Go over them to find the first point that is not covered. Create an interval for this part. Repeat this starting from the left point of the next interval.
At the end we will have a list of non-overlapping intervals. ... |
**Stage 1:** find the union of pairs in $A$.
Sort the intervals in $A$ by their starting position.
Go over them to find the first point that is not covered. Create an interval for this part. Repeat this starting from the left point of the next interval.
At the end we will have a list of non-overlapping intervals. ... |
{"Voters":[{"Id":41,"DisplayName":"Kaveh"}]} |
**Stage 1:** find the union of pairs in $A$.
Sort the intervals in $A$ by their starting position.
Go over them to find the first point that is not covered. Create an interval for this part. Repeat this starting from the left point of the next interval.
At the end we will have a list of non-overlapping intervals. ... |
{"Voters":[{"Id":41,"DisplayName":"Kaveh"}]} |
**Input:**
A set of $\ell$ arrays $A_i$ (of numbers).
<br>
The elements within each array are in sorted order, but the set of arrays is not necessarily sorted. The arrays are not necessarily the same size. The total number of elements is $n$.
**Output:**
The $k$th smallest element out of all elements in the inp... |
**Stage 1:** Break down the problem to that of covering a single interval.
Find the union of pairs in $A$ as follows:
Sort the intervals in $A$ by their starting position.
Go over them to find the first point that is not covered. Create an interval for this part. Repeat this starting from the left point of the nex... |
Suppose I have a decision tree in which there is a label $L$ under which is the attribute $A$ as shown below. I am given that the Shannon entropy of label $L$ is $H(L) = 0.95$.
![enter image description here][1]
I must find the Shannon entropy of $L$ given $A$ ($H(L \mid A)$). Here's what I have tried.
\begin{... |
Why is the Shannon entropy -0.94 in this example? |
null |
Here is a randomized $O(\ell\log^2 n)$ algorithm. It can probably be derandomized using the same trick used to derandomize the usual quickselect.
We emulate the classical quickselect algorithm. In each phase, you pick a pivot and calculate how many elements are below it, in $O(\ell\log n)$, using binary search in ea... |
Suppose I have a decision tree in which there is a label $L$ under which is the attribute $A$ as shown below. I am given that the Shannon entropy of label $L$ is $H(L) = 0.95$.
![enter image description here][1]
I must find the Shannon entropy of $L$ given $A$ ($H(L \mid A)$). Here's what I have tried.
\begin{... |
Why is the Shannon entropy 0.94 in this example? |
Back to the definitions:
$$H(L\mid A) = \sum_a p(A=a) H(L \mid A=a).$$
As you compute, $P(A=true)=6/8$ and $P(A=false)=2/8$.
However, you don't compute $H(L\mid A=true)$ but instead compute $P(L=positive\mid A=true)$. [and the same for $A=false$.].
With standard definition of $H()$ we get,
$$H(L\mid A=... |
The classic Hindley-Milner type inference algorithm requires each literal value to be unambiguously inferable to a type: `0` is an `int`, while `0.0` is a `real`. Haskell's one, as I understand it, has been enhanced to accomodate subtyping, so that a value may be promoted to a better fit if the need arises.
See ... |
Looking at the document _Fundamentals of Computing Series_, [The Stable Marriage Problem][1].
Theorem 1.2.3 - page 12:
> In a man-optimal version of stable matching, each woman has worst
> partner that she can have in any stable matching.
Proof:
> Suppose not. Let $M_0$ be the man-optimal stable matchin... |
Here's an $O(n\log n)$ algorithm, which is optimal in the algebraic decision tree model by an easy reduction from element distinctness (map each element $x$ to the interval $(x,x+\epsilon)$). We follow Kaveh's outline. Stage 1 runs in linear time, so we focus on Stage 2.
Let $I$ be the set of intervals in $C = (a,b)... |
Build an **FA** that accepts only the language of all word with **B** as **second letter** |
Build an FA that accepts only the language of all word with b as second letter |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.