instruction
stringlengths
0
29.8k
⌀
Assume for simplicity that $n$ is a power of $2$. By unrolling $T(n) = T(n/2) + \log n$ you get: $$ \begin{align*} \log n + \log \frac{n}{2} + \log \frac{n}{4} + \log \frac{n}{8} + \dots &= \log n + ( \log n - 1 ) + (\log n - 2) + (\log n - 2) + \dots \\ & = \sum_{i=0}^{\log n} (\log n - i) = \sum_{i=0}^{\log...
null
Assume that we are given a formula in 3-CNF such that at least 1% of the complete assignments satisfy it. My question is how to find a satisfying assignment in polynomial time without the use of randomness? Prove the correctness and the upper bound on the running time for the algorithm that you suggest.
How to find a satisfying assignment in polynomial time without the use of randomness?
|satisfiability|3-sat|constraint-satisfaction|
I'm trying to solve an exercise from "*Algorithmics for hard problems*" but I have no idea how to solve it. First the definition of one-sided-error Monte Carlo algorithm is a little different than usual. We say A is a one-sided error monte carlo algorithm recognizing L if 1. for every $x \in L, Prob(A(x)=1) \geq1/2$ ...
one sided equality communication complexity is at least O(n)
|communication-complexity|
- The first column list all ranges with uniform number of levels for both approaches, up to 42. One way is to start with one level, and compute how many inputs a circuit with that many outputs accommodates - twice as many with (4;2) compressors, three halves, truncated, with (3,2) counters. - With a simple timing m...
null
null
Why one-sided-error equality problem communication complexity is at least O(n)
On the proof assistants StackExchange site, someone gave this example of a dependent product: $$\prod_{i\in I}\sum_{j\in J_i}x_{ij}=\sum_{f\in\prod_iJ_i}\prod_{i\in I}x_{if(i)}$$ The dependent product is the $\prod_iJ_i$ bit, and just what role it plays in this case is mysterious to me. It's a very short answe...
Application of dependent product
|dependent-types|
null
That's what I'm formally asking: Let the algorithm $A$ have the worst-case time complexity $\Theta(f(n))$, such that for any algorithm $B$ with the worst-case time complexity $\Theta(g(n))$ doing the same job as $A$, $g(n) \in \Omega(f(n))$. Let $\Theta(s(n))$ be the worst-case space complexity for the algorithm $A$...
Can a time-optimal algorithm have a time complexity better than its space complexity?
|algorithms|complexity-theory|time-complexity|space-complexity|
It took me a while to figure out what this circuit does: It takes 5 inputs and produces 3 outputs. One output is the sum with a value of 1, and two carry bits with a value of 2. If the sum of the inputs is 2 or 3, one of the two carries must be set, and one cleared; it doesn’t matter which one; this gives you the value...
A NOP instruction is used to fill program space while having no side effect. This is done for example to make a loop start at the beginning of a cache line to run faster. The AMD processor manuals describe 1 byte to 9 byte NOP instruction. None is officially called NOP. For example “add constant 0 to register x” wo...
null
null
A 0-operand instruction is simply an instruction that takes no operand. As a result, if such an instruction changes some data either in memory or in some register, the corresponding address or register name is implicitly determined by the instruction itself at time of execution (e.g., the affected memory location mig...
null
I am looking for an unranking (and ranking) algorithm for the Heap' Algorithm. I have been researching a bit on ranking and unranking of permutation algorithms. There are plenty algorithms for lexicographic permutations, few on Johnson-Trotter, there is Ruskey and Myrvold (seems another order), but I could not f...
Rank and unrank for Heap's Algorithm
|permutations|
null
To name one example, one of the NOPs in x86 (there's a bunch!) is encoded as `90`. It's a special case of the family of instructions encoded as `90+rd` meaning that it encodes *one* operand in the 3 bottom bits of the opcode, in `90` those three bits are obviously zero, which encodes `eax`. The `90+rd` family encodes `...
In my university class, I received this homework assignment on computer architecture, but I don't know how to solve it. I already know that the correct answer is 0, but I don't understand why. Could someone help me? Problem: The byte-addressable memory has a 16-bit address. The directly addressed cache has 7-bit ta...
Problem with cache and memory from university class
|computer-architecture|memory-management|memory-allocation|cache|
People I know said that converting a Regex to DFA is just a "matter of judgement" (I do not believe them, there has to be a more systematic approach). Is there a simple/intuitive, yet concise way to convert a Regex like this a*b+a(b+a|aa+b)*ab(a?|bb?a)+ into a DFA?
Converting Regex to DFA
|finite-automata|regular-expressions|
You can convert the regular expression into an automaton using the [Glushkov's construction](https://en.wikipedia.org/wiki/Glushkov%27s_construction_algorithm). The resulting automaton is non-deterministic, but you can find a deterministic automaton using the [powerset construction](https://en.wikipedia.org/wiki/Pow...
The article is correct about $T$ but not $S$ since ${S[i] : 0 ≤ i ≤ 2N}$ and $T[i,j] : 0 ≤ i, j ≤ N$.
The article is correct about $T$ but not $S$ since ${S[i] : 0 ≤ i ≤ 2N}$ and $T[i,j] : 0 ≤ i, j ≤ N$. I believe a TL;DR of the question is in order, therefore: 1. What is the iteration domain of this loop? ``` for (int i = 0; i <= 2*N; ++i) ``` The answer is ${S[i] : 0 ≤ i ≤ 2N}$, and the article incorrectly ...
null
null
null
null
null
If I understand correctly, your directly-mapped cache has 128 cache lines of 8 bytes. So, in a memory address, the 3 least significant bits (bits `[0:3]`) are used to compute the location *inside the cache line* while the rest of the bits are used to target a specific cache line inside the cache. I can only *assume* th...
|satisfiability|polynomial-time|3-sat|constraint-satisfaction|
Neither could I find any counterexamples, nor could I show that if indeed the complement of NP-hard problems was NP-hard, one could deduce some unknown results from it, which would imply that it is indeed probably unknown. If someone knows the answer or a paper where this question is discussed or any other reason why ...
Is it known, whether the complement of NP-hard problems is necessarily again NP-hard?
|complexity-theory|computability|np-complete|logic|complexity-classes|
null
Given an undirected graph, two vertices $s$ and $t$, and two integers $k$ and $r$, then a $k$-set of internally disjoint $s$-$t$-paths is defined to be a set of exactly $k$ $s$-$t$-paths that share no vertex except for $s$ and $t$. What is the complexity of deciding whether there are $r$ pairwise edge-disjoint $k$-sets...
Are there $r$ pairwise edge-disjoint $k$-sets of internally disjoint $s$-$t$-paths? Complexity
|algorithms|complexity-theory|graphs|np-hard|path|
Suppose you have a Knapsack (optimisation) problem with integer values and weights, and you know the optimal value $OPT$. Can you compute an optimal solution in polynomial time by using a PTAS or FPTAS and setting $\epsilon < 1/OPT$, since this would mean it computes a solution in polynomial time which is of value $\ge...
Can PTAS be used to optimally solve Knapsack?
|optimization|approximation|knapsack-problems|
Suppose you have a Knapsack (optimisation) problem with integer values and weights, and you know the optimal value $OPT$. Can you compute an optimal solution in polynomial time by using a PTAS or FPTAS and setting $\epsilon < 1/OPT$, since this would mean it computes a solution in polynomial time which is of value $\ge...
null
Suppose you have a Knapsack (optimisation) problem with integer values and weights, and you know the optimal value $OPT$. Can you compute an optimal solution in polynomial time by using a PTAS or FPTAS and setting $\epsilon < 1/OPT$, since this would mean it computes a solution in polynomial time which is of value $\ge...
Assume for simplicity that $n$ is a power of $2$. By unrolling $T(n) = T(n/2) + \log n$ you get: $$ \begin{align*} \log n + \log \frac{n}{2} + \log \frac{n}{4} + \log \frac{n}{8} + \dots &= \log n + ( \log n - 1 ) + (\log n - 2) + (\log n - 2) + \dots \\ & = \sum_{i=0}^{\log n} (\log n - i) = \sum_{i=0}^{\log...
null
- A is an array of size n of different numbers (not necessarily integers). Indexes start from $1$ to $n$. - S is an array with the property: $$S[i] = |\left\{A[j] \ : 1\le j<i \ \text{and} \ A[j] \le A[i]\right\}| $$ For example, for $A=[2,7, 4,5,15,9,12]$ , $S=[0,1,1,2,4,4,5]$. ---------- I want to so...
How to sort an array A using an array S with the properties below
|sorting|
null
According to my information the technique is by [J.A. Brzozowski][1] and [E.J. McCluskey][2]. The method is described in Signal Flow Graph Techniques for Sequential Circuit State Diagrams, IEEE Transactions on Electronic Computers, 67 - 76, 1963. https://doi.org/10.1109/PGEC.1963.263416 (subscription needed) > Abstr...
I am looking for an unranking (and ranking) algorithm for the [Heap's Algorithm][1]. I have been researching a bit on ranking and unranking of permutation algorithms. A ranking function for the permutations on n symbols assigns a unique integer in the range [0, n!-1] to each of the n! permutations. The correspon...
How can I prove that it is NL or L? I see that I should create a deterministic/nondeterminsitic algorithm with logarithmic space, but I have no idea how to store the coloring in logaritmic space.
The 2-coloring problem is in P class. But does it belongs to L or NL?
|complexity-theory|complexity-classes|colorings|
The 2-coloring problem is [$\mathsf{SL}$](https://en.wikipedia.org/wiki/SL_(complexity))-complete. That means that there is a logspace reduction from 2-coloring to undirected accessibility. See [this paper](https://link.springer.com/article/10.1007/PL00001603) for some references. It was showed in 2004 that [$\maths...
The 2-coloring problem is [$\mathsf{SL}$](https://en.wikipedia.org/wiki/SL_(complexity))-complete. That means that there is a logspace reduction from 2-coloring to undirected accessibility (and conversely). See [this paper](https://link.springer.com/article/10.1007/PL00001603) for some references. It was showed in 2...
The runtime of a FPTAS is polynomial in the input size and in $1/\epsilon$. However, if $\epsilon$ depends on parameters which may **not** be polynomial in the input size, such as in this case $OPT$ or $V$, then the algorithm is not a polynomial time algorithm. It is however a pseudo-polynomial time algorithm, sinc...
I have a 12-dimensional state-space and would like to use a kd-tree to partition my data, so that nearest neighbour operations can be performed quickly. Unfortunately I have the issue that three of the states are angular values which wrap-around (360 degrees and 0 degrees are the same), which will mislead the nearest n...
Kd-trees excluding some splitting dimensions
|data-structures|nearest-neighbour|kd-tree|
null
Note that a graph $G$ is 2-colorable iff $G$ is bipartite iff $G$ has no odd cycle. All these equivalences are well-known and can be easily looked up. Using that, it is easy to show that the language is in $NL$, and one can even show that it is in $L$, as already answered [here][1]. [1]: https://cs.stackexchange...
I am looking for an unranking (and ranking) algorithm for permtuations that is consistent with the order that [Heap's Algorithm][1] generates permutations. I have been researching a bit on ranking and unranking of permutation algorithms. A ranking function for the permutations on n symbols assigns a unique integ...
|combinatorics|permutations|enumeration|
I suggest that you tweak the distance metric slightly. You can define any distance metric that you want, to capture/measure similarity between two points. When computing the distance between two angles $r,s$, a helpful definition is $$d(r,s) = \min(|r-s|,|r+2\pi-s|,|r-2\pi-s|),$$ or concisely, $d(r,s) = |r-s|...
{"Voters":[{"Id":755,"DisplayName":"D.W."}],"DeleteType":1}
null
null
null
I realize that this is a very old question, but I just came across it as part of my own research into the topic. Hopefully, this will be useful to somebody else who finds it. There has been a newer proposal by Chen et al. ("A general check digit system based on finite groups", there's an author's copy [here][1]) for...
I realize that this is a very old question, but I just came across it as part of my own research into the topic. Hopefully, this will be useful to somebody else who finds it. There has been a newer proposal by Chen et al. ("A general check digit system based on finite groups", there's an author's copy [here][1]) for...
Suppose we've to pick $K (\le N)$ random integers in range $[0, N - 1]$ for very large $N$ such that there is no repetition, while also deterministically minimizing number of calls made to $rand()$ function, how would we do it? Picking random till we get unique value may not be efficient for smaller N, and traversin...
pick K random integers without repetition
|randomness|
You can convert a regexp to a DFA with [Thompson's algorithm](https://en.wikipedia.org/wiki/Thompson%27s_construction). It is covered in many resources, including standard textbooks on automata theory. Alternatively, you could consider [Glushkov's algorithm](https://en.wikipedia.org/wiki/Glushkov%27s_construction_a...
Suppose we've to pick $K (\le N)$ random integers in range $[0, N - 1]$ for very large $N$ such that there is no repetition, while also deterministically minimizing number of calls made to $rand()$ function, how would we do it? Assume $rand(X)$ produces a random integer in range $[0,X - 1]$, calling it with any argu...
I suggest that you tweak the distance metric slightly, and then tweak the split function in your k-d tree to match it. You can define any distance metric that you want, to capture/measure similarity between two points. And you can modify a standard k-d tree so it works well with the revised distance function. When...
{"Voters":[{"Id":755,"DisplayName":"D.W."}]}
null
As [mentioned by Clement C. on CS Theory](https://cstheory.stackexchange.com/questions/53801/how-to-find-a-satisfying-assignment-in-polynomial-time-without-the-use-of-random#comment119626_53801), this is answered at [Conditions for tractability of 3SAT-Satisfiability](https://cstheory.stackexchange.com/a/3176). You ca...
How can I prove that it is NL or L? I see that I should create a deterministic/nondeterminsitic algorithm with logarithmic space, but I have no idea how to store the coloring in logarithmic space.
The 2-coloring problem is in P class. But does it belong to L or NL?
null
The 2-coloring problem is in P. How can I prove that it is in NL or L? I see that I should create a deterministic/nondeterministic algorithm with logarithmic space, but I have no idea how to store the coloring in logarithmic space.