instruction
stringlengths
0
29.8k
⌀
I have a problem with the application of the [Shannon expansion](http://en.wikipedia.org/wiki/Shannon_expansion) for to obtain the negation of a formula boolean, than will need for implement the negation operator on OBDD ([Order Binary Decision Diagram](http://en.wikipedia.org/wiki/Binary_decision_diagram) that is, dem...
Maybe it is better to understand if you make a truth table for both functions. You can see that if $(\neg f|_{x_1=0} \wedge \neg f|_{x_1=1})$ is true then $(\neg x_1 \wedge \neg f|_{x_1=0}) \vee (x_1 \wedge \neg f|_{x_1=1})$ is also true, because both $f$ terms are true and either $x_1$ is true or $\neg x_1$ is true. ...
I thought (so it can be wrong :-) of this $O(N^2)$ solution that uses the [Fisher-Yates shuffle][1]. In order to keep uniform distribution with *good approximation* (see EDIT section below) at every iteration you can use this trick to produce a value <code>krand</code> between $0$ and $k-1$: // return a random...
This question involves a problem from [an InterviewStreet CompanySprint](https://genesys.interviewstreet.com). I already competed but I'd like some thoughts on a problem (solutions aren't released, and I've been banging my head against the wall over this problem). I hope it's okay to ask here. The problem is: Giv...
Balanced weighting of edges in cactus graph
|algorithms|graphs|greedy-algorithms|
You can always use [linear programming](http://en.wikipedia.org/wiki/Linear_programming): just create a variable for each edge and a constraint for each vertex. However there must be a better solution as this does not use the fact that we have a cactus graph. I will try to think about this problem, but one thing you ca...
$L_1 \cdot L_2$ is NP-hard. **Proof:** Let $L$ be a language in NP, let $f$ be a reduction of $L$ to $L_1$ and let $w_2$ be in $L_2$. Define $g(x) = (f(x), w_2)$. Now $g$ is a polynomial time many-to-one reduction of $L$ to $L_1 \cdot L_2$ because clearly: $x \in L \quad \Longleftrightarrow\quad (f(x), w_2) \in L...
Consider a graph $G$, we want to know if there are two different paths from $A$ to $B$ of the same length. What to do? Simple: code two paths in one. Define graph $G'$ with vertices $V \times V \times \{0,1\}$. You make a step in $G'$ by making two independent steps in $G$. The additional bit tells you whether the two ...
You can always use [linear programming](http://en.wikipedia.org/wiki/Linear_programming): just create a variable for each edge and a constraint for each vertex. However there must be a better solution as this does not use the fact that we have a cactus graph. I also suggest to run LP algorithms on a few examples and tr...
As sxu points out, this problem is amenable to linear programming. If you need just the objective value, the dual LP has the same objective value and is the fractional vertex cover problem. The nice thing about vertex cover is that it has a half-integral optimum; in linear time, you can use depth-first search to comput...
I have a problem with the application of the [Shannon expansion](http://en.wikipedia.org/wiki/Shannon_expansion) for to obtain the negation of a formula boolean, than will need for implement the negation operator on OBDD ([Order Binary Decision Diagram](http://en.wikipedia.org/wiki/Binary_decision_diagram) that is, sho...
|logic|information-theory|
I've been studyin' the [Spearman's rank correlation coefficient][1]. If computed for two list that have both size *n*, what's the **complexity** of the algorithm? Since the algorithm should just compute *n* subtractions, is it possible to be **O(n)** ? Many thanks! [1]: http://en.wikipedia.org/wiki/Spearman...
What's the complexity of Spearman's rank correlation coefficient computation?
|complexity-theory|time-complexity|sorting|space-complexity|
Suppose that we have a random generator that outputs numbers in the range $[1..R]$ with uniform distribution and we need to generate random numbers in the range $[1..N]$ with uniform distribution. Suppose that $N < R$ and $N$ does not evenly divide $R$; in order to get a **truly uniform distribution** we can use...
Is rejection sampling the only way to get a truly uniform distribution of random numbers?
|randomness|
Suppose that we have a random generator that outputs numbers in the range $[0..R-1]$ with uniform distribution and we need to generate random numbers in the range $[0..N-1]$ with uniform distribution. Suppose that $N < R$ and $N$ does not evenly divide $R$; in order to get a **truly uniform distribution** we can...
However shouldn't the trace $s_1^w$ be more instructive for your reasons? in this trace $\mathrm{G}\,\mathrm{F}\,p$ holds always however $\mathrm{G}\,\mathrm{F}\,q$ doesn't, therefore $\mathrm{G}\,\mathrm{F}\,p \to\mathrm{G}\,\mathrm{F}\,p$ becomes false.
Suppose that we have a random generator that outputs numbers in the range $[0..R-1]$ with uniform distribution and we need to generate random numbers in the range $[0..N-1]$ with uniform distribution. Suppose that $N < R$ and $N$ does not evenly divide $R$; in order to get a **truly uniform distribution** we can...
Extending upon [Klaus' answer](http://cs.stackexchange.com/a/2552/98), here are counter-examples: 1. $s_1^\omega = (p,\lnot q)^\omega$ is a trace -- so $\mathrm{G}\, \mathrm{F}\, q$ is not valid. 2. $s_1s_2^\omega = (p,\lnot q)(\lnot p,\lnot q)^\omega$ is a trace -- so $\mathrm{G}\, \mathrm{F}\, p$ is not valid. ...
Suppose we are given an array of positive integers $P = [p_1, p_2, \dots, p_N]$ where each $p_i$ represents the price of a product on a different day $i = 1 \dots N$. I would like to design an algorithm to find the maximum profit that you can given this array of prices. Profit is made by buying at a given date $i$ ...
|algorithms|arrays|
The first observation is that the strategy of buying at the lowest price or selling at the highest price does not always maximize the profit. As you also note, the simple brute-force method works by trying every possible pair of buy and sell dates in which the buy date precedes the sell date. A period of $n$ days has $...
|complexity-theory|homework|np-hard|
null
Given a sequence of natural numbers, you can add any natural number to any number in the sequence such that their xor becomes zero. My goal is to minimize the sum of added numbers. Consider the following examples : 1. For $1, 3$ the answer is $2$; adding $2$ to $1$ we get $3 \oplus 3=0$. 2. For $10, 4, 5, 1...
I don't actually have a solution, but here are a few ideas that came up. If you look at the results of XORing all of the numbers in the sequence, that gives an upper bound on the number of additions you need to do. For example, in your example of $10, 4, 5, 1$, we have $10 \oplus 4 \oplus 5 \oplus 1 = 10$, so you kn...
It seems to me that $a = a_i \oplus \dots \oplus a_n$ holds all necessary information: the $1$bits in $a$ are the bits you need to flip in (exactly) one of the $a_i$. As you are only allowed to *add*, you have to find one $a_i$ where the corresponding bit $j$ is $0$ and flip it -- this causes the same cost for all $a_i...
If $L_1$ is NP-hard, $L_1 \times L_2$ is NP-hard for every $L_2 \neq \emptyset$, where $\qquad \displaystyle L_1 \times L_2 = \{(w_1,w_2) \mid w_1 \in L_1, w_2 \in L_2\}$ Is it true or false and why? I can't prove it but I also don't find counter example.
Is NP-hard closed against cartesian product with arbitrary languages?
$L_1 \times L_2$ is NP-hard. **Proof:** Let $L$ be a language in NP, let $f$ be a reduction of $L$ to $L_1$ and let $w_2$ be in $L_2$. Define $g(x) = (f(x), w_2)$. Now $g$ is a polynomial time many-to-one reduction of $L$ to $L_1 \times L_2$ because clearly: $x \in L \quad \Longleftrightarrow\quad (f(x), w_2) \in...
|algorithms|integers|xor|
I've been studying the [Spearman's rank correlation coefficient][1]. If computed for two list that have both size $n$, what's the *complexity* of the algorithm? Since the algorithm should just compute $n$ subtractions, is it possible to be $O(n)$ ? [1]: http://en.wikipedia.org/wiki/Spearman%27s_rank_correlatio...
|complexity-theory|time-complexity|space-complexity|
You have to compute * two averages, * $2n$ differences, * three sums with $n$ summands -- which can be computed in constant time -- each and * one division, one multiplication and one square root. All of this can be done in linear time if we assume elementary arithmetic operations run in constant time, the...
I've been studying the [Spearman's rank correlation coefficient][1] $\qquad \displaystyle \rho = \frac{\sum_i(x_i-\bar{x})(y_i-\bar{y})}{\sqrt{\sum_i (x_i-\bar{x})^2 \sum_i(y_i-\bar{y})^2}}$. for two lists $x_1, \dots, x_n$ and $y_1, \dots, y_n$. What's the *complexity* of the algorithm? Since the algorithm sh...
|probability-theory|randomness|random-number-generator|
Suppose that we have a random generator that outputs numbers in the range $[0..R-1]$ with uniform distribution and we need to generate random numbers in the range $[0..N-1]$ with uniform distribution. Suppose that $N < R$ and $N$ does not evenly divide $R$; in order to get a **truly uniform distribution** we can...
You have to compute * two averages, * $2n$ differences, * three sums with $n$ summands -- which can be computed in constant time -- each and * one division, one multiplication and one square root. All of this can be done in linear time if we assume elementary arithmetic operations run in constant time, the...
I have a problem with the application of the [Shannon expansion](http://en.wikipedia.org/wiki/Shannon_expansion) for to obtain the negation of a formula boolean, than will need for implement the negation operator on OBDD ([Order Binary Decision Diagram](http://en.wikipedia.org/wiki/Binary_decision_diagram)) that is, sh...
I have read that the degree of nodes in a "knowledge" graph of people roughly follows a power law distribution, and more exactly can be approximated with a Pareto-Lognormal distribution. Where can I find a kind of algorithm that will produce a random graph with this distribution?
How to random-generate a graph with Pareto-Lognormal degree nodes?
|algorithms|graphs|
|complexity-theory|np-hard|
I couldn't understand your approach exactly (Seems it's correct), but there is a simple rule for impossible orders: The order is impossible $iff$ there is $a_i,a_j,a_k$ such that $a_i > a_k > a_j$ and $i<j<k$. To such a $a_i,a_j,a_k$ we say bad triple. Why? First you should prove that if there is bad triple then the...
The lookup time for the worst-case is O(1), then does it simply mean that if that is the case then the average should be <= O(1)?
what is the average search complexity of perfect hashing?
|hash-tables|
Yes, but in complexity theory, $≤O(1)$ only means $O(1)$ i.e. [constant time][1]. [1]: http://en.wikipedia.org/wiki/Time_complexity#Constant_time
Sometimes it is necessary to dig into Artificial Intelligence or specifically Machine Learning problems to make a research. Common googling (in my own experience) usually doesn't help much due to a lot of non relevant or paid materials in SERP. Google Scholar at the contrast is limited to scientific publications only, ...
Is there a seach engine over Artificial Intelligence and Machine Learning -related sites?
|machine-learning|artificial-intelligence|
Say instead of using a linked list as buckets for a hash table of size m, we use another hash table of size p as buckets this time. What would be the average case for this problem? I looked up perfect hashing and i got a very close algorithm, and it is O(1). Can someone please clarify! Thanks
Hash Table Questions
|hash-tables|
In *Algorithmic Randomness and Complexity* from Downey and Hirschfeldt, it is stated page 127 that $\sum_{K(\sigma)\downarrow} 2^{-K(\sigma)} \leq 1$, where $K(\sigma)\downarrow$ means that $K$ halts on $\sigma$, $\sigma$ being a binary string. $K$ denotes the prefix-free Kolmogorov complexity. When does $K$ halts ...
When does the function mapping a string to its prefix-free Kolmogorov complexity halts?
|computability|kolmogorov-complexity|
If a graph $G$ is connected and has no path with a length greater than $k$, prove that every two paths in $G$ of length $k$ have at least one vertex in common. I think that that common vertex should be in the middle.Because if this is not the case then we can have a path of length $>k$. Am I right?
Prove that every two paths in $G$ of length $k$ have at least one vertex in common
|graphs|
So this question has been bothering me: why a cactus, if there's already a linear-time algorithm for a more general class? The primal problem is known as the fractional matching problem, and, unsurprisingly, it has been studied as well. Balinski (whose result was made known to me via Schrijver's book Combinatorial O...
So this question has been bothering me: why a cactus, if there's already a linear-time algorithm for a more general class? The primal problem is known as the fractional matching problem, and, unsurprisingly, it has been studied as well. Balinski (whose result was made known to me via Schrijver's book Combinatorial O...
Is there a search engine over Artificial Intelligence and Machine Learning -related sites?
Using a hash table with $n$ buckets and a hash function $h_n : S \rightarrow \{0, 1, ..., n - 1\}$ , where each bucket is a hash table with $m$ buckets and a hash function $h_m : S \rightarrow \{0, 1, ..., m - 1\}$, is equivalent to a hash table wit $nm$ buckets and a hash function $h_{nm} : S \rightarrow \{0, 1, 2, .....
In *Algorithmic Randomness and Complexity* from Downey and Hirschfeldt, it is stated page 129 that $\sum_{K(\sigma)\downarrow} 2^{-K(\sigma)} \leq 1$, where $K(\sigma)\downarrow$ means that $K$ halts on $\sigma$, $\sigma$ being a binary string. $K$ denotes the prefix-free Kolmogorov complexity. When does $K$ halts ...
If a graph $G$ is connected and has no path with a length greater than $k$, prove that every two paths in $G$ of length $k$ have at least one vertex in common. I think that that common vertex should be in the middle of both the paths.Because if this is not the case then we can have a path of length $>k$. Am I rig...
Given a [cactus](https://en.wikipedia.org/wiki/Cactus_graph), we want to weight its edges in such a way that 1. For each vertex, the sum of the weights of edges incident to the vertex is no more than 1. 2. The sum of all edge weights is maximized. Clearly the answer is no more than $\frac{n}{2}$ for $n$ vertices...
|algorithms|graphs|randomness|
null
You are right that the common vertex must occur in the middle of both paths. However that intuition will not solve the actual problem you're trying to solve. Instead try to demonstrate that, given any point in the path, the path segment from (and including) that point to one of the ends of the original path must ...
Yes and no, depending on what you mean by “the only way”. Yes, in that there is no method that is guaranteed to terminate, the best you can do (for generic values of $N$ and $R$) is an algorithm that terminates with probability 1. No, in that you can make the “waste” as small as you like. ### Why guaranteed terminat...
null
Semi clustering algorithm is mentioned in the [Google Pregel paper][1]. The score of a semi cluster is calculated using the below formula ![enter image description here][2] where Ic is sum of the weights of all the internal edges Bc is the sum of the weights of all the boundary edges Vc is the number of edge...
What is the significance of the semi clustering formula in the Google Pregel paper?
|algorithms|graphs|
Assume for contradiction that $P_{1} = <v_{0},\ldots,v_{k}>$ and $P_{2} = <u_{0},\ldots,u_{k}>$ are two paths in $G$ of length $k$ with no shared vertices. As $G$ is connected, there is a path $P'$ connecting $v_{i}$ to $v_{j}$ for some $i,j \in [1,k]$ such that $P'$ shares no vertices with $P_{1} \cup P_{2}$ other ...
null
The language is defined by $$(a+b)^*-\{(a^nb^n)^n\mid n \geq1 \}$$ is Context-Free Language? I believe that the answer is that it is not a CFL's, but I can't prove it by Ogden lemma or pumping lemma.
Is this language Context-Free?
|context-free|pumping-lemma|pushdown-automata|
The lookup time in perfect hash-tables is $O(1)$ in the worst case. Does that simply mean that the average should be $\leq O(1)$?
What is the average search complexity of perfect hashing?
|time-complexity|asymptotics|hash-tables|
Given any set $X \subseteq \mathbb{R}$, you have $\qquad \displaystyle \min X\ \leq\ \frac{1}{|X|}\sum_{x \in X} x\ \leq\ \max X$. Therefore, average runtime is always bounded above by worst-case runtime. Denoting an asymptotic upper bound by "$\leq O(f)$" is abuse of notation, but will be understood. To be mo...
Sometimes it is necessary to dig into Artificial Intelligence or specifically Machine Learning problems to make a research. Common googling (in my own experience) usually doesn't help much due to a lot of irrelevant or paid material among the results. Google Scholar in contrast is limited to scientific publications onl...
|reference-request|machine-learning|artificial-intelligence|
Say instead of using a linked list as buckets for a hash table of size $m$, we use another hash table of size $p$ as buckets this time. What would be the average case for this problem? I looked up perfect hashing and I got a very close algorithm, and it is $O(1)$. Can someone please clarify?
Using hash tables instead of lists for buckets in hash tables
|data-structures|time-complexity|hash-tables|
In *Algorithmic Randomness and Complexity* from Downey and Hirschfeldt, it is stated on page 129 that $\qquad \displaystyle \sum_{K(\sigma)\downarrow} 2^{-K(\sigma)} \leq 1$, where $K(\sigma)\downarrow$ means that $K$ halts on $\sigma$, $\sigma$ being a binary string. $K$ denotes the prefix-free Kolmogorov comp...
|computability|terminology|kolmogorov-complexity|descriptive-complexity|
I think you are right; $K$ is a specific function which can not be computed. The author likely means to use *some* (arbitrary) approximative implementation; so no, this does not seem to be well-defined, if you are pedantic. You can also call it abuse of notation. Consider this instead: $\qquad \displaystyle \fora...
When does the function mapping a string to its prefix-free Kolmogorov complexity halt?
I have read that the degree of nodes in a "knowledge" graph of people roughly follows a power law distribution, and more exactly can be approximated with a Pareto-Lognormal distribution. Where can I find a kind of algorithm that will produce a random graph with this distribution? See for example the paper [Revisi...
|algorithms|graphs|probability-theory|randomness|
Semi clustering algorithm is mentioned in the [Google Pregel paper][1]. The score of a semi cluster is calculated using the below formula $\qquad \displaystyle S_c =\frac{I_c - f_BB_c}{\frac{1}{2}V_c(V_c - 1)}$ where * $I_c$ is sum of the weights of all the internal edges, * $B_c$ is the sum of the weights of...