instruction
stringlengths
0
29.8k
⌀
Your algorithm, while recursive, is not really D&C. An algorithm is usually referred to as D&C if it solves the problem by dividing the instance into smaller instances of the same problem, and solving each smaller part using the same algorithm. The division does not have to be into two parts (and in particular not ...
I went to listen to a workshop and some audience asked the presenter how the moments can improve the [mutual information](https://en.wikipedia.org/wiki/Mutual_information). I am learning the MI (Mutual Information) so didn't have enough knowledge to understand what it means. Then, I have done some research but still ha...
Mutual information and moment generating functions
|complexity-theory|terminology|np-hard|
null
|algorithms|terminology|divide-and-conquer|
"Divide & Conquer" is not a very fixed notion. It usually goes along the lines of > D&C algorithms divide the problem and solve recursively. That's not very strong, for the following reasons. * What I would call *inductive* algorithms do this, but are usually not considered divide & conquer algorithms. Given ...
I've found in many exercises where I'm asked to show that $f(n)=\Theta(g(n))$ where the two functions are of the same order of magnitude I have difficulty finding a constant $c$ and a value $n_0$ for the lower bound. I'm using Corman's definition of $\Theta$: $$\exists c_1,c_2>0\in\mathbb{R}:\forall n\geq n_0: 0 \...
Depending what $f$ and $g$ are precisely, you can use l'Hôpital's rule. The description from [Wolfram Mathworld](http://mathworld.wolfram.com/LHospitalsRule.html) is quite good (the Wikipedia leaves out some cases leaving the definitions not quite correct). In short (for the purposes of algorithmic analysis), if $\l...
I have a kind of cutting problem. There is an irregular polygon that doesn't have any holes and a list of standard sized of rectangular tiles and their values. I want an efficient algorithm to find the single best valued tile that fit in this polygon; or an algorithm that just says if a single tile can fit inside th...
An algorithm for fitting a rectangle inside a polygon
|algorithms|computational-geometry|
Suppose $\sigma$ is a vocabulary of First Order logic consisting of one binary relation $E$ and let $\phi$ be a $\sigma$ sentence (FO formula with no free variables). Is it decidable whether there is a finite directed graph $G$, with all in- and out-degrees $0$ or $1$, such that $G\models \phi$ ?
{"Voters":[{"Id":6716,"DisplayName":"frafl"},{"Id":6447,"DisplayName":"vonbrand"},{"Id":4249,"DisplayName":"Pål GD"},{"Id":19,"DisplayName":"Nicholas Mancuso"},{"Id":3011,"DisplayName":"Paresh"}]}
null
When proving that a language isn't regular/context free it is quite useful to be able to limit the area containing the pumped string. The classical example is proving $\{a^n b^n \colon a \ge 0\}$ non-regular: If you take $\sigma = a^p b^p$, where $p$ is the lemma's constant, then without condition (2) you have to consi...
null
"Divide & Conquer" is not a very fixed notion. It usually goes along the lines of > D&C algorithms divide the problem and solve recursively. That's not very strong, for the following reasons. * What I would call *inductive* algorithms do this, but are usually not considered divide & conquer algorithms. Given ...
|asymptotics|landau-notation|lower-bounds|
If you want rigorous proof, the following lemma is often useful resp. more handy than the definitions. > If $c = \lim_{n\to\infty} \frac{f(n)}{g(n)}$ exists, then > * $c=0 \qquad \quad\ \,\implies f \in o(g)$ > * $c \in (0,\infty) \quad \implies f \in \Theta(g)$ > * $c=\infty \qquad \ \ \ \implies f \in \omega(...
Using de l'Hôpital's rule on discrete functions is meaningless; you would have to use continuous extension. For factorials, that would be the [Gamma function](https://en.wikipedia.org/wiki/Gamma_function). For discrete functions, there is [Stolz–Cesàro](http://math.stackexchange.com/q/92945/3330). In either case, co...
null
I'd like to start by stating this isn't homework! I'm studying for a job interview and would appreciate a second opinion. (Well, I guess it is homework, but not for school!). I've written an algorithm (see pseudocode below) to merge two *sorted* lists into one sorted list. The problem requires that I implement it as...
|graphs|logic|undecidability|first-order-logic|finite-model-theory|
For a language $L$ with pumping length $p$, and a string $s\in L$, the pumping lemmas are as follows: **Regular version**: If $|s| \geq p$, then $s$ can be written as $xyz$, satisfying the following conditions: 1. $|y|\geq 1$ 2. $|xy|\leq p$ 3. $ \forall i\geq 0: xy^iz\in L$ **Context-free version**: If $|...
null
The moment generating function $M_X$ is a property of a random variable $X$. It's defined by the expected value of $e^{tX}$ (where $t$ is the argument). Since the exponential function $e^x = \sum_0^\infty \frac{x^n}{n!}$ contains all natural powers of its argument as a summand, the expected value of a sum is the sum...
{"Voters":[{"Id":157,"DisplayName":"Ran G."}]}
null
Let $P=(p_1,\dots,p_n)$ be the polygon and $\overline{P}$ the set of points it contains. Let $R=(a,b,c,d)$ be the rectangle of width $w$ and length $l$ with $l\ge w$ (and we assume $d(a,b)=w$) and $\overline{R}$ the set of points it contains. You want $\overline{R}\subset \overline{P}$. --- Suppose $\overli...
null
Depending what $f$ and $g$ are precisely, you can use l'Hôpital's rule. The description from [Wolfram Mathworld](http://mathworld.wolfram.com/LHospitalsRule.html) is quite good (the Wikipedia leaves out some cases leaving the definitions not quite correct). In short (for the purposes of algorithmic analysis), if $\l...
Check out this link: http://projecteuclid.org/DPubS/Repository/1.0/Disseminate?view=body&id=pdf_1&handle=euclid.pja/1195520719 This is a simpler version of a proof by Chomsky that NSE grammars represent regular languages. Fortunately, the proof technique illustrates how to construct a left-regular grammar from a giv...
I found the P vs NP problem some time ago and I have recently worked on the subset sum problem. I have read [Wikipedia article][1] on the Subset Sum problem as well as the question [Subset Sum Algorithm][2] I have looked at the problem and found some solutions but so far they seem to be NP, I believe I can make...
Subset sum, pseudo-polynomial time dynamic programming solution?
null
It seems that (in a broad sense) two approaches can be utilized to produce an algorithm for solving various optimization problems: 1. Start with a feasible solution and expand search until constraints are tight and solution is maximal (or minimal). 2. Begin with violated constraints and search for maximal (or ...
Constraint violation and efficiency in search
|algorithms|optimization|
null
Another example is interior-point algorithms for convex optimizations, which (if I remember correctly) start at an arbitrary point and try to simultaneously get into the feasible region and optimize the objective function. They are provable and (to some extent) practically faster than the simplex algorithm (and related...
When dealing with Landau notation, $\Theta, O,\Omega,o,\omega$, why do some texts choose the Corman style definitions, i.e.: $$o(g(n))=\{ f(n): \forall c>0:\exists n_0>0:\; 0\leq f(n) < cg(n): \; \forall n\geq n_0 \}$$ and some texts use limit based definitions such as: $$\lim_{n\to\inf}\frac{f(n)}{g(n)}=0\Rig...
Landau Notation, Definitions: Limits vs. Corman's
|complexity-theory|landau-notation|
Check out [this link](http://projecteuclid.org/DPubS/Repository/1.0/Disseminate?view=body&id=pdf_1&handle=euclid.pja/1195520719). This is a simpler version of a proof by Chomsky that NSE grammars represent regular languages. Fortunately, the proof technique illustrates how to construct a left-regular grammar from a gi...
Skiena provides a sorted list of the dominance relations between the most common functions in his book, The Algorithm Design Manual: $$n!\gg c^n \gg n^3 \gg n^2 \gg n^{1+\epsilon} \gg n \lg n \gg n \gg n^{1/2}$$ $$ \gg \lg^2n \gg \lg n \gg \frac{\lg n}{\lg\lg n} \gg \lg\lg n \gg \alpha(n) \gg 1$$
|terminology|asymptotics|landau-notation|
null
The second definition is often handy [when comparing functions w.r.t asymptotic growth](http://cs.stackexchange.com/questions/824/sorting-functions-by-asymptotic-growth) since evaluating one limit is (usually) easier than showing something for all $c$.
When dealing with Landau notation, $\Theta, O,\Omega,o,\omega$, why do some texts choose the Corman style definitions, i.e.: $$o(g(n))=\{ f(n): \forall c>0:\exists n_0>0:\; 0\leq f(n) < cg(n): \; \forall n\geq n_0 \}$$ and some texts use limit based definitions such as: $$\lim_{n\to\infty}\frac{f(n)}{g(n)}=0\R...
|terminology|np-complete|reductions|
I can think of four major hurdles which are not entirely independent: * NP-hardness only gives you information about complexity *in the limit*. For many NP-complete problems, algorithms exist that solve all instances of interest (in a certain scenario) reasonably fast. In other words, for any *fixed* problem size (...
null
Perhaps the simplest example would be to consider DFS as a search algorithm on graphs, but to use iterative lengthening as follows: the cost of each edge is 1, and the cost of a path is the sum over the edges. So we essentially use DFS while limiting the search depth. If you start from the limit 1 and increase, then...
null
I don't understand how the star1 variation mentioned in the paper is [Sparse Sampling for Adversarial][1] different than the usual star1 algorithm? > (Taken from the bottom of page 7). This variant can be easily > described in terms of the descriptions of Star1. To enable sampling, > one need only change the imple...
How does this star1 variation work? (star1 is a stochastic (dice) algorithm for artificial intelligence in adversarial games)
|artificial-intelligence|board-games|
A binary indexed tree has very less or relatively no literature as compared to other data structures. The only place where it is taught is[the topcoder tutorial][1]. Although the tutorial is complete in all the explanations, I cannot understand that what is the intuition behind such a tree? How was it thought of? What ...
BIT:What is the intuition behind a binary indexed tree and how was it thought about?
|algorithms|binary-trees|trees|
Are there any "natural" examples of decidable problems that are definitively known not to be in $NP$? The decidable languages I know of that are not contained in $NP$ are usually derived from the time hierarchy theorem, which produces "artificial" languages based on diagonalization. Thanks!
A "natural" decidable problem not in $NP$?
|np|
Are there any "natural" examples of decidable problems that are definitively known not to be in **NP**? The decidable languages I know of that are not contained in **NP** are usually derived from the time hierarchy theorem, which produces "artificial" languages based on diagonalization.
A "natural" decidable problem not in $\mathsf{NP}$?
From an answer to a [related question on **NP**-hard problems which are not contained in **NP**](http://cs.stackexchange.com/a/9064/2152): probably the most natural example is determining whether two regular expressions (including the Kleene star, for arbitrary repetition) are equivalent. The resulting problem is **EXP...
|algorithms|optimization|lower-bounds|
Intuitively, you can think of a binary indexed tree as a compressed representation of a binary tree that is itself an optimization of a standard array representation. This answer goes into one possible derivation. Let's suppose, for example, that you want to store cumulative frequencies for a total of 7 different e...
null
To expand on Raphael's answer, both definitions are equivalent. The second definition is Landau-style (i.e. number theory style), while the first definition is computer science style. The Landau-style definition is clearly more succinct and I personally prefer it. There are two reasons to state the definition in th...
Given two vectors of integers of possibly unequal lengths, how can I determine the maximum result possible from accumulating choosing the maximum between corresponding pairs of numbers between the two vectors with extra zeros inserted into the shorter vector to make up for the size difference? For example, consider ...
What algorithm would compute the maximum choices from two sets?
|algorithms|time-complexity|
Hint: Use dynamic programming. For each $z,l$, compute the optimal way to insert $z$ zeroes to the prefix of length $l$ of the smaller array.
|algorithms|
null
null
null
The problem: Only pattern-like images are supposed to be uploaded and be used as backgrounds to a site, photos should not. How would you detect if an image looks enough like itself to be regarded as a pattern?
Image pattern detection - Finding similarities in same image
|image-processing|
a variation of [Posts Correspondence Problem](http://en.wikipedia.org/wiki/Post_correspondence_problem) for bounded length input (but _not_ the standard "bounded" version eg in Garey/Johnson that is called "bounded PCP" that limits the number of blocks in the solution to the cardinality of the block set) is complete fo...
a variation of [Posts Correspondence Problem](http://en.wikipedia.org/wiki/Post_correspondence_problem) for bounded length input (but _not_ the standard "bounded" version eg in Garey/Johnson that is called "bounded PCP" that limits the number of blocks in the solution to the cardinality of the block set) is complete fo...
A binary indexed tree has very less or relatively no literature as compared to other data structures. The only place where it is taught is [the topcoder tutorial][1]. Although the tutorial is complete in all the explanations, I cannot understand that what is the intuition behind such a tree? How was it thought of? What...
BIT: What is the intuition behind a binary indexed tree and how was it thought about?
I'm no expert in image processing, but generally, repeating patterns can be identified relatively easily in the frequency domain. This is true for signal as well as image processing. From what I understand of your question, you want to check that each image is composed almost completely of some repeating pattern, a...
Construct two functions $ f;g: R^+ → R^+ $ satisfying, 1. f; g are continuous; 2. f; g are monotonically increasing; 3. f != O(g) and g != O(f).
Construct two functions f & g satisfying f != O(g), g != O(f)
|algorithms|complexity-theory|functional-programming|
Construct two functions $ f,g: R^+ → R^+ $ satisfying: 1. $f, g$ are continuous; 2. $f, g$ are monotonically increasing; 3. $f \ne O(g)$ and $g \ne O(f)$.
Construct two functions $f$ and $g$ satisfying $f \ne O(g), g \ne O(f)$
|asymptotics|landau-notation|
null
There are many examples for such functions. Perhaps the easiest way to understand how to get such an example, is by manually constructing it. Let's start with function over the natural numbers, as they can be continuously completed to the reals. A good way to ensure that $f\neq O(g)$ and $g\neq O(f)$ is to *alter...
There are many examples for such functions. Perhaps the easiest way to understand how to get such an example, is by manually constructing it. Let's start with function over the natural numbers, as they can be continuously completed to the reals. A good way to ensure that $f\neq O(g)$ and $g\neq O(f)$ is to *alter...
null
I'm no expert in image processing, but generally, repeating patterns can be identified relatively easily in the frequency domain. This is true for signal as well as image processing. From what I understand of your question, you want to check that each image is composed almost completely of some repeating pattern, a...
I was wondered whether there is one kind CPU which doesn't contain ALU ?
Is any CPU doesn't contain ALU?