instruction
stringlengths
0
29.8k
⌀
|game-theory|
$\sum\limits_{k=1}^{n}\log \frac{n}{k} = \sum\limits_{k=1}^{n}\log n-\sum\limits_{k=1}^{n}\log k = \log n^n - \log n! = n \log n - (n \log n - n + O(\log n)) = n - O(\log n) = O(n)$
null
null
null
null
In an answer to [this][1] question: > For instance, modern Intel TLBs have a process context ID (PCID); each TLB entry is tagged with the PCID of the process that the page mapping is for, and the processor will only use that TLB entry if its PCID matches the ID of the currently running process. The processor fills t...
How does virtualization handle modern TLBs?
|operating-systems|memory-hardware|virtual-memory|
null
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...
[Theo H's suggestion](https://cs.stackexchange.com/a/165200) of using Floyd's algorithm is a good one, but requires knowing the number of elements we wish to sample in advance. However, there's a fairly similar algorithm that allows the sampled elements to be generated one at a time "on demand". The basic idea is t...
In an answer to [this][1] question: > For instance, modern Intel TLBs have a process context ID (PCID); each TLB entry is tagged with the PCID of the process that the page mapping is for, and the processor will only use that TLB entry if its PCID matches the ID of the currently running process. The processor fills t...
[Theo H's suggestion](https://cs.stackexchange.com/a/165200) of using Floyd's algorithm is a good one, but requires knowing the number of elements we wish to sample in advance. However, there's a fairly similar algorithm that allows the sampled elements to be generated one at a time "on demand". The basic idea is t...
I am trying to find the Big O notation of this code below, really its the big theta, but whatever I believe its the same in this case. for (i=2; i < n^2; i++){ for (j=3; j < 4i^3; j = 2*j){ x = i+n } } One, I believe that the constant in 4i^3 can be dropped. And so, the inner l...
Big O, Understanding when the increment is doubling
|asymptotics|big-o-notation|
If you care only about having uniform probability for each of the $N$ elements to be included in the $K$-element sample, then @PeterCordes's suggestion to use just one call to $rand()$ to seed a suitably tuned LCG is very attractive. If it is additionally important to have equal probability of each of the $\tbinom...
[Theo H's suggestion](https://cs.stackexchange.com/a/165200) of using Floyd's algorithm is a good one, but requires knowing the number of elements we wish to sample in advance. However, there's a fairly similar algorithm that allows the sampled elements to be generated one at a time "on demand". The basic idea is t...
If you care only about having uniform probability for each of the $N$ elements to be included in the $K$-element sample, then @PeterCordes's suggestion to use just one call to $rand()$ to seed a suitably tuned LCG is very attractive. If it is additionally important to have equal probability of each of the $\tbinom...
[Theo H's suggestion](https://cs.stackexchange.com/a/165200) of using Floyd's algorithm is a good one, but requires knowing the number of elements we wish to sample in advance. However, there's a fairly similar algorithm that allows the sampled elements to be generated one at a time "on demand". The basic idea is t...
Given a set `S` of N-tuples, I want to generate all (N+1)-tuples (call this set `T`) such that for each element of `T` each N-element sub-tuple is in `S`. My current naive algorithm performs quite badly. Set `S` ~ 100-10000 elements and `N` ~ 5 or so. More concretely (although perhaps more confusingly). Let $N...
Generate set of (N+1) tuples from (N) tuples
|graphs|
[Theo H's suggestion](https://cs.stackexchange.com/a/165200) of using Floyd's algorithm is a good one, but requires knowing the number of elements we wish to sample in advance. However, there's a fairly similar algorithm that allows the sampled elements to be generated one at a time "on demand". The basic idea is t...
Given a set `S` of N-tuples, I want to generate all (N+1)-tuples (call this set `T`) such that for each element of `T` each N-element sub-tuple is in `S`. My current naive algorithm performs quite badly. Set `S` ~ 100-10000 elements and `N` ~ 5 or so. More concretely (although perhaps more confusingly). Let $N...
Given a set `S` of N-element sets, I want to generate all (N+1)-element sets (call this set `T`) such that for each element of `T` each N-element subset is in `S`. My current naive algorithm performs quite badly. Set `S` ~ 100-10000 elements and `N` ~ 5 or so. More concretely (although perhaps more confusingly). ...
Given a set $S$ of N-element sets, I want to generate all (N+1)-element sets (call this set $T$) such that for each element of $T$ each N-element subset is in $S$. My current naive algorithm performs quite badly. Set $S$ ~ 100-10000 elements and $N$ ~ 5 or so. More concretely (although perhaps more confusingly). ...
Generate sets of size N+1 from sets of size N
We are given an undirected graph $G(V, E)$, and let $n = |V|$. The task is to find a bijective function $\psi: V \rightarrow \lbrace{1, 2, \dotsc, n \rbrace}$ such that the following objective is minimized: $\sum_{(u, v) \in E} \max(\psi(u), \psi(v))$. I am interested in the complexity of this problem. Note that this p...
I will suggest one possible approach:: - Build a hashtable that for each set $r$ of size $N-1$, maps to a list of elements $x$ such that $r \cup \{x\} \in S$. - Now, for each $s \in S$, and each $r \subset s$ such that $|r|=N-1$, look $r$ up in the hashtable, find the corresponding list, and for each $x$ in the c...
{"Voters":[{"Id":80225,"DisplayName":"csTheoryBeginner"}],"DeleteType":1}
The inner loop: After k iterations we have $j = 3 \cdot 2^k$. We exit the loop if $3 \cdot 2^k \ge 4 \cdot i^3$ or $2^k \ge (4/3) \cdot i^3$ or $k \ge \log (4/3) + 3 \cdot \log i$. So we add $\log (4/3) +3 \cdot \log i$ for $ 2 \le i \lt n^2$. An immediate upper bound is $n^2 \cdot (\log (4/3) + 6 \log n)$. The act...
If all items in the hash table are integers, then the difference between a and b is 3 or 4. You need an iterator that iterates through all elements of the hash table in O(n) to find all possible values of b in random order; most hash table implementations will provide this. Then for each b you check whether b-3 or b-4 ...
{"Voters":[{"Id":80225,"DisplayName":"csTheoryBeginner"}]}
**Context:** I was reading a research paper related to [polyhedral representation][1]. Got confused while trying to understand the notation by implementing them with example code. **Problem description:** *From the paper; Page no: 6, Point: 3, 2nd paragraph* > Let us now introduce the representation of a ...
"Consecutive statements" in Static control Part(SCoP)
|optimization|sets|loops|loop-invariants|
null
null
Lets say I have a SAT problem with variables $x_1,...,x_n$. For a given subset of the variables I want to create a clause which forces an even number of the variables in $S$ to be true. Of course there is the brute force solution, but I would like a more efficient solution with as few clauses/variables as possible.
SAT formulation of the condition that an even number of a given set of variables must be set to true
|logic|satisfiability|
Let $\oplus$ be XOR, then your question is asking for $\bigoplus_{k=1}^n x_k = 0$. We can encode this efficiently without an exponential explosion in clauses by introducing new variables. The basic premise is the following: $$a = b \oplus c \quad\iff\quad a \oplus b \oplus c = 0$$ Assuming $a$ is the new varia...
I suppose that this statement is true if NP equals with coNP, otherwise not, but I don't know how can I prove that.
Is there an NP-hard problem that is polynomially reducible to its complement, and whose complement is polynomially reducible to the problem?
|complexity-theory|complexity-classes|
null
Take any NP-hard problem $A \subseteq \{0,1\}^*$. Now let $\langle A, \overline{A}\rangle := \{0w \mid w \in A\} \cup \{1w \mid w \notin A\}$. Clearly, $A$ is polytime reducible to $\langle A, \overline{A}\rangle$ via $w \mapsto 0w$, thus $\langle A, \overline{A}\rangle$ inherits being NP-hard from $A$. Also, $\langle...
I know the double tree algorithm and Christofides algorithm with 1.5 approximation ratio. We got this question from the teacher.
Is there a 3-approximation algorithm for the TSP problem?
|complexity-theory|approximation|
Begin by drawing a table of the instructions executed: | # | INSN | OP1 | OP2 | OP3 | COMMENT | |----|------|-----|------|---------|-------------------------| | 1 | addi | t0 | zero | 1 | t0 = 1 | | 2 | addi | v0 | zero | 0 | v0 = 0 | | 3 |...
The Bucheim-Walker algorithm is used for drawing trees. However, there are many real-world examples where Directed Cyclic Graphs would benefit from such an algorithm (e.g. family trees with intermarriage or incestual relationships, dependency graphs, etc.). Can the algorithm be modified to support DCGs? If so, how? Is ...
null
The Bucheim-Walker algorithm is used for drawing trees. However, there are many real-world examples where Directed Cyclic Graphs would benefit from such an algorithm (e.g. family trees with intermarriage or incestual relationships, dependency graphs, etc.). Can the algorithm be modified to support DCGs? If so, how? ...
Information theory to a large extent deals with how to efficiently encode messages given a probability distribution over messages. Intuitively, it seems like we can think of machine instructions (or programs) as "messages to the CPU". Some messages are more probable than others. E.g. "add numbers x and y" is more pr...
null
null
One version of the minimum sum vertex cover [1] is the following problem: We are given an undirected graph $G(V, E)$, and let $n = |V|$. The task is to find a bijective function $\psi: V \rightarrow \lbrace{1, 2, \dotsc, n \rbrace}$ such that the following objective is minimized: $\sum_{(u, v) \in E} \min(\psi(u), \...
Min sum vertex cover complexity proof
|complexity-theory|vertex-cover|vertex-labeling|
null
null
As mentioned in the comments [2](https://tetali.math.gatech.edu/PUBLIS/mssc_final.pdf) proves this in Theorem 14 with the slightly stronger claim: "For some $\epsilon'>0$, it is NP-hard to approximate min sum vertex cover within ratios better than $1+\epsilon'$."
A course in multivariable calculus is useful for understanding back-propagation. Some familiarity with a programming language like Python would helpful to understanding how it all works, and for actually running some common libraries. A course in statistics would be useful as well!
Suppose a generalized version of k-SAT where the usual clauses (disjunctions of literals) are generalized to arbitrary Boolean functions of k variables. (For example, $(x \oplus (y \land z)), ((x \land z) \lor (y \land z))$ and $(x \implies z)$ could be generalized clauses for k = 3.)(Just a note: there are $2^{2^k}$...
How fast can we make generalized k-SAT?
|complexity-theory|satisfiability|3-sat|
**Context:** I was reading a research paper related to [polyhedral representation][1](citation given in last). Got confused while trying to understand the notation by implementing them with example code. **Problem Description:** *From the paper; Page no: 6, Point: 3, 2nd paragraph* > Let us now introduce ...
**Context:** I was reading a research paper related to [polyhedral representation][1](citation given in last). Got confused while trying to understand the notation by implementing them with example code. **Paper Citation:** > Bastoul, Cédric & Cohen, Albert & Girbal, Sylvain & Sharma, Saurabh & > Temam, Olivi...
|complexity-theory|satisfiability|3-sat|sat-solvers|
We are given an undirected graph $G(V, E)$, and let $n = |V|$. The task is to find a bijective function $\psi: V \rightarrow \lbrace{1, 2, \dotsc, n \rbrace}$ such that the following objective is minimized: $\sum_{(u, v) \in E} \max(\psi(u), \psi(v))$. I am interested in the complexity of this problem. Note that this p...
For any specific machine $M_0$ and input $w_0$, there is a machine that decides whether $M_0$ halts on $w_0$. Indeed, one of the following machines works: - The machine that outputs "Yes". - The machine that outputs "No". However, there is no program $P$ that given *arbitrary* $M$ and $w$ produces a machine $T_{...
I know that when I compile a program and then I inspect with objdump, I have addresses. These are **relative addresses**. But if it's a C program and I printf with %p a pointer, that is a **virtual/logical address**. Who generates this? Is that the loader? If yes, why do I need that a loader does this? **Isn't it...
Who and how generate the virtual/logical addresses? Confusion if it's the compiler, the linker, the loader
|operating-systems|memory-management|virtual-memory|paging|
I know that exists problems that surely cannot be decided in polynomial time because P class doesn't equal with EXPTIME (for example Go, generalized chess etc.). But I assume that there may be problems for which we currently only have an algorithm with exponential time complexity and yet can be solved in polynomial tim...
We know that there is an algorithm for a problem that decides it in $\Omega(2^n)$ time. We know that it is not in P class, or we cannot decide?
|complexity-theory|complexity-classes|
Well, there is a sorting algorithm that takes $\Omega(n!)$ steps on average: Create a random permutation of your data, check whether the resulting array is sorted, and repeat until it is sorted. But obviously the problem can be solved in $O(n^2)$ and practically in $O(n \log n)$.
I know that when I compile a program and then I inspect with objdump, I have addresses. These are **relative addresses**. But if it's a C program and I printf with %p a pointer, that is a **virtual/logical address**. Who generates this? Is that the loader? If yes, why do I need that a loader does this? **Isn't it...
null
I have proved that $\bar{A}\le\bar{B}$ is true, but I have no idea how to prove or disprove the opposite direction.
$A$ and $B$ two decision problems.If $A\le\ B$ then $\bar{B}\le\bar{A}$ is true?
|complexity-theory|complexity-classes|
null
I know that when I compile a program and then I inspect with objdump, I have addresses. These are **relative addresses**. But if it's a C program and I printf with %p a pointer, that is a **virtual/logical address**. Who generates this? Is that the loader? If yes, why do I need that a loader does this? **Isn't it...
Your approach to solve the problem is correct. Actually to apply Rice's theorem to a set, The following requirements should be satisfied: 1- The language doesn't contain all Turing machine and Also it is not empty. 2- If M belongs to our set, Then for every Turing machine say M', If L(M) = L(M'), Then M' bel...
> Proove or Disproove $L_1 , L_2 \in RE \setminus R $ such that $ L_1 > \cup L_2 \in R $ and $ L_1 \cap L_2 \in R $ I tried to use the languages [![enter image description here][1]][1] but the intersection not in R right ? [1]: https://i.stack.imgur.com/GWqwY.png
Proof or disproove $L_1 , L_2 \in RE \setminus R $ such that $ L_1 \cup L_2 \in R $ and $ L_1 \cap L_2 \in R $
|formal-languages|turing-machines|
|complexity-theory|satisfiability|boolean-algebra|3-sat|sat-solvers|
{"Voters":[{"Id":159462,"DisplayName":"Ali Dastjerdi"}],"DeleteType":1}
null
You can reduce K to L: Let K = {e | e's Turing machine halts on e} Let f(x,y) be f(x,y) = Code of the following machine: For any input w: Run y's Turing machine on y. If w = x, accept. Otherwise reject. Here by Recursion theorem, We know there is some function s which: f(s(y),y) = s...
{"Voters":[{"Id":159462,"DisplayName":"Ali Dastjerdi"}]}
You can reduce K to L: Let K = {e | e's Turing machine halts on e} Let f(x,y) be f(x,y) = Code of the following machine: For any input w: Run y's Turing machine on y. If w = x, accept. Otherwise reject. Here by Recursion theorem, We know there is some computable function s which: f(...
{"Voters":[{"Id":159462,"DisplayName":"Ali Dastjerdi"}],"DeleteType":1}
{"Voters":[{"Id":159462,"DisplayName":"Ali Dastjerdi"}]}