instruction stringlengths 0 29.8k ⌀ |
|---|
|runtime-analysis|recurrence-relation| |
null |
A Turing Machine cannot accept a language.
A Turing Machine will either accept or reject a string or loop forever. We know it accepts the string because it will halt in an accepting state. It is said to reject a string, if it halts in a rejecting state.
A TM *recognises* a language, if it halts and accepts all st... |
null |
Any question that asks whether SAT with the following constraints is NP-complete or not |
null |
Are the following problems NP-complete:
* 2-or-3-in-3 SAT: where 2 or 3 literals must be true in each clause
* 1-in-3 SAT: exactly 1 literal is true in each clause
* 0-or-3-in-3 SAT: Either none or all are true
* NOT-ALL-EQUAL-3 SAT: At least 1 true, at least 1 false
* 2 SAT: Each clause has at most 2 literals
... |
null |
|hash-tables| |
null |
Given a number n, the task is to find the XOR of every number from 1 to n. Why does the following algorithm work?
1. Find the remainder of n by moduling it with 4.
2. If rem = 0, then XOR will be same as n.
3. If rem = 1, then XOR will be 1.
4. If rem = 2, then XOR will be n+1.
5. If rem = 3, then XOR will b... |
Calculating XOR of all numbers from 1 to n: Why does this method work? |
null |
given this lanauge:
$L=\left\{\langle M\rangle\right.$ : there does not exist $\mathrm{w} \in \Sigma^*$ such that M rejects $\left.\mathrm{w}\right\}$.
how can I determine whether it is in $R, R E \backslash R, \operatorname{coRE} \backslash R$, or $\overline{R E \cup c o R E}$.
I tried to prove the it is in $c... |
L = {⟨M⟩ : there does not exist w ∈$Σ^*$ such that M rejects w } is in coRE? |
|turing-machines|reductions| |
I want to find areas in a binary image that correspond to long and thin curves. In the example below, structures thinner than 3 pixels but longer than 20 pixels are highlighted. Observe that the bottom-most line is split because it locally comes in contact with the Data Matrix code. The structures need not be straight,... |
I want to find areas in a binary image that correspond to long and thin curves. In the example below, structures thinner than 3 pixels but longer than 20 pixels are highlighted. Observe that the bottom-most line is split because it locally comes in contact with the Data Matrix code. The structures need not be straight,... |
Depending on the size of N (the number of points) and M (the number of queries), it may be enough to precompute all the answers: there are no more than N*N possible lines. :-) You can represent all lines by exact slope and 0-crossing using reduced (i.e. simplified) rationals. Then search. Binary search, hashing, perfe... |
Depending on the size of N (the number of points) and M (the number of queries), it may be enough to precompute all the answers: there are no more than N*N possible lines. :-) You can represent all lines by exact slope and 0-crossing using reduced (i.e. simplified) rationals. Then search. Binary search, hashing, perfe... |
I'm confused by the use of the expressions "computable problem" and "computable function" in the context of computability theory. Are they refer to the same thing or are there differences? |
Are "computable problem" and "computable function" the same thing? |
|computability| |
Conceptually, you can always copy the local variables to the new stack frame upon entering a block, and copy back upon exit. So if you give no other constraint, the answer is yes, you can live with the last stack frame. |
They're basically the same, in informal usage. They're not necessarily exactly 100% identical.
A computable function is often defined to be a function $f:\mathbb{N}^k \to \mathbb{N}$, or a function $f:\mathbb{N} \to \{0,1\}$, or a function $f:\{0,1\}^* \to \{0,1\}$, that can be computed by some algorithm (e.g., a T... |
I am studying for my final exams in complexity theory and I came across a graph problem which I cannot fully prove that it is NP-complete. It's gist is the following:
> Assume that you have a weighted directed graph $G$ with $n$ nodes and $m$ edges, where the weight of each edge is the travel time between the two co... |
NP-completeness of graph problem |
|algorithms|complexity-theory|knapsack-problems| |
I want to find areas in a binary image that correspond to long and thin curves. In the example below, structures thinner than 3 pixels but longer than 20 pixels are highlighted. Observe that the bottom-most line is split because it locally comes in contact with the Data Matrix code. The structures need not be straight,... |
Let $G = (V, E)$ be an undirected graph. Assume the value is $v_i = 1$ for each vertex and the weight is $w_e = 1$ for each edge. Also assume the deadline is $d_i = |V| - 1$ for each vertex.
Then you can accumulate a total value $|V|$ if and only if there is an hamiltonian path in $G$. |
I want to find areas in a binary image that correspond to long and thin curves. In the example below, structures thinner than 3 pixels but longer than 20 pixels are highlighted. Observe that the bottom-most line is split because it locally comes in contact with the Data Matrix code. The structures need not be straight,... |
Since functional completeness is a kind of universality, there might be deep connections to other universal phenomena like Turing completeness. |
How does Post's theorem connect to concepts of universality and computability in theoretical computer science? |
|turing-machines| |
null |
I have 4,500 ($N$) unique items, and I want to auction each one off to the highest bidder (break ties arbitrarily).
Each item has $T$ binary traits. Since it is too complex for the $B$ bidders to specify a bid for each individual item, instead the bidders express preferences in the form of "I am willing to pay $x$ f... |
Efficient way to calculate many Dutch auctions? |
|sorting|data-compression|constraint-satisfaction| |
One reasonable way to select bids would be to formulate this as a matching problem.
Build a bipartite graph, with one left vertex per bidder and one right vertex per item. Add an edge from a bidder to each item that meets the bidder's preference, with weight $x$ (the bidder's willingness to pay). Then find a [maxi... |
given this lanauge:
$L=\left\{\langle M\rangle\right.$ : there does not exist $\mathrm{w} \in \Sigma^*$ such that M rejects $\left.\mathrm{w}\right\}$.
how can I determine whether it is in $R, R E \backslash R, \operatorname{coRE} \backslash R$, or $\overline{R E \cup c o R E}$?
I tried to prove the it is in $co... |
Let $n:=2^m$ and take the logarithm.
$$\log(T(2^m))=2\log(T(2^{m-1}))+2^m$$
or
$$S(m)=2S(m-1)+2^m.$$
By educated guess (or alternative methods), the solution is
$$S(m)=(m+S_0)2^m$$
so that
$$T(n)=2^{(\log(n)+\log(T_1))n}=\left(T_1n\right)^n$$
|
$L$ is clearly not recursive: given a Turing machine $M$, consider $\overline{M}$ the machine where you reverse accepting and rejecting states.
Then it is clear that $\langle M\rangle\in E_{TM}$ if and only if $\langle \overline{M}\rangle \in L$.
However, $L$ is indeed in $coRE$, this can be proved by [dovetailin... |
In pure aloha the if one frame is been transmitted and another is send during the transmission then the whole frames get destroyed.
Vulnerable time is the time period where there is the chance for collision.
But why is it set to 2*Tp where
Tp: Transmission time
I watch some you-tube it said It is 2*Tp because ... |
Why is vulnerable time equal to 2*Tp where Tp is Transmision time? |
|computer-networks|tcp| |
Why is vulnerable time equal to 2*Tp where Tp is Transmision time? (pure-ALOHA) |
$L$ is clearly not recursive: given a Turing machine $M$, consider $\overline{M}$ the machine where you reverse accepting and rejecting states.
Then it is clear that $\langle M\rangle\in E_{TM}$ if and only if $\langle \overline{M}\rangle \in L$.
However, $L$ is indeed in $coRE$, this can be proved by [dovetailin... |
In terms of abstract rewriting, confluence and determinism are different notions.
Let $\to$ be a binary relation on a set.
The relation $\to$ is *deterministic* if $b = c$ whenever $b \leftarrow a \to c$. The relation $\to$ is *confluent* if there is some $d$ such that $b \rightarrow^* d$ and $c \rightarrow^* d$ when... |
Depending on the size of N (the number of points) and M (the number of queries), it may be enough to precompute all the answers: there are no more than N*N possible lines. :-) You can represent all lines by exact slope and 0-crossing using reduced (i.e. simplified) rationals. Then search. Binary search, hashing, perfe... |
null |
To prove that a problem is NP-complete, one has to show that it is both (a) in NP and that it is (b) NP-hard by reducing a known NP-complete problem to it in polynomial time.
Regarding the reduction, I understand that the instance of the known NP-complete problem must be **arbitrary** to avoid loss of generalisatio... |
NP-completeness of problem based on non-arbitrary instance |
|algorithms|complexity-theory|np-complete|np-hard| |
I am studying for my final exams in complexity theory and I came across a graph problem which I cannot fully prove that it is NP-complete. It's gist is the following:
> Assume that you have a weighted directed graph, where the weight of each edge is the travel time between the two corresponding nodes. There are good... |
I am studying for my final exams in complexity theory and I came across a graph problem which I cannot fully prove that it is NP-complete. Its gist is the following:
> Assume that you have a weighted directed graph, where the weight of each edge is the travel time between the two corresponding nodes. There are goods... |
I am studying for my final exams in complexity theory and I came across a graph problem which I cannot fully prove that it is NP-complete. Its gist is the following:
> Assume that you have a weighted directed graph, where the weight of each edge is the travel time between the two corresponding nodes. There are goods... |
I am studying for my final exams in complexity theory and I came across a graph problem which I cannot fully prove that it is NP-complete. Its gist is the following:
> Assume that you have a weighted directed graph, where the weight of each edge is the travel time between the two corresponding nodes. There are goods... |
I am studying for my final exams in complexity theory and I came across a graph problem which I cannot fully prove that it is NP-complete. Its gist is the following:
> Assume that you have a weighted directed graph, where the weight of each edge is the travel time between the two corresponding nodes. There are goods... |
If you restrict yourself to *linear* contraction orders, i.e., you only contract tensors adjacent to the set of already-contracted ones, you can actually do this in polynomial time. I have recently proved this in my Master's [thesis][1]. The result follows from a fascinating yet non-trivial connection to *database join... |
Speaking of $2$ arrays $[3][4]$ vs. $4$ arrays $[2][3]$ is misleading, as it might be understood with the same storage order for all arrays.
The truth is closer to $2$ arrays of $3$ arrays of $4$ elements vs. $4$ arrays of $3$ arrays of $2$ elements, if that is understood as the storage order.
Then the commutativ... |
Speaking of $2$ arrays $[3][4]$ vs. $4$ arrays $[2][3]$ is misleading, as it might be understood with the same storage order for all arrays.
The truth is closer to $2$ arrays of $3$ arrays of $4$ elements vs. $4$ arrays of $3$ arrays of $2$ elements, if that is understood as the storage order.
Then the commutativ... |
tl;dr: If I have integers $k$ and $d$ and a set of $k$ strings $x_1, ..., x_k$, all of the same length $L \leq kd$, how can checking if a given string $z$ is a center string - that is, it has a Hamming distance less than or equal to $d$ from every one of the $x_i$ - be done in $\mathcal{O}(kd)$?
Long version:
I a... |
How Can the Bounded Search Tree Algorithm for Closest String run in $\mathcal{O}(kd)$ per node? |
|strings|hamming-distance| |
To prove that a problem is NP-complete, one has to show that it is both (a) in NP and that it is (b) NP-hard by reducing a known NP-complete problem to it in polynomial time.
Regarding the reduction, I understand that the instance of the known NP-complete problem must be **arbitrary** to avoid loss of generalisatio... |
A **specific** instance is never NP-hard. The concept of NP-hardness only applies to languages (classes of instances, if you will).
If your reduction from $A$ to $B$ is $f$, then $f$ is a function from the set of instances of $A$ to the set of instances of $B$. The function does not need to be injective nor surjecti... |
I don't think they are formally related. Post's theorem concerns Boolean functions $\mathbb{B}^n \to \mathbb{B}$ (where $\mathbb{B} = \{0, 1\}$), which are always trivially computable by a Turing machine.
Differing concrete domains aside, in the abstract, Post's theorem is about finite lists of Boolean functions, wh... |
null |
No. You need a [heap](https://en.wikipedia.org/wiki/Memory_management#HEAP), for dynamically sized data structures like linked lists, trees, graphs, etc. You can't simulate that with a stack in the way you're looking for.
(I am assuming that each element stored in the stack is fixed size, e.g., 64 bits, and that e... |
null |
I'm a young programmer that was interested by machine learning. I watched videos and read articles about the theory behind simple neural networks. However, I can't manage to set it up correctly. I've already managed a simple linear regression AI but I can't manage to make it deeper. I wanted to make An AI that could ac... |
Create a simple Neural Network of n layers in python from scratch with numpy to solve XOR example problem using Batch Gradient Descent |
|machine-learning|neural-networks|python|gradient-descent| |
null |
null |
I have a table like this (more specifically a nested dictionary)
| img | a | b | c | d | e |
|-------|---|---|---|---|---|
| img1 | 0 | 0 | 1 | 0 | 1 |
| img2 | 3 | 1 | 0 | 0 | 2 |
| img3 | 4 | 0 | 0 | 0 | 1 |
| img4 | 2 | 2 | 0 | 0 | 0 |
| img5 | 0 | 0 | 0 | 0 | 2 |
| img6 | 2 | 2 | 0 | 0 | 0 |
| im... |
Is there an algorithm for finding rows that have same sum of column values up to a threshold value? |
|algorithms|databases| |
I have a table like this (more specifically a nested dictionary)
[![enter image description here][1]][1]
I need to add all the column names upto a threshold value, I need those rows which would give me the same sum for all columns.
for example, If I keep 5 as a threshold then it should give rows which sums upto ... |
tl;dr: If I have integers $k$ and $d$ and a set of $k$ strings $x_1, ..., x_k$, all of the same length $L \leq kd$, how can checking if a given string $z$ is a center string - that is, it has a Hamming distance less than or equal to $d$ from every one of the $x_i$ - be done in $\mathcal{O}(kd)$?
Long version:
I a... |
I do not know if this question makes sense
BUT
AX has two halves al and ah but the higher halves of EAX and RAX are not addressable.
When IMUL instruction is executed *e.g. IMUL r/m16* the os uses ax and dx registers:
*DX:AX = AX*r/m16*
This made me question why is using two registers necessary for this in... |
About registers and IMUL |
|computer-architecture|assembly| |
I do not know if this question makes sense
BUT
AX has two halves al and ah but the higher halves of EAX and RAX are not addressable.
When IMUL instruction is executed *e.g. IMUL r/m16* the os uses ax and dx registers:
*DX:AX = AX*r/m16*
This made me question why is using two registers necessary for this in... |
Please see Theorem 1 from the [original paper][1]. The distance of $z$ to $x_i$'s can be updated in $O(k)$ time.
Note that $z$ might not necessarily be chosen from the given set of strings $x_1 , \dotsc, x_k$. So, the algorithm change the string $z$ at one position at each step of the recursion. Since only one alph... |
Please see Theorem 1 from the [original paper][1]. The distance of $z$ to $x_i$'s can be updated in $O(k)$ time.
Note that $z$ might not necessarily be chosen from the given set of strings $x_1 , \dotsc, x_k$. So, the algorithm change the string $z$ at one position at each step of the recursion. Since only one alph... |
Please see Theorem 1 from the [original paper][1]. The distance of $z$ to $x_i$'s can be updated in $O(k)$ time.
Note that $z$ might not necessarily be chosen from the given set of strings $x_1 , \dotsc, x_k$. So, the algorithm change the string $z$ at one position at each step of the recursion. Since only one alph... |
I have a table like this (more specifically a nested dictionary)
| img | a | b | c | d | e |
|-------|---|---|---|---|---|
| img1 | 0 | 0 | 1 | 0 | 1 |
| img2 | 3 | 1 | 0 | 0 | 2 |
| img3 | 4 | 0 | 0 | 0 | 1 |
| img4 | 2 | 2 | 0 | 0 | 0 |
| img5 | 0 | 0 | 0 | 0 | 2 |
| img6 | 2 | 2 | 0 | 0 | 0 |
| im... |
null |
null |
Trying to solve the zero-sum problem described [here][1], where two opponent players at each turn can choose to collect 1, 2 or 3 stones with different values, with the objective of getting more points at the end of the game (and assuming each player is playing optimally).
All presented solutions based on recursion... |
|algorithms|dynamic-programming|board-games|memoization| |
<!-- Well actually I did take into account both players' actions, as a every recursion step I check for the best score from that position on, assigning that score to either player alternating between them. Something like: Best_score_from_pos(pos, alice) = max( 1 stone + Best_score_from_pos(pos+1, bob), 2 stones + Best_... |
**this is a question I got from a test that we had before**
Let there be X, a subgroup of languages above $\Sigma $ such that X isn't empty nor all of the langauges in $\Sigma $ we need to say if the language L = {< M >| L(M) $\in$ X} is decidable.
In the answer they said that there is an X, which is X = $P(\Sig... |
Question regarding rice theorem |
|turing-machines|computability|undecidability|rice-theorem|decidability| |
Vertex cover for comparability graphs is solvable in P-time:
1. Comparability graphs are (strongly) perfect ("Strongly Perfect Graphs", Berge & Duchet, 1984)
2. Independent set is P-time on perfect graphs (https://en.wikipedia.org/wiki/Perfect_graph)
3. The complement of an independent set is a vertex cover, an... |
null |
null |
They're basically the same, in informal usage. They're not necessarily exactly 100% identical.
A computable function is often defined to be a function $f:\mathbb{N}^k \to \mathbb{N}$, or a function $f:\mathbb{N} \to \{0,1\}$, or a function $f:\{0,1\}^* \to \{0,1\}$, that can be computed by some algorithm (e.g., a T... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.