instruction
stringlengths
0
29.8k
⌀
null
I can see how adding 2 unsigned four-bit values is $O(n)$. We just go from the rightmost digits to the leftmost digits and add the digits up sequentially. We can also perform multiplication in polynomial time ($O(n^2)$) via the algorithm we all learned in grade school. However, how can we add up or multiply say $i$ ...
How can repeated addition/multiplication be done in polynomial time?
|time-complexity|
Reductions are useful in studying computability not so much to prove that problems *are* computable (although that is also done), but to prove that problems are *not* computable. Used to prove incomputability, a reduction proof is a particular kind of proof by contradiction. You take your problem P and a known incom...
From what you said, I suppose that you consider complexity in terms of number of bits of the input. Say you add up two numbers $a$ and $b$, with respectively $n_1$ and $n_2$ bits, then the result is at most $\max(n_1, n_2) + 1$ bits since $a + b \leq 2 \times \max(a, b)$. For the multiplication, the result is at...
I'm curious if anyone's come up with a problem or method as n => infinity t => 0. Are there any sort of cases found in quantum computing?
is there an example of an algorithm that has O(1/n)?
|time-complexity|
Just elaborating what @Lamine pointed out : When $k$ is part of the input, $k$ can be as large as $\frac{n}{2}$, in which case the number of potential clique sets are $\binom{n}{\frac{n}{2}}$ which is at least $\left( \frac{n}{\frac{n}{2}} \right)^{\frac{n}{2}}$. Hence your naive algorithm would take time $2^{\frac{n}{...
In this Wikipedia article about the [Clique problem in graph theory][1] it states in the beginning that the problem of finding a clique of size K, in a graph G is NP-complete: > Cliques have also been studied in computer science: finding whether there is a clique of a given size in a graph (the clique problem) is NP...
Is the k-clique problem NP-complete?
|graphs|complexity-classes|
|time-complexity|arithmetic|
From what you said, I suppose that you consider complexity in terms of number of bits of the input. Say you add up two numbers $a$ and $b$, with respectively $n_1$ and $n_2$ bits, then the result is at most $\max(n_1, n_2) + 1$ bits since $a + b \leq 2 \times \max(a, b)$. For the multiplication, the result is at...
As the complexity of an algorithm is a measure of the number of operations (in a sense to be defined in each context) needed to do some computation in function of the size of some input, sub-constant complexity does not make any sense. With your exemple, $O(\frac1n)$, it means that for a sufficiently large input, the a...
As the complexity of an algorithm is a measure of the number of operations (in a sense to be defined in each context) needed to do some computation in function of the size of some input, sub-constant complexity does not make any sense. With your exemple, $O(\frac1n)$, it means that for a sufficiently large input, the a...
Your problem is equivalent to the weighted version of [Set Cover](http://en.wikipedia.org/wiki/Set_cover_problem), which is NP-complete (and delving into other complexity classifications, W[2]-complete and inapproximable within $O(\log n)$). If you want a polynomial-time algorithm, you're going to have to impose res...
null
null
Have a look at [Boomerang][1]. It is a language for writing bijections between strings. I do not know how wide a class of maps is expressible in it, but I am sure you can find out if you search a bit. [1]: http://www.seas.upenn.edu/~harmony/
There is no such language. However, have a look at [Boomerang][1]. It is a language for writing bijections between strings. I do not know how wide a class of maps is expressible in it, but I am sure you can find out if you search a bit. It is reasonable to require of a programming language that the set of valid p...
I have a dynamic programming problem: > If I have a set of sensors covering targets (a target might be > covered by mutiple sensors) how can I find the minimum cost subset of > sensors covering all targets given each sensor has a cost? I have thought a lot about this, but I can't reach the recursive formula to...
null
I am unsure if I have even identified the problem correctly, but reading up on [knapsack problem][1] seems the closest to what I am trying to solve: > A cook has several ingredients of varying quantities. Given a > list of $n$ recipes, each consisting varying ingredients of varying > quantities, how can the cook m...
Knapsack problem with multiple constraints
null
For what size alphabet does it take longer to construct [a suffix tree][1] - for a really small alphabet size (because it has to go deep into the tree) or for a large alphabet size? Or is it dependent on the algorithm you use? If it is dependent, how does the alphabet size affect [Ukkonen's algorithm][2]? [1]: h...
null
null
A larger alphabet is usually a drawback. However there are algorithms that can deal with this as long as the alphabet size is $n^{O(1)}$. Ukkonen's algorithm runs only in $O(n)$ if the alphabet size is a constant but it is $O(n \log n)$ without this assumption. However, there are alternatives. You can compute the ...
|algorithms|data-structures|strings|
|algorithms|data-structures|algorithm-analysis|strings|efficiency|
> **Possible Duplicate:** > [Complexity inversely propotional to $n$](http://cs.stackexchange.com/questions/3495/complexity-inversely-propotional-to-n) <!-- End of automatically inserted text --> I'm curious if anyone's come up with a problem or method as n => infinity t => 0. Are there any sort of cases found in...
{"OriginalQuestionIds":[3495],"Voters":[{"Id":41,"DisplayName":"Kaveh"},{"Id":2755,"DisplayName":"Realz Slaw"},{"Id":1636,"DisplayName":"Luke Mathieson"},{"Id":2205,"DisplayName":"A.Schulz"},{"Id":98,"DisplayName":"Raphael"}]}
A larger alphabet is usually a drawback. However there are algorithms that can deal with this as long as the alphabet size is $n^{O(1)}$. Ukkonen's algorithm runs only in $O(n)$ if the alphabet size is a constant but it is $O(n \log n)$ without this assumption. However, there are alternatives. You can compute the ...
So I've passed coursera Scala course and deciced to apply my fresh knowledge. Here is my algo: 1. Xor ciphers with each other and collect xor result for each position. As a result I got a **Map[Int, List[String]]** where *Int is a position of char* in chiper and *List[String] are* all xor results for current posit...
null
You might use it to **evaluate the performance of programming languages**: http://en.wikipedia.org/wiki/Tak_%28function%29 since recursive methods are pretty useful for benchmarking. In particular, deep recursion tests the speed with which a language can make method calls. This is important because modern applica...
You might use it to **evaluate the performance of programming languages**: http://en.wikipedia.org/wiki/Tak_%28function%29 since recursive methods are pretty useful for benchmarking. In particular, deep recursion tests the speed with which a language can make method calls. This is important because modern applica...
It means "open" the recursion. For simplicity - denote `O(n)` as `n`: T(n) = 2T(n/2) + n = 2* (2T(n/4) + n/2) + n = 2 * (2 * (2T(n/8) + n/4) + n/2) + n = .... It might give you *intuition*, but it is NOT a *proof*. To prove it, you will need [mathematical induction][1] or the [master theorem][2]. --- **P...
I know that the solution is T(n) = O(n log(n)) but how do you get to that point? I don't understand when it says put t into the equation repeatedly until it drops out... Any help?
Solving the big-Oh notation for T(n) = 2 T(n/2) + O(n)
|untagged|
I know that the solution for $T(n) = 2 T(n/2) + O(n)$ is $ T(n) = O(n \log(n))$ But how do you get to that point? I don't understand when it says put t into the equation repeatedly until it drops out... Any help?
Solving the big-Oh notation for $T(n) = 2 T(n/2) + O(n)$
|asymptotics|landau-notation|
It means "open" the recursion. For simplicity - denote $O(n)$ as $c\cdot n$: $$ \begin{align} T(n) &= 2T(n/2) + cn \\ &= 2(2T(n/4) + cn/2) + cn\\ &= 2 (2 (2T(n/8) + cn/4) + cn/2) + cn\\ & \vdots \end{align}$$ It might give you *intuition*, but it is NOT a *proof*. To prove it, you will need [mathemati...
null
Building on @Peter answers (it is a very long comment, so I just included as an answer hopping that someone will benefit from it). I would suggest the following reference: Arnaud Casteigts, Paola Flocchini, Walter Quattrociocchi, Nicola Santoro: Time-varying graphs and dynamic networks. IJPEDS 27(5): 387-408 (...
Many common operations are [monoids](http://en.wikipedia.org/wiki/Monoid). Haskell has leveraged this observation to make many higher-order functions more generic (`Foldable` being one example). There is one obvious way in which using monoids can be used to improve performance: the programmers is asserting the opera...
Are monoids useful in optimization?
|optimization|compilers|category-theory|
null
Let $P$ be a transition matrix of a random walk in an undirected graph $G$. Let $\pi$ be a distribution on $V(G)$. The Shannon entropy of $\pi$ is defined by $$H(\pi)=-\sum_{v \in V(G)}\pi_v\cdot\log(\pi_v).$$ How do we prove that $H(P\pi)\ge H(\pi)$ ?
Increasing entropy of random walk
|entropy|random-walks|
The compiler can optimize exponentiation with monoids. Let $\oplus$ be a binary operator such that $\oplus$ and $a_1, a_2, ... \in A$ form a monoid. Then the operation $$\bigoplus_{k\in[1..n]} a_k = \underbrace{a_k \oplus a_k \oplus \dots \oplus a_k}_{\text{$n$ times}}$$ which usually takes $\cal O(n)$ time can b...
> **Possible Duplicate:** > [Solving or approximating recurrence relations for sequences of numbers](http://cs.stackexchange.com/questions/2789/solving-or-approximating-recurrence-relations-for-sequences-of-numbers) <!-- End of automatically inserted text --> I know that the solution for $T(n) = 2 T(n/2) + O(n)$ ...
{"OriginalQuestionIds":[2789],"Voters":[{"Id":98,"DisplayName":"Raphael"}]}
The compiler can optimize exponentiation with monoids. Let $\oplus$ be a binary operator such that $\oplus$ and $a_1, a_2, ... \in A$ form a monoid. Then the operation $$\bigoplus_{[1..n]} a_k = \underbrace{a_k \oplus a_k \oplus \dots \oplus a_k}_{\text{$n$ times}}$$ which usually takes $\cal O(n)$ time can be ev...
Is this even true? Consider an undirected graph which is a star. That is, a central vertex $V_0$ is connected to all other vertices $V_1, V_2, \dots, V_{n-1}$, and there are no other edges in the graph. Then, if you start with an equal distribution on $V_1, V_2, \ldots, V_{n-1}$, after one step all the weight is on the...
null
I am unsure if I have even identified the problem correctly, but reading up on [knapsack problem][1] seems the closest to what I am trying to solve: > A cook has $k$ ingredients of $p$ quantities. Given a > list of $n$ unique recipes, each consisting varying ingredients of varying > quantities. > Now, the cook w...
null
I understood what amortized analysis does, but can anyone tell me what is the main purpose of this kind of analysis? For example in dynamic programming we save the answers to sub problems in tables which helps us reduce the running time(lets say from exponential to polynomial) But I am unable to get a complete pi...
Advantages of amortized analysis
|amortized-analysis|
The compiler can optimize exponentiation with monoids. Let $\oplus$ be a binary operator calculateable in constant time such that $\oplus$ and $a_1, a_2, ... \in A$ form a monoid. Then the operation $$\bigoplus_{[1..n]} a_k = \underbrace{a_k \oplus a_k \oplus \dots \oplus a_k}_{\text{$n$ times}}$$ which usually t...
I understood what amortized analysis does, but can anyone tell me what is the main purpose of this kind of analysis? What I understood: Let say we have 3 three operations a,b,c used 1,2 and 3 times to achieve d. Based on aggregate analysis a,b and c are used 2 times each. Is this correct? I am trying to unders...
|algorithm-analysis|amortized-analysis|
If you are in the constant folding/constant propagation step, whenever you come up with the identity of the monoid, you can just ignore it if it's multiplying other non-constant expressions.
Its not a homework question.Came in `Gate 2006` and also in My Final mid-term yesterday,dont know how to do it. For each of the four processes P1, P2, P3, and P4. The total size in kilobytes (KB) and the number of segments are given below. Process Total size(in KB) Number of segments P1 19...
Processes and Segmentation
|untagged|
Let $P$ be a transition matrix of a random walk in an undirected **(may not regular)** graph $G$. Let $\pi$ be a distribution on $V(G)$. The Shannon entropy of $\pi$ is defined by $$H(\pi)=-\sum_{v \in V(G)}\pi_v\cdot\log(\pi_v).$$ How do we prove that $H(P\pi)\ge H(\pi)$ ?
Consider the `std::vector` container from the STL, together with it's appending operation, `push_back()`. This operation has amortized running time $O(1)$. Why? `std::vector` implemented as an array which can dynamically grow, if more space is needed. The *strategy* it uses for resizing is simple: it doubles it's si...
I am new to "Computational Complexity" and therefore I have enough problems with some exercises like the following one: > Remember: $\text{PH} := \bigcup_{i} \Sigma_i$ > > Show: > > $\bullet \bigcup_{i}(\Sigma_i \cup \Pi_i \cup \Delta_i) = \bigcup_{i}\Sigma_i = \bigcup_{i}\Pi_i = \bigcup_{i}\Delta_i$ > > $\...
Polynomial hierarchy
|complexity-theory|
I'm currently learning computer science, and there is a slide of notes brief described the parallel radix sort under data parallelism. number 101 110 011 001 111 (1st bit) order 2 1 3 4 5 (new order) number 110 101 011 001 111 (2nd bit) order 3 1 4 2 5 (new order) number...
how does the parallel radix sort work?
|sorting|parallel-computing|
|complexity-theory|time-complexity|
The following problem was on my final and in `Gate 2006`, but I don't understand how to solve it: Different methods of memory management have different overheads: - The paging method for memory management uses two-level paging, and its storage overhead is $P$. - The storage overhead for the segmentation metho...
|storage|paging|
null
The following problem was on my final and in `Gate 2006`, but I don't understand how to solve it: Different methods of memory management have different overheads: - The paging method for memory management uses two-level paging, and its storage overhead is $P$. - The storage overhead for the segmentation metho...
|operating-systems|memory-management|storage|paging|
null
I am guessing that overheads P, S, and T exclude per page/segment overheads and are per-process overheads (if they are per-system overheads, the adjustments are obvious), so the overhead of each process would be P + page_count * 4 bytes for paging, S + segment_count * 8 bytes for segmentation, and T + segment_count * 8...
What is does it mean when an argument to a function is called a **dummy argument**? I have not encountered this term outside Fortran, is it a general term in computer science? What would be examples of arguments passed as dummy and not passed as dummy? I found [this definition][1], which I am not sure that I underst...
|complexity-theory|graphs|np-complete|complexity-classes|
I am new to "Computational Complexity" and therefore I have enough problems with some exercises like the following one: > Remember: $\text{PH} := \bigcup_{i} \Sigma_i$ > > Show: > > $\bullet \bigcup_{i}(\Sigma_i \cup \Pi_i \cup \Delta_i) = \bigcup_{i}\Sigma_i = \bigcup_{i}\Pi_i = \bigcup_{i}\Delta_i$ > > $\...