instruction stringlengths 0 29.8k ⌀ |
|---|
Explain meaning of states and transitions for DFA that accepts two binary words (a,b) with b = 5a |
|finite-automata| |
I am interested in the following problem
> Input: A boolean function F with n boolean inputs and m boolean outputs.
>
> Output: A circuit C implementing F such that C has as few gates as possible.
The function F could either be given as a boolean truth table, or more likely, another circuit D.
I realize tha... |
null |
null |
First look at the second component only. This represents a finite state automaton for strings that have a binary value that is a multiple of five.
The states are the value of the string up to now, mod 5.
We move from state $x$ with bit $b$ to state $2{\cdot}x+b\pmod 5$.
This ensures that $b$ is indeed a multiple of ... |
Here is a popular proof of the halting problem theorem:
Suppose there exist a procedure h(x, y) so that for any procedure p(x) and any data d, the execution of h(p, d) will halt, where halt means return by a "return" statement so a system crash means doesn't halt, and if h(p, d) returns 1 then the execution of p(d) ... |
null |
The reason you are provided that information is that, without this extra promise, it is not possible to sort in linear time. With this extra promise, it *is* possible to sort in linear time.
It's your exercise, so I will leave it to you to come up with the strategy to sort such an array in linear time. Once you've... |
If your goal is to minimize the maximum absolute difference of each pair, I suggest trying to explore [greedy algorithms](https://cs.stackexchange.com/questions/tagged/greedy-algorithms?tab=Votes). In particular, suppose the arrays are presented in sorted order, and suppose for the moment that there are no duplicates,... |
{"Voters":[{"Id":755,"DisplayName":"D.W."}]} |
null |
A completely general solution for this is difficult to achieve if a wider floating-point format with at least twice the number of significand bits is not available. Normally, on common system platforms using C or C++ one could just use `float rem = (float) fmod ((double)a * (double)b, 360.0);` with `float` mapped to IE... |
As pointed by @D.W., Theorem 2 from the link https://www.planetmath.org/conjugacyclassesinthesymmetricgroupsn has a proof for the existance of such $\tau$.
In essence, consider two cycles $\pi$ = ($a_1$ ... $a_n$) and $\sigma$ = ($b_1$ ... $b_n$). We can build $\tau$ as the permutation that moves each $b_i$ to $a_i$... |
Hoare Triple formalizes program correctness, which contains postcondition, program and precondition such as $\vdash P \{Q\} R$
Provided code snippet:
i := 0;
s := 0;
while i < N do
s := s + max(arr[i]);
i := i + 1;
od
The program's goal is to compute the **sum** of the max... |
|hoare-logic|imperative-programming|sequential-circuit| |
|np-complete|3-sat|schaefers-dichotomy| |
I agree with @OmG that the table is wrong.
However, $\mathbb{P}(B\mid A)$ must be equal to $\mathbb{P}(B)$ and not $1$.
**Intuitively:** as @OmG said, $\mathbb{P}(A)=1$ means that under $\mathbb{P}$ the event $A$ is not informative therefore you will not update the probability of $B$ after conditioning on $A$ and... |
null |
null |
"Lookahead" is an aspect of a particular parsing algorithm, and might be different for different parsing algorithms using the same grammar. You can't talk about lookahead without specifying which parsing algorithm is in use.
If you are using a top-down LL parsing algorithm, parsing decisions need to be made very ear... |
This [post](https://cs.stackexchange.com/q/19582/157195) introduces a new variant of 3-SAT called EQUAL-3-SAT, where the number of 3-Literal clause is equal to the number of variable.
>Consider the 3-SAT problem where the formula is in conjunctive normal form and we restrict the Boolean formulas such that the number... |
This [post](https://cs.stackexchange.com/q/19582/157195) introduces a new variant of 3-SAT called EQUAL-3-SAT, where the number of 3-Literal clause is equal to the number of variable.
>Consider the 3-SAT problem where the formula is in conjunctive normal form and we restrict the Boolean formulas such that the number... |
null |
What is the optimal time complexity for an algorithm that solves the Longest Increasing Subsequence problem?
I am aware of the O(n log n) algorithm mentioned in textbooks (and on the [Wikipedia article][1]). Can we do better? Is it possible to solve this problem in O(n) time?
[1]: https://en.m.wikipedia.org/... |
Longest Increasing Subsequence in linear time? |
|algorithms| |
Say they are two tokens, A and B. A has probability weight 0.99 (and B has 0.01). If I want to encode the sequence "AAA", wouldn't the binary encoding just be "0"? And wouldn't that be the same for encoding "AA", or "AAAA", or an number of A's? How is the decoder supposed to know how many A's are sent when all it recei... |
An Arithmetic Encoding's length being ambiguous? |
|arithmetic|data-compression|encoding-scheme|communication-protocols| |
Arithmetic coding tries to get close to the theoretical maximum. Getting closer takes more effort. So two encoders will give different results, depending how much effort they put into the compression.
The easiest way to understand it properly is to write a decoder. It has to decode one A, two As, ..., thousand As, ... |
Yes - you need to be able to indicate EOF (and EOF is obviously meaningful). Note that you may have a natural message boundary in terms of decoding; for example, if you are writing to a file then the file has a size and thus the information can be encoded in a trailer (e.g., how many of the final decoded characters sho... |
null |
Suppose we are given an array-based list data structure. Suppose that its initial capacity is
$m > 0.$ When appending an element to the end of the list, if the list is full, we extend its capacity by $d > 0$ array components, copy the old content, and finally append the element. Suppose we are to append $n \geq m$ el... |
A decidable language must be recognizable.
Unrecognizable languages must be undecidable?
I want to know more about the relation of undecidability and unrecognizability |
Unrecognizable languages must be undecidable? |
|turing-machines|computability|undecidability|decidability|turing-recognizable| |
One of the most applicable basic laws of basic logic is the law of contraposition: $(P \rightarrow Q) \leftrightarrow (\neg Q \rightarrow \neg P)$.
Therefore, if you know decidable languages must be recognizable, its contrapositive readily follows: languages that are not recognizable can not be recognizable.
For ... |
One of the most applicable basic laws of basic logic is the law of contraposition: $(P \rightarrow Q) \leftrightarrow (\neg Q \rightarrow \neg P)$.
Therefore, if you know decidable languages must be recognizable, its contrapositive readily follows: languages that are not recognizable can not be decidable.
For a m... |
Here is a pipeline diagram with no bypasses:
[![enter image description here][1]][1]
The five colors indicate the five stages; fetch (F), decode (D),
execute (X), memory (M), and writeback (W). With no bypasses, `sw`
stalls in decode until `add` has written the value of `$t1`.
Here is the situation if we ass... |
null |
null |
Instructions are atomic and not splittable in any model of the
computation. For any sequence of instructions, it can be assumed that
the previous instruction has finished before the next instruction in
the sequence runs. However, many optimization techniques either
overlap instructions or split them into many micro... |
**Short answer:**
Current computers are digital, and even binary, i.e. they represent numbers as strings of bits, and bits are "encoded" using some physical phenomenon such as electric voltages. Typically, the physical phenomenon can take two ranges of value that can be discriminated by comparison to a fixed thresho... |
How could the add instruction stall before it has been decoded (D)? At
that point, it is not known that there is a data hazard via `$t2` so
no stall is possible. So the correct sequence is:
F D stall stall stall E M W
Afaict, three stall cycles are required because "You can read an
operand from the registe... |
First look at the second component only. This represents a finite state automaton for strings that have a binary value that is a multiple of five.
The states are the value of the string up to now, mod 5.
We move from state $x$ with bit $d$ to state $2{\cdot}x+d\pmod 5$.
This ensures that $b$ is indeed a multiple of ... |
From my understanding, the general implementation of an adjacency list is using a hashtable with vertices as keys and linked lists to as values in the hashtable to represent the adjacent vertices of the key. It is also said that the time complexity of finding all the neighbours of a given vertex in the graph using the ... |
Confusion about adjacency list graph representation |
|graphs| |
null |
Given what *we know*, which of the following scenarios are possible:
1. There exist algorithms which are in-fact Ptime algorithms for NP-Complete problems, but which cannot be proved to work.
2. 1. and there are no Ptime algorithms for NP-Complete problems which can be proved to work.
3. 2. and it cannot be proved... |
Alternative outcomes of P versus NP |
|np-complete|complexity-classes| |
null |
Your answer: Any problem that is NP-hard, that is today believed not to be in NP, but that actually _can_ be proved to be in NP (except for the fact that nobody has yet been able to do so).
Obviously if P = NP then any problem that can be proved to be in NP is actually in P. |
OK, so this is painful. I haven't read your book, but it looks like the authors are trying to appropriate [Montague Grammar](https://en.wikipedia.org/wiki/Montague_grammar) for their examples but they don't quite know what they're doing. So briefly, Montague Grammar is an approach to the semantics of natural languages ... |
Suppose we are given an array-based list data structure. Suppose that its initial capacity is
$m > 0.$ When appending an element to the end of the list, if the list is full, we extend its capacity by $d > 0$ array components, copy the old content, and finally append the element. Suppose we are to append $n \geq m$ el... |
This [post](https://cs.stackexchange.com/q/19582/157195) introduces a new variant of 3-SAT called EQUAL-3-SAT, where the number of 3-Literal clause is equal to the number of variable.
>Consider the 3-SAT problem where the formula is in conjunctive normal form and we restrict the Boolean formulas such that the number... |
null |
The proposirional logic is based on 3 schema of axioms of which (A1) is:
(A1) B ⇒ (C ⇒ B)
Then, for any 2 axioms p and q, p ⇒ (q ⇒ p) is an instance axiom of (A1). We can have q ⇒ p by a step of MP as we have p. We can have p ⇒ q in the same manner. So, we have p ⇔ q, that is, all axioms are equivalent. But can we... |
Can we accept that all axioms are equivalent? |
|logic| |
The proposirional logic is based on 3 schema of axioms of which (A1) is
B ⇒ (C ⇒ B). Then, for any 2 axioms p and q, p ⇒ (q ⇒ p) is an instance axiom of (A1). We can have q ⇒ p by a step of MP as we have already p. We can have p ⇒ q in the same manner. So, we have p ⇔ q, that is, all axioms are equivalent. But can we... |
null |
Problem: Given an integer n, give a semi-prime number of n digits (that is a number which is the product of exactly two primes). For n = 200 for example, it is reasonably easy to find two 100 digit primes and multiply them, but proving that their product is the product of exactly two primes is very hard.
Or: Given ... |
Usually vertices can be represented with consecutive integers, then you can just use an array instead of a hash table.
If you insist on using a hash table have a look at [perfect hashing][1]
[1]: https://en.wikipedia.org/wiki/Perfect_hash_function |
null |
Reference from here <https://cs.stackexchange.com/questions/6167/if-a-language-is-non-recognizable-then-what-about-its-complement>
There exist complementary languages of unrecognizable languages that are recognizable, and there exist complementary languages of unrecognizable languages that are undecidable.
If a lan... |
If a language is undecidable, then its complementary language must also be undecidable? |
|turing-machines|computability|undecidability|decidability|turing-recognizable| |
I have frequently seen two different definitions of polynomial-time reduction. In the following let $A, B \subseteq \Sigma^*$ be decidable problems. I will try to formulate the definitions in my own words:
Definition 1: $A \le_{p_1} B$ iff there exists a polynomial-time computable function $f\colon \Sigma^*\to\Sigma... |
Correct defintion polynomial-time reduction |
|complexity-theory|np-complete|reductions|complexity-classes| |
null |
If $A(x)$ is an algorithm deciding $x\in L^c$, then $\lnot A(x)$ is an algorithm deciding $x\in L$.
To be more pedantic, by $\lnot A(x)$ I mean the algorithm that executes $A(x)$ and if that accepts (resp. rejects) then it rejects (resp. accepts). In a programming language it's likely something like `bool not_a(stri... |
If $A(x)$ is an algorithm deciding $x\in L^c$, then $\lnot A(x)$ is an algorithm deciding $x\in L$.
To be more pedantic, by $\lnot A(x)$ I mean the algorithm that executes $A(x)$ and if that accepts (resp. rejects) then it rejects (resp. accepts). In a programming language it's likely something like `bool not_a(stri... |
Suppose $G=(V,E)$, let $\delta(u,v)$ as shortest path between any pair $u,v\in V$. Also there is no negative cycle in $G$. Can we conclude that
$$\sum_{u\in V}\sum_{v\in V}\delta(u,v)\geq0\;\;?$$
I try to find a counter example but I guess that it's true because if $\sum_{u\in V}\sum_{v\in V}\delta(u,v)<0$ there i... |
Summation over shortest path lengths |
|algorithms| |
Suppose graph $G=(V,E)$, let $\delta(u,v)$ as the shortest path between any pair $u,v\in V$. Also there is no negative cycle in $G$. Can we conclude that
$$\sum_{u\in V}\sum_{v\in V}\delta(u,v)\geq0\;\;?$$
I try to find a counter example but I guess that it's true because if $\sum_{u\in V}\sum_{v\in V}\delta(u,v)<... |
What you have discovered is that any two true propositions are logically equivalent (you do not need them to be axioms in your argument, only that they hold).
What may be confusing is that the truth value of $p \Rightarrow q$ has nothing to do with the *meaning* of $p$ and $q$, it only depends on the truth values of... |
I'm studying algorithms on the very famous book "Introduction to Algorithms" by Cormen, Leiserson, Rivest, and Stein.
and I'm looking at the algorithms for finding the maximum and minimum elements in a binary search tree .
In the book obviously such a tree is described as follows:
> "We can represent such a tree ... |
Querying a binary search tree, find maximum |
|algorithms|binary-trees| |
Modern cpus have deep pipelines with 20 stages or more. Attempting
full forwarding would require far too many bypasses to be
practical. For example, if the depth is 20 the first stage would be
connected to 19 bypasses, the second 18 bypasses, the third 17
bypasses, and so on. This would consume way too much silicon... |
Suppose directed graph $G=(V,E)$, let $\delta(u,v)$ as the shortest path between any pair $u,v\in V$. Also there is no negative cycle in $G$. Can we conclude that
$$\sum_{u\in V}\sum_{v\in V}\delta(u,v)\geq0\;\;?$$
I try to find a counter example but I guess that it's true because if $\sum_{u\in V}\sum_{v\in V}\de... |
null |
No. Try an example. The loop terminates when x.right == NIL. This is not the same as x == NIL. |
Definition 1 is a [polynomial-time many-one reduction](https://en.wikipedia.org/wiki/Many-one_reduction), also known as a Karp reduction. Definition 2 is a [Cook reduction](https://en.wikipedia.org/wiki/Polynomial-time_reduction#Turing_reductions).
NP-completeness is defined with respect to Karp reductions. If you... |
{"Voters":[{"Id":755,"DisplayName":"D.W."}]} |
Yes. Given any formula with more clauses than variables, pad with extra clauses of the form
$$(x_t \lor x_u)$$
where $x_t,x_u$ are fresh new variables used only in that clause. You can verify that in this way you can add enough padding to meet the "EQUAL" requirement. You should be able to take it from here. |
Given what *we know*, which of the following scenarios are possible:
1. There exist algorithms which are in-fact Ptime algorithms for NP-Complete problems, but which cannot be proved to work.
2. 1. and there are no Ptime algorithms for NP-Complete problems which can be proved to work.
3. 2. and it cannot be proved... |
null |
null |
null |
null |
Let's say we are looking at the decimal language $L_6$ where $$\Sigma = \{ 0,1,2,3,4,5,6,7,8,9 \}$$ and $L_6$ accepts an integer w if w is a multiple of 6. I'm trying to find the regular expression for this regular language or prove that it is non-regular.
I think that the language is regular since this is an inte... |
What is a regular expression that describes whether an integer w is a multiple of 6? |
|regular-languages|regular-expressions| |
null |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.