instruction stringlengths 0 29.8k ⌀ |
|---|
[Suffix arrays][1] can be used for this problem. They contain the starting positions of each suffix of the string sorted in lexicographic order. Even though they can be constructed naively in $O(nlogn)$ complexity, there are methods to construct them in $\Theta(n)$ complexity. See for example [this][2] and [this][3]. L... |
null |
What is an example for which the purely functional programming approach gives better results than imperative style? |
As long as the programming language in question is sufficiently complex (i.e. if it is Turing complete), then there are always programs in the language which no program can prove to terminate.
<s>Since all but the most primitive languages are Turing complete (it only takes something like variables and conditionals),... |
> Can I find a general algorithm to solve the halting problem for some possible program input pairs?
Yes, sure. For example you could write an algorithm that returns "Yes, it terminates" for any program which contains neither loops nor recursion and "No, it does not terminate" for any program that contains a `while(... |
Yes you can, but I doubt it will be useful. You'd probably have to do it be case analysis and then you'd only be able to look for the most obvious cases. For example, you could grep a file for the code `while(true){}`. If the file has that code it will never terminate^. More generally you could say that a program with ... |
I think all the answers here completely and utterly miss the point. The answer to the question is: assuming the program is intended to halt, then yes you <em>had better</em> be able to show it stops. If you cannot show it stops easily then the program should be considered very badly written and rejected by Quality Cont... |
> "Alan Turing proved in 1936 that a general algorithm to solve the
> halting problem for *all* possible program-input pairs cannot exist"
Can I find a general algorithm to solve the halting problem for *some* possible program input pairs?
Can I find a programming language (or languages), where I for every kind... |
Algorithm to solve Turing's "Halting problem" |
|halting-problem| |
Consider some formal theory $T$. Consider TMs augmented with proofs in $T$ that they halt/do not halt. Then we can decide whether a given TM-proof pair is halting by verifying the proof. (The examples given in sepp2k's answer are special cases).
This is quite trivial. If we take the union of any c.e. subset of halti... |
|computability|formal-methods|halting-problem|software-verification| |
|algorithms|asymptotics|mathematical-analysis|landau-notation|master-theorem| |
I have a homework assignment where I need to convert a grammar into LL(1). I've already removed the left recursion, but I'm having trouble doing left-factoring. All of the examples I've found are simple, and look something like this:
`A -> aX | aY`<br>
becomes:<br>
`A -> aZ`<br>
`Z -> X | Y`
I understand that.... |
Left-Factoring a grammar into LL(1) |
|formal-languages|formal-grammars|parsers| |
Let $a = 1$ and $b = 2$, so that
$$ T(2^n) = \sum_{k=0}^n f(2^n). $$
For case 3 to apply, we need $f(n) = \Omega(n^\epsilon)$ (for some $\epsilon > 0$) and the regularity condition, $f(n/2) \leq (1-\delta) f(n)$ (for some $\delta > 0$). You get the regularity condition from the proof, i.e. it's a proof-generated conc... |
Not a rigorous proof, but a "from the top of my head" explanation.
Imagine the recurrence aT(n/b)+f(n) as a tree. The third case covers the scenario when the root node dominates the running time asymptotically, ie. most of the work is being done in measly node on top of the recurrence tree. Then the running time is ... |
Not a rigorous proof, but a "from the top of my head" explanation.
Imagine the recurrence $aT(n/b)+f(n)$ as a tree. The third case covers the scenario when the root node dominates the running time asymptotically, i.e. most of the work is being done in measly node on top of the recurrence tree. Then the running time ... |
Understanding the definition of reduction |
Not a rigorous proof, but a "from the top of my head" explanation.
Imagine the recurrence $aT(n/b)+f(n)$ as a tree. The third case covers the scenario when the root node dominates the running time asymptotically, i.e. most of the work is being done in measly node on top of the recurrence tree. Then the running time ... |
Let $a = 1$ and $b = 2$, so that
$$ T(2^n) = \sum_{k=0}^n f(2^k). $$
For case 3 to apply, we need $f(n) = \Omega(n^\epsilon)$ (for some $\epsilon > 0$) and the regularity condition, $f(n/2) \leq (1-\delta) f(n)$ (for some $\delta > 0$). You get the regularity condition from the proof, i.e. it's a proof-generated conc... |
I face a problem with computing a complexity.
I have this equality : $P(u) = (\sqrt{u}+1)P(\sqrt{u}) + \theta(\sqrt{u})$
And I want to prove that $P(u) = O(u)$
This is how I process :
I put $m = \lg\lg u \implies P(u) = P(2^{2^{m}}) = (2^{2^{m-1}}+1)P(2^{2^{m-1}}) + \theta(2^{2^{m-1}})$
Now, I consider $S... |
Recursive complexity with change of variable |
|recurrence-relation| |
excellent and (prob unintentionally deep) question. there are indeed halting-detecting programs that can succeed on limited sets of inputs. its an active area of research. it has very strong ties to (automated) theorem proving areas.
however computer science does not appear to have an exact term for "programs" that ... |
null |
[Suffix arrays][1] can be used for this problem. They contain the starting positions of each suffix of the string sorted in lexicographic order. Even though they can be constructed naively in $O(nlogn)$ complexity, there are methods to construct them in $\Theta(n)$ complexity. See for example [this][2] and [this][3]. L... |
null |
What problem does the halting problem solve in computing, whether theoretical or practical?
Isn't it very easy to debug code which loops forever, just signal the debugger to break if the program is running for too long? What purpose / good is the halting problem? Why was Turing praised for it? |
What helpful solution does the Halting Problem give to computing? |
|halting-problem| |
What problem does the halting problem solve in computing, whether theoretical or practical?
It is very easy to debug code which loops forever, just signal the debugger to break if the program is running for too long? What purpose / good is the halting problem? Why was Turing praised for it? |
Following your suggestion, let $S(m) = P(2^{2^m})$, and let's forget about the $+1$ in the recurrence. Then
$$
\begin{align*}
S(m) &= 2^{2^{m-1}}S(m-1) + \Theta(2^{2^{m-1}}) \\ &=
\Theta(2^{2^{m-1}} + 2^{2^{m-1}+2^{m-2}}) + 2^{2^{m-1}+2^{m-2}} S(m-2) \\ &= \cdots \\ &=
\Theta(2^{2^{m-1}} + 2^{2^{m-1}+2^{m-2}} + \c... |
The halting problem is an example of a problem that a computer cannot solve. On the face of it, it might seem that computers can do anything, given enough resources and time. However, Turing showed that this intuition is false. Later on this was made more tangible by showing that a computer cannot decide whether a give... |
SUBSET-SUM instances can be encoded in base 3. We have codes for $0,1,\#$. Some codings are invalid, but in that case we can just immediately output $\#\#$ (or $\#$, if we have just written $\#$). Every SUBSET-SUM problem has infinitely many encodings, I hope that's not a problem.
If the input has length $\ell$, the... |
Just an extended (informal) comment.
As explained in Yuval's answer the halting problem is not computable.
But even if you were able to connect a Turing machine to a black-box (*oracle*) that solves it (i.e. the Turing machine sends a program $M$ and an input $x$ to the black-box and receives an answer whether $m... |
Just an extended (informal) comment.
As explained in Yuval's answer the halting problem is not computable.
But even if you were able to connect a Turing machine to a black-box (*oracle*) that solves it (i.e. the Turing machine sends a program $M$ and an input $x$ to the black-box and receives an answer whether $m... |
null |
We got tower no.1 with n odd disks and tower no.2 with n even disks.
Now we want to move all 2*n disks to tower no.3.
If T(p,q) is a recurrence relation of minimum number of moves we make to move p disks from tower no.1 and q disks from tower no.2 to tower no.3, We must find T(n,n).
Well I think it would be:
1:... |
An Alternative Hanoi Tower problem |
|recurrence-relation| |
What is a good textbook for a seminar about
- virtual environments, virtual worlds, augmented reality and
similar topics?
The seminar is at the graduate studies level and is supposed to give introduction to virtual environments, technologies and applications as well as current research directions.
A ... |
null |
I have been reading [*Introduction to Algorithms* by Cormen et al.][1] and I'm reading [the statement of the Master theorem starting on page 73][2]. In case 3 there is also a regularity condition that needs to be satisfied to use the theorem:
> ... 3. If
> $\qquad \displaystyle f(n) = \Omega(n^{\log_b a + \varep... |
[Suffix arrays][1] can be used for this problem. They contain the starting positions of each suffix of the string sorted in lexicographic order. Even though they can be constructed naively in $O(nlogn)$ complexity, there are methods to construct them in $\Theta(n)$ complexity. See for example [this][2] and [this][3]. L... |
[Suffix arrays][1] can be used for this problem. They contain the starting positions of each suffix of the string sorted in lexicographic order. Even though they can be constructed naively in $O(n\log n)$ complexity, there are methods to construct them in $\Theta(n)$ complexity. See for example [this][2] and [this][3].... |
|asymptotics|recurrence-relation| |
|computability|terminology|halting-problem| |
We got tower $T_1$ with $n$ odd disks and tower $T_2$ with $n$ even disks.
Now we want to move all $2n$ disks to tower $T_3$.
If $T(p,q)$ is a recurrence relation of minimum number of moves we make to move $p$ disks from $T_1$ and $q$ disks from $T_2$ to $T_3$, we must find $T(n,n)$.
Well I think it would be:
$... |
|algorithms|recurrence-relation|board-games| |
We got tower $T_1$ with $n$ odd disks and tower $T_2$ with $n$ even disks.
Now we want to move all $2n$ disks to tower $T_3$.
If $T(p,q)$ is a recurrence relation of minimum number of moves we make to move $p$ disks from $T_1$ and $q$ disks from $T_2$ to $T_3$, we must find $T(n,n)$.
Well I think it would be:
$... |
We got tower $T_1$ with $n$ odd disks(1,3,5...) and tower $T_2$ with $n$ even disks(2,4,6...).
Now we want to move all $2n$ disks to tower $T_3$.
If $T(p,q)$ is a recurrence relation of minimum number of moves we make to move $p$ disks from $T_1$ and $q$ disks from $T_2$ to $T_3$, we must find $T(n,n)$.
**EDIT**:
... |
**EDIT**: I changed the problem from 3CNF to SUBSET SUM (perhaps it has a simpler instance enumeration).
An instance of the **[SUBSET SUM][1]** problem (given $y$ and $A = \{x_1,...,x_n\}$ is there a non-empty subset of $A$ whose sum is $y$) can be represented on a one-tape Turing Machine with a list of comma separa... |
Let's have a look at your grammar:
$\qquad \begin{align}
X &\to aE \mid IXE \mid (X)E \\
E &\to IE \mid BXE \mid \varepsilon \\
I &\to \text{++} \mid \text{--} \\
B &\to \text{+} \mid \text{-} \mid \varepsilon
\end{align}$
Note that $X$ does not need left-factoring: all rules have disjoint FIRST sets¹.
If ... |
null |
They decide at most the context-sensitive languages (which, as you point out, is a superset of the context-free languages). See [this perl monks post](http://www.perlmonks.org/?node_id=809842).
The basic insight is that the "memory" of the machine is the number of capture groups, which is linearly bounded. |
SUBSET-SUM instances can be encoded in base 3. We have codes for $0,1,\#$. Some codings are invalid, but in that case we can just immediately output $\#\#$ (or $\#$, if we have just written $\#$). Every SUBSET-SUM problem has infinitely many encodings, I hope that's not a problem.
If the input has length $\ell$, the... |
We got tower $T_1$ with $n$ odd disks (1,3,5,...) and tower $T_2$ with $n$ even disks (2,4,6,...).
Now we want to move all $2n$ disks to tower $T_3$.
If $T(p,q)$ is a recurrence relation of minimum number of moves we make to move $p$ disks from $T_1$ and $q$ disks from $T_2$ to $T_3$, we must find $T(n,n)$.
**EDIT... |
null |
An instance of the **[SUBSET SUM][1]** problem (given $y$ and $A = \{x_1,...,x_n\}$ is there a non-empty subset of $A$ whose sum is $y$) can be represented on a one-tape Turing Machine with a list of comma separated numbers in binary format.
If $\Sigma = \{0,1,\#\}$ a reasonable format could be:
$( 1 \; (0|1)^* \; ... |
From [Wikipedia][1]:
> The type of computational problem: **The most commonly used problems are
> decision problems**. However, complexity classes can be defined based on
> function problems, counting problems, optimization problems, promise
> problems, etc.
I also saw the definitions of NP-complete, NP-hard, ... |
Why decision problems are commonly used in complexity theory? |
|complexity-theory| |
null |
*(A summary of the comments to the questions)*
pretty much any area of mathematics could be important in TCS, so you should do the best to strengthen your math background. Any tool you learn is a gain, and may be employed in some TCS (sub-)field.
<br>
This question was also answered in other SE, and very informa... |
null |
null |
Oftentimes decision problems are used because they allow a precise and simple definition of the problem and, as stated, many other problems can be converted to an equivalent decision problem.
Other types of problems are also considered in complexity theory, for instance [Function Problems][1] and [Search Problems][... |
[Partition refinement](http://en.wikipedia.org/wiki/Partition_refinement) is a technique in which you start with a finite set of objects and progressively split the set. Some problems, like DFA minimization, can be solved using partition refinement quite efficiently. I don't know of any other problems that are usually ... |
Let $T_n$ be the the column of disks $1:2:…:n$.
Let's start by the end:
- $(T_n)()()$ is the final configuration. The only mean to get there is by moving the disk $n-1$ on the stack $(n)$, so the remaining $T_{n-2}$ should be on another stick. So we should get to:
- $(n)(n-1)(T_{n-2})$ in $2^{n-2}$ steps: firs... |
null |
null |
From [Wikipedia][1]
> **a computational problem** is understood to be a task that is in principle amenable to being solved by a computer (i.e. the problem can
> be stated by a set of mathematical instructions). Informally, a
> computational problem consists of **problem instances** and **solutions** to
> these pr... |
Relation between problems and algorithms |
|algorithms|complexity-theory| |
I think this can be answered in a fairly trivial way.
I could easily introduce a tag into the description of a problem and make my algorithm branch on that tag and then call more specific algorithms to solve the actual problem, thereby making an algorithm that solves more than one problem.
For instance, I can ta... |
You can, for example, reduce problem A to a problem B, and then apply the classic algorithm for solving B to A. Therefore I'd say, you can apply algorithms to different problems. |
|complexity-theory|terminology| |
From [Wikipedia][1]:
> The type of computational problem: **The most commonly used problems are
> decision problems**. However, complexity classes can be defined based on
> function problems, counting problems, optimization problems, promise
> problems, etc.
I also saw the definitions of NP-complete, NP-hard, ... |
Why aredecision problems commonly used in complexity theory? |
We got tower $T_1$ with $n$ odd disks (1,3,5,...) and tower $T_2$ with $n$ even disks (2,4,6,...).
Now we want to move all $2n$ disks to tower $T_3$.
If $T(p,q)$ is a recurrence relation of minimum number of moves we make to move $p$ disks from $T_1$ and $q$ disks from $T_2$ to $T_3$, we must find $T(n,n)$.
If any... |
From [Wikipedia][1]
> **a computational problem** is understood to be a task that is in principle amenable to being solved by a computer (i.e. the problem can
> be stated by a set of mathematical instructions). Informally, a
> computational problem consists of **problem instances** and **solutions** to
> these pr... |
|algorithms|complexity-theory|terminology| |
G{V, E} is directed, **cyclic**, weighted graph. What is the algorithm of finding all paths between any given two nodes?
Can you suggest any good reading? |
The path between any two nodes in cyclic directed graph |
|graphs| |
null |
The complexity of solving a computational problem is defined in terms of which instance $I$ of the problem, what size $n$ of the problem instance, and what algorithm $A$ for solving the problem instance.
Is the complexity of the problem at a given size $n$ of the problem instance defined as
$$
\min_A \max_{I\in \{... |
Meaning of complexity of a computational problem |
|complexity-theory| |
I think the question is more philosophical than scientific, and indeed, as @raphael mentioned, the problem is in the definition of a "Problem".
Algorithm, in the simplest way, is a function (a mapping).
It gets an input (instance) $in \in I$ and gives an output $out \in O$.
For any instance $in$ there is only a ... |
If I understand correctly, the complexity of solving a computational problem is defined in terms of which instance $I$ of the problem, what size $n$ of the problem instance, and what algorithm $A$ for solving the problem instance.
Is the complexity of the problem at a given size $n$ of the problem instance defined a... |
If I understand correctly, the complexity of solving a computational problem is defined in terms of which instance $I$ of the problem, what size $n$ of the problem instance, and what algorithm $A$ for solving the problem instance.
Is the complexity of the problem at a given size $n$ of the problem instance defined a... |
|complexity-theory|terminology| |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.