instruction
stringlengths
0
29.8k
⌀
Consider the following schedule: ```python for k = 1, 2, 3, 4...: T_k = 2^k for all programs p ordered by increasing length: if floor(T_k 2^{-l(p)}) > 0: run p for T_k 2^{-l(p)} steps if p has halted (on its own) and the output string matches the target: return p else: br...
I think that I have found an issue with the proof of the halting problem, which would cause the entire proof to be invalid. <br> To ensure I understand, here is Turing's proof of the halting problem being unsolvable. Proof: ----- Assume the function $h(x,y)$ determines whether the function $y(x)$ halts on input...
Halting problem logic must be wrong
|turing-machines|proof-techniques|halting-problem|
Your analysis of $L(L)$ is not complete. Indeed, if we assume $L(L)$ loops this implies that $L(L)$ runs in less that $n$ steps, thus $L(L)$ does not loop. Hence *our assumption* $L(L)$ loops is false. We conclude $L(L)$ must halt. Now if we assume $L(L)$ halts in $<n$ steps, we again get a contradiction (because ...
I have two non-convex polygon which intersect one another. I have written program years ago to find union polygons. I described that I has been used algorithm Weiler-Atherton. But in Wikipedia I found that Weiler–Atherton algorithm is for clipping - is Weiler-Atherton for polygon union or I have mistaken the name?<br> ...
Polygon union with arcs
|algorithms|graphics|
I have been on this problem for very long time, Lets assume we have a shopping list eg:`{milk,bread,coke,orange,apple,..}` and the shop only sells pack of thing and not individual things eg: `[{milk, bread}, {bread,orange} , {orange,apple} ...]`. Given the cost of each package. Is there any algorithm to minimize the co...
Algorithm to optimise the cost to choose a subset of array
|time-complexity|dynamic-programming|
Using "seconds" is not very well defined, so I'll use the usual "steps" instead. The typical strategy creating a machine for $l$ is to have it simulate $y(x)$ for up to $n$ steps. If the simulation finishes, then it returns true, otherwise it returns false. If you try to diagonalize against this in the same way as t...
What is the time complexity of the best-known algorithm to search for the largest complete bipartite subgraph (not induced subgraph, since not all edges have to be considered) in a given graph? A complete bipartite graph $G = (V, E)$ can be partitioned into two subsets $V_1$ and $V_2$ such that each vertex of $V_1...
Search for complete bipartite subgraph of graph
Is there any proof or reference or intuition for the following theorem related to AAD: Any function f of n variables f(x1,...,xn) can be differentiated with respect to every variable xi at a computational cost that does not exceed 4 times the complexity of one computation of f. Thank you
Automatic differentiation - Upper bound time
|algorithms|time-complexity|
Using "seconds" is not very well defined, so I'll use the usual "steps" instead. The typical strategy creating a machine for $l$ is to have it simulate $y(x)$ for up to $n$ steps. If the simulation finishes, then it returns true, otherwise it returns false. If you try to diagonalize against this in the same way as t...
null
null
If ```K = {<<M>> | L(M) has at least 1 word}```, then does K belong to the class of recursive enumerable (RE) languages or its complement? I'm a bit confused, because if it is RE, then we'd have a TM W that semidecides it, but even for some language, ```L(M)```, that does halt for at least a word, we don't know whic...
Recursive enumerable class or its complement?
|turing-machines|recursively-enumerable|
If ```K = {<<M>> | L(M) has at least 1 word}```, then does K belong to the class of recursive enumerable (RE) languages or its complement? I'm a bit confused, because if it is RE, then we'd have a TM W that semidecides it, but even for some language, ```L(M)```, that does halt for at least a word, we don't know whic...
I have a matrix with three possible elements: A, B and C. The size of the matrix could be a maximum of 15x16. $$ \begin{bmatrix} A & A & C & A\\ A & C & B & C\\ A & C & B & C\\ A & A & C & A \end{bmatrix} $$ I need create a second matrix with the same size but different types. I need to cover all Cs with a...
Having a 2D matrix with three typed elements, how to efficiently cover one of the types and NOT cover the other one?
|algorithms|matrices|
At one level, the answer to "why not" is "because that's not the definition". In mathematics, we define certain concepts and then explore them. At another level, it's because such a variation would not add any new knowledge or create any new concepts. In particular, consider the following two versions of what you ...
|algorithms|matrices|python|
null
This is the (weighted) [set cover problem](https://en.wikipedia.org/wiki/Set_cover_problem). It is NP-hard, so there is not likely to be any efficient algorithm that works on all problem instances. There are various methods to deal with this: e.g., heuristic algorithms whose worst-case running time is exponential (e....
The question is to convert the following regular expression to an NFA: [![enter image description here][1]][1] [1]: https://i.stack.imgur.com/8qEjt.png I know that the symbol phi in Theory Of Computation means an empty set. But what does phi^* mean?
Can anyone help me understand this Theory of Computation question and help me solve it?
|automata|finite-automata|regular-expressions|
How to convert the regular expression Ø* to an NFA?
null
[Directed Graph Hashing (Helbling 2020)](https://arxiv.org/abs/2002.06653) described a method of structural hashing cyclic directed graphs. If I understand it correctly, first it reduces the graph to the condensation graph in which cycles are collapsed into single nodes. The condensation graph is acyclic and hence i...
#### Considering the runtime analysis (with the master theorem) of the function below $T(n) = 12T(\frac{n}{4}) + 2\sqrt{n} + \log^4(n)$. --- As I could not figure out a way to get the equation in the form $T(n)=aT(\frac{n}{b}) + \theta(n^d)$, I aimed to get the equation in the form of $T(n)=aT(\frac{n}{b})+\the...
null
I read [this article][1], mentioning that either here, or StackOverflow would be the best places to ask generic machine learning questions, however, if the question isn't programming specific with a minimal reproducible example, the mod's at S.O. can't wait to shut you down pretty quick, so figured I'd try here first. ...
Reinforcement Learning Reward Function for Optimizing Golf Aim?
|machine-learning|reinforcement-learning|
I read [this article][1], mentioning that either here, or StackOverflow would be the best places to ask generic machine learning questions, however, if the question isn't programming specific with a minimal reproducible example, the mod's at S.O. can't wait to shut you down pretty quick, so figured I'd try here first. ...
$A$ is an array of length $n$ \ $B$ is an $n*n$ matrix \ I want to return an array C of size n such that: \ $C_{i} = \sum_{j=1}^{n} max(0, a_i - b_{ij}) $ In pseudocode it could be like below ``` for i = 1 to n: C[i] = 0 for j = 1 to n: C[i] += max(0, a[1] - b[i,j]) ``` this run...
Is there a faster way to solve the following problem?
|algorithms|time-complexity|
That's not possible. You have to read in the entire $B$ matrix to determine the correct answer, which fundamental requires $O(n^2)$ time.
$A$ is a $m*n$ matrix \ $B$ is an $n*n$ matrix I want to return matrix C of size m*n such that: \ $C_{ij} = \sum_{k=1}^{n} max(0, a_{ij} - b_{jk}) $ In pseudocode it could be like below ``` for i = 1 to m: for j = 1 to n: C[i,j] = 0 for k = 1 to n: C[i,j] += max(0, a[i,j]...
Is there a possibility to convert the following problem into divide and connquer
|algorithms|time-complexity|divide-and-conquer|
In Turing's proof, $H$ is a function that is obviously computable if $h$ (The putative halting decider function) is computable. The fact that $H$ causes a halting decider to "trip up" is a fundamental aspect of the proof – but conversely, that $H$ uses a putative halting decider is a fundamental aspect of the proof. Yo...
{"Voters":[{"Id":153410,"DisplayName":"Macosso"}]}
@rici wrote a very good answer. I actually intended to write a comment but I write it as answer instead. I can think of only these reasons: first POSIX as mentioned before. Second a misunderstanding. Third, formal language theory could have influenced it. **For the first reason,** I think, the best way of impleme...
null
@rici wrote a very good answer. I actually intended to write a comment but I write it as answer instead. I can think of only these reasons: first POSIX as mentioned before. Second a misunderstanding. Third, formal language theory could have influenced it. **For the first reason,** I think, the best way of impleme...
I think that I have found an issue with the proof of the halting problem, which would cause the entire proof to be invalid. <br> To ensure I understand, here is Turing's proof of the halting problem being unsolvable. Proof: ----- Assume the function $h(x,y)$ determines whether the function $y(x)$ halts on input...
In Turing's proof, $H$ is a function that is obviously computable if $h$ (The putative halting decider function) is computable. The fact that $H$ causes a halting decider to "trip up" is a fundamental aspect of the proof – but conversely, that $H$ uses a putative halting decider is a fundamental aspect of the proof. Yo...
null
$A$ is an array of length $n$ \ $B$ is an $n\times n$ matrix \ I want to return an array C of size n such that: \ $$C_{i} = \sum_{j=1}^{n} \max(0, a_i - b_{ij}) $$ In pseudocode it could be like below ``` for i = 1 to n: C[i] = 0 for j = 1 to n: C[i] += max(0, a[1] - b[i,j]) ``` ...
A key observation is that all $i$ problems are completely independent, and you need to compute $n$ times a sum of the form $$s=\sum_{j=1}^n\max(0,a-b_j).$$ With $a=0$ and all $b_j<0$, we get the even simpler form $$s=-\sum_{j=1}^nb_j$$ which is a sum of $n$ terms and takes $\Omega(n)$ additions. (If paralleliz...
A key observation is that all $i$-problems are completely independent, and you need to compute $n$ sums of the form $$s=\sum_{j=1}^n\max(0,a-b_j).$$ With $a=0$ and all $b_j<0$, we get the even simpler form $$-s=\sum_{j=1}^nb_j$$ which is a sum of $n$ terms and takes $\Omega(n)$ additions. (If parallelized, thi...
null
A key observation is that if $i$-problems are completely independent, you need to compute $n$ sums of the form $$s=\sum_{j=1}^n\max(0,a-b_j).$$ With $a=0$ and all $b_j<0$, we get the even simpler form $$-s=\sum_{j=1}^nb_j$$ which is a sum of $n$ terms and takes $\Omega(n)$ additions. (If parallelized, this can...
That's not a phi symbol (phi is written either $\phi$ or $\varphi$, and the uppercase version is $\Phi$), but you are right that $\emptyset$ denotes the empty set. The star symbol is known as the [Kleene Star](https://en.wikipedia.org/wiki/Kleene_star) and $A^*$ is the set containing the empty word (denoted by $\var...
[According to NIST:][1] >The worst case for Huffman coding (or, equivalently, the longest Huffman coding for a set of characters) is when the distribution of frequencies follows the Fibonacci numbers. For this and other relations see [Alex Vinokur's note on Fibonacci numbers][2], Lucas numbers and Huffman codes. ...
null
The question is to convert the following regular expression to an NFA: $\emptyset^*$. [1]: https://i.stack.imgur.com/8qEjt.png I know that the symbol phi in Theory Of Computation means an empty set. But what does phi^* mean?
How to convert the regular expression $\emptyset^*$ to an NFA?
In Turing's proof, $H$ is a function that is obviously computable if $h$ (The putative halting decider function) is computable. The fact that $H$ causes a halting decider to "trip up" is a fundamental aspect of the proof – but conversely, that $H$ uses a putative halting decider is a fundamental aspect of the proof. Yo...
A key observation is that if $i$-problems are completely independent, you need to compute $n$ sums of the form $$s=\sum_{j=1}^n\max(0,a-b_j).$$ With $a=0$ and all $b_j<0$, we get the even simpler form $$-s=\sum_{j=1}^nb_j$$ which is a sum of $n$ terms and takes $\Omega(n)$ additions. (If parallelized, this can...
null
null
A finite automaton has no memory other than which state is the current state. The strings in the language consist of some substring, then another substring, then the reverse of the first substring. One way to recognize this language would be to check whether the end of the string matches the start of the string, whi...
$A$ is an array of length $n$ \ $B$ is an $n\times n$ matrix \ I want to return an array C of size n such that: \ $$C_{i} = \sum_{j=1}^{n} \max(0, a_i - b_{ij}) $$ In pseudocode it could be like below ``` for i = 1 to n: C[i] = 0 for j = 1 to n: C[i] += max(0, a[1] - b[i,j]) ``` ...
null
null
While the worst-case complexity is $O(n^2)$, the following special case might be of interest for some applications of this algorithm: If: - $B$ does not contain negative values and: - $a_i = 0$ Then $C_i = 0$, with no need to consider the matrix entries $b_{i1}$ to $b_{in}$. This short circuit may ma...
That's not possible. You have to read in the entire $B$ matrix to determine the correct answer, which fundamentally requires $O(n^2)$ time.
It seems like a plausible thing to try. Give it a try and see how it works. An even better metric might be some estimate of (the negation of) the expected number of strokes needed, given the remaining distance to the hole. This is not a purely linear function, so might give a better reward function.
A key observation is that if $i$-problems are completely independent, you need to compute $n$ sums of the form $$s=\sum_{j=1}^n\max(0,a-b_j).$$ With $a=0$ and all $b_j<0$, we get the even simpler form $$-s=\sum_{j=1}^nb_j$$ which is a sum of $n$ terms and takes $\Omega(n)$ additions. (If parallelized, this can...
null
If $l'(x)$ returns false (meaning $x(x)$ does not halt within $n$ seconds) - by running $x(x)$ for $n$ seconds and observing whether it halted - then it necessarily takes more than $n$ seconds to do so. It's impossible to make a program that runs $l'(x)$ and then halts in less than $n$ seconds if $l'(x)$ returns fal...
Yes, we can skip or ignore an input without pushing it into the stack. In my case (a^i b^j c^k d^j e^i) where i & j >=0 while k >0. 'abcde'is an accepted string so I ll make following PDA so that it will accept my string. In this case I am ignoring C so that I can make a perfect machine. So, It is possible to skip an...
Let $\{M_n\}$ and $\{W_n\}$ be recursive enumerations of the machines and the words. Now for each $n$ run $M_1\ldots M_n$ on $W_1\ldots W_n$ for $n$ steps, and output the code of the machines that stopped at some point. That produces a recursive enumeration of $K$.
If your solution takes an exponential number of steps to accomplish any component of the computation it is at least exponential in time. Hence, not P.
Unfortunately it has been shown that 3SAT is not reducible to 2SAT. However, 3SAT is in P where any algorithm solves the general case in P time and space. For such an algorithm see linked paper below. https://arxiv.org/abs/cs/0205064
$A$ is an array of length $n$ \ $B$ is an $n\times n$ matrix \ I want to return an array C of size n such that: \ $$C_{i} = \sum_{j=1}^{n} \max(0, a_i - b_{ij}) $$ In pseudocode it could be like below ``` for i = 1 to n: C[i] = 0 for j = 1 to n: C[i] += max(0, a[i] - b[i,j]) ``` ...
null
I think that I have found an issue with the proof of the halting problem, which would cause the entire proof to be invalid. <br> To ensure I understand, here is Turing's proof of the halting problem being unsolvable. Proof: ----- Assume the function $h(x,y)$ determines whether the function $y(x)$ halts on input...
Proof can be found in section 4.4 and 4.5 of "evaluating derivatives and principles of algorithmic differentiation" from Griewank&Walther
null
The node weighted Steiner Tree Problem as found in [this compendium][1]: $\textbf{Instance}: \text{Graph } G = (V, E)\text{, set of terminals } S \subseteq V \text{ and a node weight function } w:V \to \mathbb{R}^+$ $\textbf{Solution}: \text{A tree } T = (V_T,E_T) \text{ in } G \text{, such that } S\subseteq V_T ...
Node weighted Steiner Tree Problem where all Nodes have the same Weight
|graphs|trees|np|
Given a DFA with m number of input alphabet and n number of states. What is time complexity to check DFA accepts infinite language (i.e infinite length of strings)?
Given an automata [DFA A=(Q,Σ,δ,q0,F)], is there any algorithm to check whether DFA accepts infinite language?
|algorithms|time-complexity|automata|
I'm assuming that you want to minimize $\sum_{v \in V_T} w(v)$. Since all vertex weights are equal, this is equivalent to minimizing $|V_T|$, and since a tree on $x$ vertices has exactly $x-1$, edges, this is equivalent to minimizing $|E_T|$. Therefore your problem [is NP-hard](https://cstheory.stackexchange.com/qu...
{"Voters":[{"Id":6759,"DisplayName":"Steven"}]}
{"Voters":[{"Id":6759,"DisplayName":"Steven"}]}