instruction
stringlengths
0
29.8k
⌀
|algorithms|image-processing|
null
|algorithms|optimization|
|terminology|data-mining|
{"OriginalQuestionIds":[9063],"Voters":[{"Id":4249,"DisplayName":"Pål GD"},{"Id":1636,"DisplayName":"Luke Mathieson"},{"Id":98,"DisplayName":"Raphael"}]}
{"OriginalQuestionIds":[9835],"Voters":[{"Id":3011,"DisplayName":"Paresh"},{"Id":6447,"DisplayName":"vonbrand"},{"Id":98,"DisplayName":"Raphael"}]}
|combinatorics|linear-algebra|
Does the difficulty of a strongly NP-hard or NP-complete problem (as e.g. defined [here](http://en.wikipedia.org/wiki/Strongly_NP-complete)) change when its input is unary instead of binary encoded? What difference does it make if the input of a strongly NP-hard problem is unary encoded? I mean, if I take for instan...
Plot the intervals for all the jobs (sorted by earliest finishing time) on the x axis. Start with y = 1. If two jobs overlap, then plot the intervals of the later job on a higher y -- i.e., above the already plotted job interval. Stop when all jobs have had their intervals plotted. Sort the levels such that the bot...
Seeing past the formulation issue pointed out in JeffE's answer, the answer is yes. Consider the [Knapsack](https://en.wikipedia.org/wiki/Knapsack_problem) problem. It does have a [pseudo-polynomial](https://en.wikipedia.org/wiki/Pseudo-polynomial_time) algorithm, that is one with runtime bounded by a polynomial in ...
I'm trying to figure out what are currently the two most efficent algorithms that permit, starting from a Left/Right pair of stereo images created using a traditional camera (so affected by some epipolar lines misalignment), to produce a pair of adjusted images plus their depth information by looking at their disparity...
|algorithms|reference-request|image-processing|
Consider the [interval scheduling problem](http://en.wikipedia.org/wiki/Interval_scheduling), see also [here](http://www.phailed.me/2012/08/interval-scheduling-problem/). In order to schedule the $n$ job requests over one resource, you sort the requests in order of finish time, choose the request with earliest fini...
|algorithms|optimization|scheduling|
|regular-languages|automata|pumping-lemma|
I was reading the proof of pumping lemma from Sipser's book. I couldn't understand certain things mentioned there. ![pumping lemma proof][1] In the second paragraph he has written, "because $r_l$ occurs among first $p+1$ places, we have $l \le p+1$". Here, does $l$ denotes the number of states visited? Also he...
|complexity-theory|graphs|np-complete|
The function is no longer one-way. we build a counter example in the following way. Assume $g$ is a one-way function that preserve size, and define $$f(bx_1x_2) = \begin{cases} g(x_1)\,x_2 & b=0 \\ x_1\, g(x_2) & b=1 \end{cases}$$ (assuming $b\in\{0,1\}$ and assuming $|x_1|=|x_2|$.) It is easy to see that $f$ is ...
{"Voters":[{"Id":157,"DisplayName":"Ran G."}]}
I went to listen to a workshop and someone from the audience asked the presenter how the moments can improve the [mutual information](https://en.wikipedia.org/wiki/Mutual_information). I am learning about MI (Mutual Information) so didn't have enough knowledge to understand what it means. Then, I did some research but ...
null
> Does the local search algorithm start from one node in state space? Check if constraints are satisfied? If Yes, this is goal? If not, move to neighbours? A local search would typically start from an arbitrary solution. For example in the case of SAT, each variable could be assigned either a 0 or a 1 with independe...
Mapreduce does not seem to have received significant academic attention and/or widespread enthusiasm nor does it seem to have yet been integrated into much of the large previously-existing literature and theory on parallelism. This is partly due to it being relatively new, but there may be other reasons. One possibl...
The function is no longer one-way. we build a counter example in the following way. Assume $g$ is a one-way function that preserves size, and define $f$ on input $w=bx_1x_2$ in the following way, $$f(bx_1x_2) = \begin{cases} g(x_1)\,x_2 & b=0 \\ x_1\, g(x_2) & b=1 \end{cases}$$ (assuming $b\in\{0,1\}$ and $|x_1|=...
Try [Latent Semantic Analysis](http://en.wikipedia.org/wiki/Latent_semantic_analysis) or the similar [Latent Semantic Indexing](http://en.wikipedia.org/wiki/Latent_semantic_indexing) which reduces documents to vectors, and typically finds principal components via [singular value decomposition, SVD](http://en.wikipedia....
I have some questions regarding local search / optimization as explained in chapter 4 of the book : http://aima.cs.berkeley.edu/ In classical search (Chap 3), the search starts from an initial node, then the search continues based on strategies of BFS, DFS, etc. What I am unsure of is the process of local search (Ch...
I have some questions regarding local search / optimization as explained in chapter 4 of the book : http://aima.cs.berkeley.edu/ In classical search (Chap 3), the search starts from an initial node, then the search continues based on strategies of BFS, DFS, etc. What I am unsure of is the process of local search (Ch...
null
This is a Data structures & Algorithms question. For instance I have the following grades of functions: $O(1), O(2^n), O(n \log n), O(e^n), O(n^3), O(n^{1/3})$ and $O(\log \log n)$ I need to show and proof to which of these function grades does the function: $n^7$ belong to. I didn't get a chance to ask my profe...
Show that a function belongs to grade of incline
|algorithms|data-structures|
|complexity-theory|asymptotics|landau-notation|
|algorithms|reference-request|parallel-computing|
|computer-architecture|coding-theory|arithmetic|
There are not enough details in the question. Yuval's answer gives the basic arithmetic answer. I'll just add that usually modems do not transfer the information "as-is" but encode it (see [Asynchronous serial communication](http://en.wikipedia.org/wiki/Asynchronous_serial_communication)). The most common encoding ...
I have a problem that I was able to conceptualize as following: ##Problem## We have a set of n people. And m subsets representing their ethnicity like White, Hispanic, Asian etc. Given any combination of these people, I want to check if it is a diverse group. A diverse group is a group that satisfies several req...
Assignment problem with no cost
|graphs|bipartite-matching|matching|assignment-problem|
Consider the [interval scheduling problem](http://en.wikipedia.org/wiki/Interval_scheduling), see also [here](http://www.phailed.me/2012/08/interval-scheduling-problem/). In order to schedule the $n$ job requests over one resource, you sort the requests in order of finish time, choose the request with earliest fini...
Let $P$ be the set of people and $\mathcal{S}$ be the modified multi-set of subsets. By checking if a $P$-saturated matching into $\mathcal{S}$ exists (i.e. Hall's condition) you are indeed checking that your groups are diverse. This can be done quickly via the Hopcraft-Karp algorithm (as you don't have weights ove...
Let $P$ be the set of people and $\mathcal{S}$ be the modified multi-set of subsets. By checking if a $P$-saturated matching into $\mathcal{S}$ exists (i.e. Hall's condition) you are indeed checking that your groups are diverse. If you are "checking" if some group is a solution, simply make $P$ this group and solve. ...
There are not enough details in the question. Yuval's answer gives the basic arithmetic answer. I'll just add that usually modems do not transfer the information "as-is" but encode it (see [Asynchronous serial communication](http://en.wikipedia.org/wiki/Asynchronous_serial_communication)). The most common encoding ...
null
Let $P$ be the set of people and $\mathcal{S}$ be the modified multi-set of subsets. By checking if a $P$-saturated matching into $\mathcal{S}$ exists (i.e. Hall's condition) you are indeed checking that your groups are diverse. If you are "checking" if some group is a solution, simply make $P$ this group and solve. If...
Consider the following problem. Given a $m \times n$ integer matrix $A$ and a $p \times q$ integer matrix $B$, do there exist one-to-one functions $$r:\{1,2,...,m\} \rightarrow \{1,2,...,p\}$$ $$c:\{1,2,...,n\} \rightarrow \{1,2,...,q\}$$ where for all $1 \leq i \leq m$ and $1 \leq j \leq n$, $A[i,j] \leq B[r(i),c(...
Prove Matrix Correspondence is NP-complete
|np-complete|
As you mentioned, we can reduce maximum clique problem to this. In fact we can reduce the more general [subgraph isomorphism problem](http://en.wikipedia.org/wiki/Subgraph_isomorphism_problem) to this one easily. Given graphs $G$ and $H$, define $A$ and $B$ as their (undirected) incidence matrices. Then we can see that...
null
Is induced subgraph isomorphism easy on an infinite subclass?
|complexity-theory|np-complete|reductions|
The term of $O(...)$ means representation of the performance of a solution. It is not entirely clear what you see under the expression n ^ 7. And because it is a representation of the complexity of the algorithm is needed to know how this power will count. There can be several calculation algorithms, each of which will...
{"OriginalQuestionIds":[824],"Voters":[{"Id":157,"DisplayName":"Ran G."},{"Id":6447,"DisplayName":"vonbrand"},{"Id":472,"DisplayName":"Juho"},{"Id":96,"DisplayName":"Mohammad Al-Turkistany"},{"Id":667,"DisplayName":"sdcvvc"}]}
Suppose, I have an array of length 100. At alternate positions, I have 0s and 1s. What is the ***fastest method*** by which I can separate the **0s** and **1s**, so that we get all the 0s at the beginning and all the 1s at the remaining positions / vice-versa?
Fastest Algo to separate the 0s and 1s
|program-optimization|
i=0, j=size(ar)-1; while(true) increase i to position of first 1; decrease j to position of first 0; if(i>=j) break; ar[i]=0, ar[j]=1;
Suppose, I have an array of length 100. I have 0s at some positions and 1s at some other positions. What is the ***fastest method*** by which I can separate the **0s** and **1s**, so that we get all the 0s at the beginning and all the 1s at the remaining positions / vice-versa?
A general trick that works for a lot of DP problems is to look at the parameters in your recursion -- the run time is then $O(n \times max(parameter_1) \times \dots \times max(parameter_k))$ where $n$ is the number of iterations (or, the number of inputs). Consider for example a DP to solve the subset sum -- the rec...
By the nondeterministic version of the [time-hierarchy theorem](http://en.wikipedia.org/wiki/Time_hierarchy_theorem), we have $\mathsf{NP} \subsetneq \mathsf{NEXP}$, where [$\mathsf{NEXP}$](http://en.wikipedia.org/wiki/NEXPTIME) is the class of problems solvable in non-deterministic exponential-time. Thus it suffices t...
null
Here is vonbrand's solution. int C = 0, i; for (i = 0; i < 100; i++) C += A[i]; C = 100 - C; for (i = 0; i < C; i++) A[i] = 0; for (; i < 100; i++) A[i] = 1; This solution has the advantage that we only scan the array forwards. Also, there are no conditionals. The i...
null
I'm working on a type system and hit upon a problem that seems similar to lowest common ancestor. Given two types types, I need to find the smallest sequence of conversions which will result in the same target type. If I had a simple type tree I know how to get the result, but unfortunately I have a slightly more compl...
Lowest common ancestor similar algorithm for a graph
|algorithms|graphs|
null
A problem is a set of instances. We consider a problem "hard" if there are instances that require lots of resources to solve (time, space, brain cells, whatever). If a subset of the problem is hard, then the problem is hard. If a subset is easy, that doesn't mean the problem is easy (there might be hard instances elsew...
A problem is a set of instances. We consider a problem "hard" if there are instances that require lots of resources to solve (time, space, brain cells, whatever). If a subset of the problem is hard, then the problem is hard. If a subset is easy, that doesn't mean the problem is easy (there might be hard instances elsew...
I'm working on a type system and hit upon a problem that seems similar to lowest common ancestor. Given two types, I need to find the smallest sequence of conversions which will result in the same target type. If I had a simple type tree I know how to get the result, but unfortunately I have a slightly more complex gra...
this is a question from the dragon book: (I apologize for translation mistakes, I don´t have the book in english language at hand.) > Which languages are produced from this grammar? > S -> a S b S | b S a S | € (empty String) I don´t know what I´m supposed to do here. The definition in the book about langu...
which languages are produced by this grammar?
|context-free|compilers|
This is a question from the Dragon book (I apologize for translation mistakes, I don´t have the English version on hand): > What language is generated by this grammar? > $S \rightarrow a S b S |b S a S | \epsilon$ I don´t know what I´m supposed to do here. The definition in the book about languages says this (...
Finding the language generated by a context-free grammar
Hint: Construct some words that are generated by this grammar. Do you see a pattern? Can you describe some properties of all words generated by the grammar, just by looking at the rules? Once you have a (correct) guess as to the language generated by the grammar, it won't be too difficult to prove it.
Hint: What can you say about the number of $a$s and $b$s in the produced words? > It would be very helpful if someone were able to provide some tips on > solving these sorts of problems. There is no one-size-fits all recipe here. It is undecidable in general, whether two CFGs produce the same language or two CFL...
null
Hint: What can you say about the number of $a$s and $b$s in the produced words? > It would be very helpful if someone were able to provide some tips on > solving these sorts of problems. There is no one-size-fits-all recipe here. It is undecidable in general, whether two CFGs produce the same language or two CFL...
This [blogpost][1] on lattice theory has a useful reference section, which contains among others "Lattice Theory with Applications" by Vijay K. Garg. Chapter 2 "Representing Posets" describes some data structures for representing posets, and discusses how to compute join(x,y) using such a data structure. The first ...
If we regard a tree as a partial ordered set, it becomes a special case of a join-semilattice. For a join-semilattice, we want to be able to compute the (unique) least upper bound of two elements (more or less) efficiently. In the case of a tree, a data structure which would enable this would be to store for each eleme...
> Are you able to determine what the algorithm or logic is contained within the neural network? Other than feeding in all possible inputs and studying the outputs it produces. No, I don't think so, not in a meaningful way. That would be akin to studying the bits in each individual byte of a computer program in an e...
If the lowest common ancestor of two types always exists and is unique, then your structure is a join-semilattice. Computing the lowest common ancestor is possible, but the worst case runtime complexity is not as good as I would have expected intuitively. I asked a [related question][1] some time ago, but was too lazy ...
As encouraged in the comments, I'm giving a more general answer regarding constraint violation or constraint propagation in search in the context of CSP solvers. In a sense, the theory of search in CSP/SAT majorizes other approaches. My answer deals with complete search methods, although hybrids exist (combine local se...
null
|formal-languages|context-free|formal-grammars|
Grammar for describing boolean expressions with AND, OR and NOT
It is an almost copy of the grammar Wirth gives for arithmetic expressions in "Algorithms + data structures = programs" (as far as I can remember it; I might be wrong with the source, though). So I strongly believe it is correct. Write the corresponding recursive descent parser, and try it on some correct strings, a...
I'm working on a type system and hit upon a problem that seems similar to lowest common ancestor. Given two types, I need to find the smallest sequence of conversions which will result in the same target type. If I had a simple type tree I know how to get the result, but unfortunately I have a slightly more complex gra...
Suppose we're receiving numbers in a stream. After each number is received, a weighted sum of the last N numbers needs to be calculated, where the weights are always the same, but arbitrary. How efficiently can this done if we are allowed to keep a data structure to help with the computation? Can we do any better than ...
Weighed sum of last N numbers
|algorithms|data-structures|
There is a sentence with N words. The words are randomly shuffled. I have a heuristic algorithm that tries to restore the original order. I want to evaluate my algorithm on a dataset of several hundred long sentences from the internet. The main goal of the algorithm is that humans looking at the restored s...
Evaluation metric for an ordering algorithm
|algorithm-analysis|sorting|natural-language-processing|
|algorithms|data-structures|online-algorithms|
|natural-language-processing|string-metrics|
null
This is a question from the Dragon book (I apologize for translation mistakes, I don´t have the English version on hand): > What language is generated by this grammar? > $S \rightarrow a S b S \mid b S a S \mid \epsilon$ I don't know what I'm supposed to do here. The definition in the book about languages say...
Suppose we're receiving numbers in a stream. After each number is received, a weighted sum of the last N numbers needs to be calculated, where the weights are always the same, but arbitrary. How efficiently can this done if we are allowed to keep a data structure to help with the computation? Can we do any better than ...