instruction stringlengths 0 29.8k ⌀ |
|---|
The Ternary Golay Code has parameters $[n,k,d]_3=[11,6,5]_3$ and thus is a linear code over $\mathbb{Z}_3=\{0,1,2\}$ with $3^6=729$ codewords. It is *perfect* so that all the Hamming spheres of radius $2$ around codewords fill the whole space $\{0,1,2\}^{11}$ with no gaps left over. This means that the code has coverin... |
One possible reason is that bitwise operations on relations would give the wrong results. For example, the code
if ((printf("%s", "hello, God, it's") == 16) &
(printf(" me, %s\n") <= 15)) {
would evaluate to *false* if both conditions are met, if logical operations returned the value of one of thei... |
One possible reason is that bitwise operations on relations would give the wrong results. For example, the code
if ((printf( "hello, %s, it's", higher_power ) == 16) &
(printf( " me, %s\n", luser ) <= 15)) {
would evaluate to *false* if both conditions are met, if logical operations returned the va... |
The question states
> "In C, the result of the || operator is always a boolean."
This is misleading. The result of both || and && is type **int**. The value of the int is either 0 or 1.
Note that the C11 standard introduced type **_Bool**, and the upcoming C23 standard goes further with primitive type **bool*... |
Is the combined set of halting and circle-free Turing machines recursively enumerable? |
null |
null |
If I understand your question correctly, you want to determine the binary representation of a floating-point number by hand. I assume you are talking about the IEEE 754 floating-point format, since this is the most common format.
You can indeed do this by successively multiplying with 2. However, just multiplying do... |
## Question Description
I’m facing a problem asking me to construct a (Determine) Turing Machine that can accept such a language:
$L = \{ w \in \{a,b\}^* | for\ any\ prefix\ in\ w, n_a(w) > n_b(w)\}$
The problem isn’t expressed in English originally. To make sure I’m translating correctly, I’ll provide some ex... |
Construct a Turing machine that accept: for any prefix in string w, $n_a(w) > n_b(w)$ |
|turing-machines|automata| |
In some languages, e.g. Ruby, an expression like:
val = call_fn() || DEFAULT_VAL;
will set val to the results of `call_fn()` if it is _truthy_ (non-zero, non-NULL, etc), or to `DEFAULT_VAL` otherwise. This can be really useful.
In C, the result of the `||` operator is always a boolean value (1 or 0).
I... |
null |
A quad-edge is a well-known data structure used to represent planar subdivisions or polyhedra. https://en.wikipedia.org/wiki/Quad-edge
The procedure to enumerate the edges works by recursively visiting edges, and for every edge, the next edge starting from the same origin and the next edge after reversal. A flag is ... |
Successive doublings is a good way, you can virtually do it mentally (double every digit modulo $10$, and if the next is $5$ or more, add a carry).
$$0.347\\0.694\\1.388\\2.776\\5.552\\11.104\\22.208\\44.416\\88.832\\177.664\\\cdots$$
So far, $0.347\approx\dfrac{177}{512}=0.010110001$.
As you noticed, the proc... |
Successive doublings is a good way, you can virtually do it mentally (double every digit modulo $10$, and if the next is $5$ or more, add a carry).
$$0.347\\0.694\\1.388\\2.776\\5.552\\11.104\\22.208\\44.416\\88.832\\177.664\\\cdots$$
So far, $0.347\approx\dfrac{177}{512}=0.010110001$.
As you noticed, the proc... |
Successive doublings is a good way, you can virtually do it mentally (double every digit modulo $10$, and if the next is $5$ or more, add a carry).
$$0.347\\0.694\\1.388\\2.776\\5.552\\11.104\\22.208\\44.416\\88.832\\177.664\\\cdots$$
So far, $0.347\approx\dfrac{177}{512}=0.010110001$. Straight multiplication by ... |
Successive doublings is a good way, you can virtually do it mentally (double every digit modulo $10$, and if the next is $5$ or more, add a carry).
$$0.347\\0.694\\1.388\\2.776\\5.552\\11.104\\22.208\\44.416\\88.832\\177.664\\\cdots$$
So far, $0.347\approx\dfrac{177}{512}=0.010110001$. Straight multiplication by ... |
I am running a simulation on my computer. I tried to multiply two polynomials $g(x), h(x)\in GF(2)[x]$, with $degree(g(x))= 8165$, and $degree(h(x))=25$. This multiplication took almost $20$ minutes on my computer.
Now, I have to multiply all $h(x)\in GF(2)[x]$ of $degree(h(x))\leq 25$ with $g(x)$. I estimated that ... |
I would not be able to get my simulation in my life time |
|time-complexity|computability|runtime-analysis|polynomial-time|polynomial-time-reductions| |
The question states
> "In C, the result of the || operator is always a boolean."
This is misleading. The result of both || and && is type **int**. The value of the int is either 0 or 1.
Note that the C11 standard introduced type **_Bool**, and the upcoming C23 standard goes further with primitive type **bool*... |
In his [FOCS2013 (Best Paper award) work][1], Aleksander Mądry gives a $\widetilde O(m^{\frac{10}{7}})$-time for exact max-flow and gives a nice survey on the existing techniques (including near-linear time for $(1+\epsilon)$-approximation in undirected graphs).
[1]: https://madry.mit.edu/docs/matching_flow.pdf |
null |
Successive doublings is a good way, you can virtually do it mentally (double every digit modulo $10$, and if the next is $5$ or more, add a carry).
$$0.347\\0.694\\1.388\\2.776\\5.552\\11.104\\22.208\\44.416\\88.832\\177.664\\\cdots$$
So far, $0.347\approx\dfrac{177}{512}=0.010110001$. Straight multiplication by ... |
null |
I once was working as a consulting company where we were writing software for a warehouse management system. One of the requirements was to generate pick lists that would optimize the loading of trucks. My manager came up with an algorithm that he thought would work. It turns out that what he came up with was really... |
A lot of misunderstanding is caused by explaining the problem as an ongoing process.
It's a lot easier to understand if one simply considers the possible states that the generals can be in.
Assume the generals have agreed that they will attack if they get at least N messages.
- B) Before both generals have recei... |
To argue in front of your boss.
[![enter image description here][1]][1]
Source: https://www.ac.tuwien.ac.at/people/szeider/cartoon/
This cartoon is originally from the famous textbook *Computers and Intractability* by Garey \& Johnson, but adapted to the current Zeitgeist.
PS: Concerning the adaption, I wou... |
Question: Given a language L, L = {⟨M, x⟩ | M(x) terminates with an empty tape}, show that Lu is m-reducible to L by finding a computable function f: Σ* -> Σ*, where for every w, w ∈ Lu if and only if f(w) ∈ L.
(Recall Lu = {⟨M, x⟩ | x ∈ L(M)})
My general understanding of m-reducibility is that if you can assume th... |
Show that Lu is m-reducible to the language L = {⟨M, x⟩ | M(x) terminates with an empty tape} |
|turing-machines|computability|undecidability|decidability| |
null |
Recall that there are when running $M(x)$, there are three possibles results:
- $M(x)$ terminates in an accepting state;
- $M(x)$ terminates in a rejecting state;
- $M(x)$ doesn't terminates.
The reduction you want is such that $x\in M(x) \Leftrightarrow M'(x')$ terminates with an empty tape, $\langle M', x'\r... |
Recall that there are when running $M(x)$, there are three possibles results:
- $M(x)$ terminates in an accepting state;
- $M(x)$ terminates in a rejecting state;
- $M(x)$ doesn't terminate.
The reduction you want is such that $x\in L(M) \Leftrightarrow M'(x')$ terminates with an empty tape, $\langle M', x'\ra... |
null |
In many Lisp dialects, there is usually an `or` operator which returns the leftmost value that is not `nil`, and stops evaluating the rest.
GNU C does have an operator which evaluates A, and returns A if A is nonzero, otherwise B, namely: `A ?: B`.
Why, in C, we don't want `||` to have this semantics because C is... |
Is it always possible to know if there's an equivalent Turing machine to a given machine such that it'll have a smaller number of states? (1-tape machine, minimizing it)
My intuition says that finding such machine in the general case is not possible, but what about just knowing if there's a simpler machine?
Is my... |
Knowing if there's an equivalent Turing machine |
|turing-machines| |
To prove that a new language is Turing-complete the authors need to show that it can simulate any other (already known) Turing-complete language.
I wonder what Turing-complete language is used more often for this task. In other words, what language is simpler to simulate? [Bitwise Cyclic Tag][1] looks very easy. Ar... |
The most theoretically useful Turing-complete language |
|turing-completeness| |
If you don't care about the number of symbols in the alphabet, then there are constructions of universal Turing machines that only use $2$ states.
The standard definition of Turing machine restricted to have a single state would force the machine to always accept or always reject, so it could only decide trivial la... |
If you don't care about the number of symbols in the alphabet, then there are constructions of universal Turing machines that only use $2$ [states][1].*
This means that every Turing machine with at least $3$ states admits an equivalent Turing machine with less states.
Turing machines with just two states can't rea... |
The simplest Turing-complete language |
null |
I am looking for an algorithm to compute the furthest point Voronoi diagram and I don't seem to be able to find anything decent. The most complete one I have found are [these slides][1] and this terribly written [wordpress site][2] with a cool tool:
[1]: https://members.loria.fr/SHornus/fpvd/slides.pdf
[2]: h... |
Algorithm for farthest point Voronoi diagram? |
|algorithms|graphs|planar-graphs|voronoi-diagrams| |
null |
I have a problem where I'm iterating through a series of tasks and each task requires that a specific file is loaded into memory. The files are not allowed to be unloaded until all of the tasks that use it are complete.
E.g. say I have 6 tasks. I will represent each task as a Python dictionary where "files" indicate... |
Algorithm for minimizing the number of resources simultaneously open while iterating through a series of tasks |
|graphs|approximation|scheduling| |
Let's suppose we have language $Y = \{a^ib^j:i,j \in N^*\}$ defined over the alphabet $\Sigma^{}_{} = \{a, b\}$
If we want to define this language $\Sigma^{*}_{}$ \ $\ Y$ such that we don't have the case of $a$ preceding all occurances of $b$, one way I found it defined is like this (following here is meant interme... |
Exists and forall in formal language definition in the case of kleene star |
|formal-languages|automata|finite-automata| |
Let's suppose we have language $Y = \{a^ib^j:i,j \in N^*\}$ defined over the alphabet $\Sigma^{}_{} = \{a, b\}$
If we want to define this language $\Sigma^{*}_{}$ \ $\ Y$ such that we don't have the case of $a$ preceding all occurances of $b$, one way I found it defined is like this:
$ \Sigma^{*}_{}$ \ $\ Y = \{w_... |
If I understand the use here correctly it's because C languages already have another operator for that: `?:`
So in C languages
```
val = call_fn() || DEFAULT_VAL;
```
would be written as
```
val = call_fn() ? call_fn() : DEFAULT_VAL;
```
or
```
tmp = call_fn();
val = tmp ? tmp : DEFAULT_VAL;
```
Depend... |
One possible reason is that bitwise operations on relations would give the wrong results. For example, the code
if ((printf( "hello, %s, it's", higher_power ) == 16) &
(printf( " me, %s\n", luser ) <= 15)) {
would evaluate to *false* if both conditions are met, if logical operations returned the va... |
One possible reason is that bitwise operations on relations would give the wrong results. For example, the code
if ((printf( "hello, %s, it's", higher_power ) == 16) &
(printf( " me, %s\n", luser ) <= 15)) {
would evaluate to *false* if both conditions are met, if logical operations returned the va... |
Imagine a Problem $A$ with input size $n$ for which you can get a proof certificate (polynomial number of bits).
Next you try to use this string to verify if your problem is solved or not.
You know that verification gets almost as good as if you'd try to verify an $NP$-problem in the sense that the verification p... |
What is the complexity of problems with randomized polynomial time verification? |
|complexity-theory|np|randomized-algorithms| |
One possible reason is that bitwise operations on relations would give the wrong results. For example, the code
if ((printf( "hello, %s, it's", higher_power ) == 16) &
(printf( " me, %s\n", luser ) <= 15)) {
would evaluate to *false* if both conditions are met, if logical operations returned the va... |
I think the direct answer is, "No, there is not a strong argument."
It seems to me that the functionality you're describing would have worked overall pretty consistently in C (if introduced at the start), and if you had been able to make your case to the creators of C at the time they might well have at least cons... |
One possible reason is that bitwise operations on relations would give the wrong results. For example, the code
if ((printf( "hello, %s, it's", higher_power ) == 16) &
(printf( " me, %s\n", luser ) <= 15)) {
would evaluate to *false* if both conditions are met, if logical operations returned the va... |
Imagine a Problem $A$ with input size $n$ for which you can get a proof certificate (polynomial number of bits).
Next you try to use this string to verify if your problem is solved or not.
You know that verification gets almost as good as if you'd try to verify an $NP$-problem in the sense that the verification p... |
One possible reason is that bitwise operations on relations would give the wrong results. For example, the code
if ((printf( "hello, %s, it's", higher_power ) == 16) &
(printf( " me, %s\n", luser ) <= 15)) {
would evaluate to *false* if both conditions are met, if logical operations returned the va... |
One possible reason is that bitwise operations on relations would give the wrong results. For example, the code
if ((printf( "hello, %s, it's", higher_power ) == 16) &
(printf( " me, %s\n", luser ) <= 15)) {
would evaluate to *false* if both conditions are met, if logical operations returned the va... |
One possible reason is that bitwise operations on relations would give the wrong results. For example, the code
if ((printf( "hello, %s, it's", higher_power ) == 16) &
(printf( " me, %s\n", luser ) <= 15)) {
would evaluate to *false* if both conditions are met, if logical operations returned the va... |
I've been working on this question for a few hours now and I've been trying to figure out the question above. My biggest problem is that I don't know what to do with the > and >= symbols when determining the language. My current work is below. Also, if you have any resources on how to adequately learn pumping lemma it ... |
Prove that L = {a^r b^q c^q} where q > 0, r >= 0 is not a regular language |
|pumping-lemma| |
null |
While working through the book Parameterized Complexity Theory of Flum and Grohe, I encountered exercise 1.42:
Let $H = (V, E)$ be a hypergraph. A basis of $H$ is a set $S$ of subsets of $V$ with the property that for all $e \in E$ there are $s_1, \dots, s_\ell \in S$ such that $e = s_1 \cup \dots \cup s_\ell$. The ... |
Fpt algorithm for hypergraph basis problem |
|algorithms|graphs|optimization|parameterized-complexity| |
While working through the book Parameterized Complexity Theory of Flum and Grohe, I encountered exercise 1.42:
Let $H = (V, E)$ be a hypergraph. A basis of $H$ is a set $S$ of subsets of $V$ with the property that for all $e \in E$ there are $s_1, \dots, s_\ell \in S$ such that $e = s_1 \cup \dots \cup s_\ell$. The ... |
While working through the book Parameterized Complexity Theory of Flum and Grohe, I encountered exercise 1.42:
Let $H = (V, E)$ be a hypergraph. A basis of $H$ is a set $S$ of subsets of $V$ with the property that for all $e \in E$ there are $s_1, \dots, s_\ell \in S$ such that $e = s_1 \cup \dots \cup s_\ell$. The ... |
|algorithms|graphs|parameterized-complexity| |
null |
|formal-languages|computability|pumping-lemma| |
In some languages, e.g. Ruby, an expression like:
val = call_fn() || DEFAULT_VAL;
will set val to the results of `call_fn()` if it is _truthy_ (non-zero, non-NULL, etc), or to `DEFAULT_VAL` otherwise. This can be really useful.
In C, the result of the `||` operator is always a boolean value (1 or 0).
I... |
In some languages, e.g. Ruby, an expression like:
val = call_fn() || DEFAULT_VAL;
will set val to the results of `call_fn()` if it is _truthy_ (non-zero, non-NULL, etc), or to `DEFAULT_VAL` otherwise. This can be really useful.
In C, the result of the `||` operator is always a boolean value (1 or 0).
I... |
In some languages, e.g. Ruby, an expression like:
val = call_fn() || DEFAULT_VAL;
will set val to the results of `call_fn()` if it is _truthy_ (non-zero, non-NULL, etc), or to `DEFAULT_VAL` otherwise. This can be really useful.
In C, the result of the `||` operator is always a boolean value (1 or 0).
I... |
Consider any arbitrary binary tree and get its postorder sequence. Now starting from the root(the right-most element in the post order sequence) construct all possible [degenerate binary trees][1]. They all would have the same postorder sequence.
An example
```
1 1 1 ... |
Yeah, that's right. You just read the sub-expressions from bottom up; but do bear in mind, there are only 7 distinct sub-expressions, not 10. They are:
$$A = a, B = b, C = A∪B, D = C^*, E = AB, F = ED, G = D∪F.$$
So, the grammar could just as well be written as:
$$A → a, B → b, C → A, C → B, D → ε, D → DC,\\E → AB, ... |
Given an array of N elements, I need to split it into k subarrays, where k can be between 2 <= k <= N. A sub-array's score is determined by:
(left boundary point - right boundary point of the subarray)^2 + max(subarray).
Find an algorithm in O(n^2) that calculates the sum of the scores of all subarrays such that ... |
is there an O(n^2) approach to this problem? |
|algorithms|arrays| |
Given an array of N elements, I need to split it into k subarrays, where k can be between 2 <= k <= N. A sub-array's score is determined by:
(left boundary point - right boundary point of the subarray)^2 + max(subarray).
eft boundary point would be the index of the element and right boundary point would be the (i... |
|algorithms|dynamic-programming|recursion|arrays| |
Given an array of N elements, I need to split it into k subarrays, where k can be between 2 <= k <= N. A sub-array's score is determined by:
(left boundary point - right boundary point of the subarray)^2 + max(subarray).
Left boundary point would be the index of the element and right boundary point would be the (... |
I believe....
According to the Church-Turing thesis: "any algorithm that can be computed in a finite length of time, can be calculated on a Turing machine". Technically making any language that can do the same thing, 'Turing Complete'.
Other computers may be faster but none can be more powerful than a Turing machin... |
Given an array $A = [a_0, …, a_{N-1}]$, let us define some notations:
- for $0\leqslant i < j \leqslant N$, $M_{ij}$ is the maximum element in $[a_i, a_{i+1}, …, a_{j-1}]$;
- for $0 < j \leqslant N$, $S(j)$ is the minimum total score of a splitting of $[a_0, …, a_{j-1}]$ into subarrays (with no condition on the n... |
Dynamic programming gives an $O(n)$ solution. Consider partitioning the array recursively to compute the scores of each possible partition. In particular, notice that
$$
OPT = \min_t \text{score}([a_1, ..., a_t]) + \text{score}([a_{t+1}, ..., a_n])
$$
This naturally leads us to a recursive approach.
min... |
{"Voters":[{"Id":154933,"DisplayName":"Krish Singal"}]} |
Given an array $A = [a_0, …, a_{N-1}]$, let us define some notations:
- for $0\leqslant i < j \leqslant N$, $M_{ij}$ is the maximum element in $[a_i, a_{i+1}, …, a_{j-1}]$;
- for $0 < j \leqslant N$, $S(j)$ is the minimum total score of a splitting of $[a_0, …, a_{j-1}]$ into subarrays (with no condition on the n... |
Dynamic programming gives an $O(n^2)$ solution. Consider partitioning the array recursively to compute the scores of each possible partition. In particular, notice that
$$
OPT = \min_t \text{score}([a_1, ..., a_t]) + \text{score}([a_{t+1}, ..., a_n])
$$
This naturally leads us to a recursive approach.
m... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.