instruction
stringlengths
0
29.8k
⌀
I know this is a very specific question, but: Let's assume that someone designed a 1.1 approximation algorithm for the load balancing problem involving exactly 2 machines. After running the algorithm on a set of n activities, the final loads are 80 for the first machine and 120 for the second one. Is this possible give...
The following problem statement is given: Let S = {s1, s2, ..., sn} be a sequence of unique positive integers and K a positive integer, where K >= si, for every i between 1 and n. The goal is to find a subset of S whose sum is maximum, subject to the constraint that the sum must be <= K. Write an approximation algor...
Negative. They have nothing to do with each other. Turing test is a tool to assess machine's ability to display intelligent behavior indistinguishable from that of a human. There is nothing in the definition saying that mentioned machine has to be a Turing machine, or that it has to be Turing complete. All Turing co...
Negative. They have nothing to do with each other. Turing test is a tool to assess machine's ability to display intelligent behavior indistinguishable from that of a human. There is nothing in the definition saying that mentioned machine has to be a Turing machine, or that it has to be Turing complete. Nothing, even th...
The method to get the sat result is kind of straightforward, you can use some search algorithms like heuristic search to get a solution. But how does z3 get the unsat result like x < 2 && x > 2 I searched for some articles related to z3 but didn't don't know how. I would be very grateful if someone could give me the...
what is the background theory that Z3 uses to prove constraints unsat
|constraint-satisfaction|
When hand-manipulating algebra DNF (sum of products) is easier than CNF (product of sums). Possibly because factoring is more difficult than expanding. So why is it the opposite for computational boolean algebra? Perhaps one argument is that in CNF one can show that an expression is false by showing that one cla...
Why is conjunctive normal form (CNF) "better" for SAT than disjunctive normal form (DNF)?
|satisfiability|boolean-algebra|
In the (unweighted) [minimum k-cut problem][1], the goal is to partition the nodes in a given graph to at least $k$ subsets, such that the number of edges between different subsets is as small as possible. I am interested in a variant in which the number of subsets is not fixed in advance, but there can be at most $...
Finding a minimum cut with an upper bound on the set sizes
|graphs|reference-request|minimum-cuts|
You are asking about satisfiability modulo theories (SMT). There are similar algorithmic approaches there, and you can refer to [Wikipedia for more](https://en.wikipedia.org/wiki/Satisfiability_modulo_theories#Solver_approaches). In particular, you can have a look at [DPLL(T)](https://en.wikipedia.org/wiki/DPLL(T)) ...
Your premise is wrong. You are assuming we don't know how to compute the features on new sentences. But we do know. We construct features so that we can compute the features on any sentence whatsoever (not just the ones in the training set). For instance, one feature might be "does the sentence contain the word '...
One (serious) issue is that converting to DNF is _harder_ than solving the SAT problem itself! E.g. you can see that: $$ x\wedge y\ \vee\ x\wedge \neg z$$ has 2 solutions, $x=\top,\ y=\top$ and $x=\top,\ z=\bot$, without doing any fancy work. This means that converting into DNF is going to be tough, as oppose...
The idea is to set $K/2$ as the target. - If there is any given number that is at least $K/2$, just return it. - Otherwise, all given numbers are $<K/2$. - If the sum of all given numbers is $\le K$, return the sum, which is the optimal solution. - Otherwise the sum of all given numbers is $>K$. Let ...
The following problem statement is given: Let $S = \{s_1, s_2, \cdots, s_n\}$ be a sequence of unique positive integers and $K$ a positive integer, where $K \ge s_i$, for every $i$ between $1$ and $n$. The goal is to find a subset of $S$ whose sum is maximum, subject to the constraint that the sum must be $\le K$. W...
Linear-time constant-space 1/2-approximation algorithm for the maximum subset sum problem
|algorithms|approximation|subset-sum|greedy|
The idea is to set $K/2$ as the target. - If there is any given number that is at least $K/2$, just return it. - Otherwise, all given numbers are $<K/2$. - If the sum of all given numbers is $\le K$, return the sum, which is the optimal solution. - Otherwise the sum of all given numbers is $>K$. Let ...
null
Theoretical perspective ======================= One reasonable approach is to sort tests by $t/p$, where $t$ is the time to execute the test and $p$ is the probability the test fails. One can prove that if tests fail independently, then there is a sense in which this algorithm is optimal; see https://cs.stackexcha...
The problem is called Component Order edge-Connectivity. The _edge_ here refers to deletion of edges. See e.g. [Gross et al.](http://combinatorialmath.com/index.php/ArsCombinatoria/article/view/2146). The problem is defined as follows. Given an undirected graph $G = (V, E)$ and two integers $k$ and $\ell$, is it ...
null
null
I have an easy question about the DPDA. Could you read an input and push a different symbol to the stack. An example would be A transition from q1 to q2 where read input is v pop is epsilon(empty string) and push is x Both v and x are symbols
can you read and push different symbols in a DPDA?
|pushdown-automata|
I have a desktop PC with the CPU Intel I7-12700F with **180 TDP**, the CPU fan Zalman CNPS10X extreme, and Windows 11 and my problem is that The CPU cooling causes much noise when simple tasks are being performed; opening directories or windows, opening or closing small programs such as Notepad, Calculator, web browser...
null
If you mean, you can push a symbol different from what your machine has read from the input, then yes you can. The input and stack symbols are not related and there is no rule that requires them to be the same (see the formal definition [here](https://en.m.wikipedia.org/wiki/Deterministic_pushdown_automaton#Formal_defi...
null
### Algorithm in the question ### Although it is correct, it is rather slow. In function `Omega(k)`, `b` goes from 1 to the largest prime divisor of $k$, which is of order $\dfrac {\pi^2n} {12\,\log n}$ on average for $1 \le k \le n$ as [mentioned by the On-Line Encyclopedia of Integer Sequences](https://oeis.org/A0...
I want to optimize an algorithm for calculating $g(n)=\sum^n_{k=2} p(\Omega(k))\Omega(k)$ where $$ p(n) = \begin{cases} 1 &\text{if $n$ is odd} \\ -1 &\text{if $n$ is even} \end{cases}$$ and $\Omega(k)$ is the [prime factor counting function](https://en.wikipedia.org/wiki/Prime_omega_function) or more exactly, ...
|algorithms|complexity-theory|time-complexity|primes|program-optimization|
null
null
Give a real world example where table T1 has primary key (A, B), T2 has primary key (B, C) and T3 has primary key (A, C) and table 4 has a primary key (A, B, C) where (A,B) is a foregin key on T1, (B, C) is a foregin key on T2, and (A, C) is a foregin key on T3?
Real world example of complex foregin key references
|database-theory|databases|
null
There are basically two components: the underlying SAT solver procedure, and the additional theory-specific procedures. - For the underlying SAT solver: considering your example of `x < 2 && x > 2`, when viewed as a SAT formula this is just `p && q`. The SAT solver will determine from this that both `p` and `q` hav...
There are basically two components: the underlying SAT solver procedure (DPLL), and the additional theory-specific procedures. - For the underlying SAT solver: considering your example of `x < 2 && x > 2`, when viewed as a SAT formula this is just $p \land q$. The SAT solver will determine from this that both $p$ a...
The usual way to prove that a particular machine will never halt is to follow the first steps, long enough until you can find a pattern, and then prove by induction that the pattern will repeat. Maybe you can find something like "after 119 steps, and after 250 steps, the TM is in a state with a property X, and this see...
You are not comparing the same operations. You are comparing two operations that look very similar in source code, but they are very much different. `2**100` takes an integer 2, and calculates that integer raised to the 100th power using unlimited precision integer arithmetic. If you tried 2*1000000 you would get a...
null
null
when given an array [1, -6, 5, -100, 101, -8, 3, -6, 4, -90, 8], with a greedy algorithm above, it yields a result of 2. However, I think that the correct answer should be 3.
When we have an array like this: [1, -6, 5, -100, 101, -8, 3, -6, 4, -90, 8], and apply the above greedy algorithm to it, the outcome is 2 However, I think that the correct answer should be 3.
null
[![enter image description here ][1]][1] r1 and r2 both are assigned 0.05 initially. If r1 is incremented by 0.01 in this way "r1 = r1 +0.01" we have 0.060000000000000005 as answer not 0.06. [1]: https://i.stack.imgur.com/ZuE2y.png
Can anyone answer why python behaves so absurdly?
|memory-management|python|data-types|
I think the best way to explain my question would be to have sextuple (regular, context-free, Turing-recognisable, decidable, P, NP).were you fill out 1 for promblem which lies into that section, would an np problem such as chess be only 1 for NP or would also fall in decidable? Some other examples: The regular pr...
If NP problems are decidable, and decidable is subset of turning recognizable which recognizer can understand them?
|complexity-theory|time-complexity|turing-machines|
As @gnashed729 remarks, this is how [floating-point arithmetic][1] works, and it is not specific to Python. It is all clearly [explained in the Python manual][2]: - Python (like most programming languages) interprets a number such as `0.3` as a floating-point number, using the computer's built-in support for flo...
Why does Python behave so absurdly?
This is the foundation of computer arithmetic, when dealing with fractional values. (https://en.wikipedia.org/wiki/Floating-point_arithmetic.) The key reason is that numbers are represented in the binary base rather than decimal. Though $0.06$ is a short number in your world, it cannot be represented exactly by a co...
Here is a proof that context-free languages in general, not only regular ones, are not closed against making them prefix-free. Bare with me, as I will try to make it as formal as possible. --- We will demonstrate that: > **Theorem 1.** $NOPREFIX(L)$ are the $u\in L$ such that no proper prefix of $u$ is in $...
The following problem statement is given: Let $S = \{s_1, s_2, \cdots, s_n\}$ be a sequence of unique positive integers and $K$ a positive integer, where $K \ge s_i$ for every $i$ between $1$ and $n$. The goal is to find a subset of $S$ whose sum is maximum, subject to the constraint that the sum must be $\le K$. Wr...
|algorithms|approximation|greedy-algorithms|subset-sum|
Yes, this is correct, due to equivalence of nondeterministic turing machines to deterministic ones. You can try all possible certificates in exponential time.
∅ Is the empty set symbol, not a valid string. Only valid strings may be contained in a language. If you meant that L(M) = ∅ - It is not decidable: https://cs.stackexchange.com/questions/53836/etm-undecidability If you meant that L(M) contains the empty string - it is also not decidable. Suppose D is a TM that de...
null
$\emptyset$ Is the empty set symbol, not a valid string. Only valid strings may be contained in a language. If you meant that $L(M) = \emptyset$ - It is not decidable: https://cs.stackexchange.com/questions/53836/etm-undecidability If you meant that $L(M)$ contains the empty string - it is also not decidable. Sup...
Your premise is wrong. You are assuming we don't know how to compute the features on new sentences. But we do know. We construct features so that we can compute the features on any sentence whatsoever (not just the ones in the training set). For instance, one feature might be "does the sentence contain the word '...
null
Let's say we have boolean functions $f_1, \cdots, f_n$, each of which operates on pairwise disjoint variables (i.e. the variables for each function are unique to that function). Then, how can we show that $L(f_1 \oplus \cdots \oplus f_n) \geq \frac{1}{2}\sum_{i = 1}^n L(f_i)$ (where we use the De Morgan basis)? It make...
Lower Bound on Parity of Boolean Functions
|complexity-theory|space-complexity|complexity-classes|lower-bounds|boolean-complexity|
They say that protein folding is an NP-hard problem, meaning that if we could figure out how any protein folds, we could solve any NP problem in polynomial time. However, doesn't this basically destroy the field of cryptography? Like let's say I wanted to factor a large semiprime. Couldn't I convert it into a protein f...
Protein Folding and Cryptography
|complexity-theory|optimization|
I am digitizing my old books and I was wondering if I needed to buy [OCR software](https://en.wikipedia.org/wiki/Optical_character_recognition), or if the OCR software that came with my printer (Epson) would be sufficient. This made me wonder if there were any programs or software that tests the accuracy of OCR. I ...
Are there any programs out there that test the accuracy of OCR software?
|software-testing|ocr|
null
null
I understand *how* backpatching works during intermediate code generation, but I do not understand *why* it is needed. A common argument for using backpatching during intermediate code generation is as follows: Suppose the intermediate code generated is: goto L1 ... L1: When `goto L1` is gen...
Why is backpatching needed for generating actual addresses during intermediate code generation?
|compilers|code-generation|risc-v|
The CPU wants an actual address.
In the case of LLVM IR, I think the point here is not backpatching an *address*, but backpatching a *label*. If the label is "created" at the point where it is in the code, any forward jumps to it will have to be backpatched. There are other ways to define an API for building IRs, but this works. Backpatching *ad...
When emitting textual assembly code, backpatching is not strictly necessary, as long as you can predict what the label of a destination is going to be even if that destination is in the future. There are different ways to make that happen, such as numbering your basic blocks, or doing code generation from your AST o...
I have a computer architecture exam tomorrow and my professor gave us some questions for practice. I just need to clear some confusions. The first question is: <br> "a) In a Direct-Mapped Cache, modify the following Page-to-Cache address translation circuitry (attached with the post) if the Page Capacity is 1 KiWord...
Page-to-Cache mapping
|computer-architecture|virtual-memory|cache|risc-v|
If there is no calculus,we can't solve the problem like “surface area” Is there some math problem,that before the category theory invented,it can't be solved,only use category theory can slove it? if there is no such math problem,is it meens that category theory is an “abstract theory”:it can explain things clear...
Is there some math problem that must use “category theory” to solve?
|category-theory|
Why is backpatching needed during intermediate code generation? For what purposes?
In the case of LLVM IR, I think the point here is not backpatching an *address*, but backpatching a *label*. If the label is "created" at the point where it is in the code, any forward jumps to it will have to be backpatched. There are other ways to define an API for building IRs, but this works. Backpatching *ad...
null
I have a question about the DPDA. Is it possibly to have two transitions that read the same input but do different in the stack? An example would be A transition from q1 to q2 where I read input ( pop v and push nothing to the stack. And the second transition is from q1 to q3 where I read input ( pop x and push noth...
can a DPDA have two transition to different states when you pop a different symbol?
|pushdown-automata|
null
They say that [protein folding][1] is an [NP-hard][2] problem, meaning that if we could figure out how any protein folds, we could solve any NP problem in polynomial time. However, doesn't this basically destroy the field of cryptography? Suppose I want to factor a large [semiprime][3]. Couldn't I convert it into a ...