instruction stringlengths 0 29.8k ⌀ |
|---|
As is often the case with NP-reductions, it makes sense to look for [similar](https://en.wikipedia.org/wiki/List_of_NP-complete_problems#Compression_and_representation) problems. In particular, it is hard to encode global conditions such has "have seen some nodes" into PCP (with polynomially many tiles). Therefore, a s... |
null |
null |
Assume $L$ is a regular language over an ordered alphabet. Is the language built by taking every word in $L$ and sorting it always a regular language? |
Are regular languages closed under sort? |
|regular-languages| |
No. Counterexample: assuming $a < b$, we have $(ab)^\ast \xrightarrow{\;\;\text{sorted}\;\;} \{ a^n b^n \;|\; n \geqslant 0 \}$, which cannot be expressed by a regular language, by the [pumping lemma for regular languages](http://en.wikipedia.org/wiki/Pumping_lemma_for_regular_languages). |
$\newcommand\ldotd{\mathinner{..}}$Given that the occurrence of each number except a particular number in $A[1\ldotd n]$ is an odd number. Try to find the number whose occurrence is an even number.
There is an $\Theta(n\log n)$ algorithm: we sort $A[1\ldotd n]$ into $B[1\ldotd n]$, and break $B[1\ldotd n]$ into many... |
Determining the particular number in $O(n)$ time (worst case) |
|algorithms|search-algorithms| |
|formal-languages|regular-languages| |
$\newcommand\ldotd{\mathinner{..}}$Given that the occurrence of each number except a particular number in $A[1\ldotd n]$ is an odd number. Try to find the number whose occurrence is an even number.
There is an $\Theta(n\log n)$ algorithm: we sort $A[1\ldotd n]$ into $B[1\ldotd n]$, and break $B[1\ldotd n]$ into many... |
Informally, the problem is similar to Sicilian reasoning. Any given agent can only act if
* it got the original message,
* it knows that everybody else got the message,
* it knows that everybody else knows it got the message,
and so on. In your model, there is no tool to break this dilemma: all communication... |
I am looking for a reference text on applied graph theory and graph algorithms. Is there a standard text used in most computer science programs? If not, what are the most respected texts in the field? I have Cormen et al. |
|algorithms|graphs|reference-request|education|books| |
Another detail that may help your intuition is that an Euler cycle exists if and only if each vertex has even degree. A similar theorem exists for Euler paths. This follows from a fairly straightforward proof--basically, every time you visit a vertex, you must then leave it, so each "visit" takes two from the degree ... |
In general, you can decide equivalence of regular expression and finite automaton using standard algorithms:
* Construct an NFA from the regular expression,
* Determinise and minimise both automata,
* Check for equality (up to isomorphism).
These algorithms and proof that the minimal DFA of any regular langu... |
I just came across an exercise which is to find a regular expression for the following automata, such that the regular expression and the automata generate the same language.
![NFA][2]
One solution presents the following expression:
$\qquad \displaystyle r_A = a^+b^+(c\mid ca^*b^+)^*$
However, can this be t... |
Here is an idea for an algorithm; just count all occurrences!
1. Find $m = \max A$. -- time $\Theta(n)$
2. "Allocate" array $C[0..m]$. -- time $O(1)$¹
3. Iterate over $A$ and increase $C[x]$ by one whenever you find $A[\_]=x$. If $C[x]$ was $0$, add $x$ to a linear list $L$. -- time $\Theta(n)$
4. Iterate ove... |
I had written a [compiler compiler](https://github.com/shabbyX/shCompiler) a few years ago and I'm now cleaning it up, improving it, and turning it into C.
I came across a terminology problem however that I remember in the past I couldn't solve it either.
Imagine an LL(k) stack. In this stack, you may have termin... |
How to call something that can be either a terminal or a nonterminal? |
|terminology|formal-grammars|compilers| |
In a recent CACM article [1], the authors present an implementation for *staged functions*. They use the term as if it was well-known, and none of the references looks like an obvious introduction.
They give a short explanation (emphasis mine and reference number changed; it's 22 in the original)
> In the context... |
What are staged functions (conceptually)? |
|terminology|programming-languages| |
I had written a [compiler compiler](https://github.com/shabbyX/shCompiler) a few years ago and I'm now cleaning it up, improving it, and turning it into C.
I came across a terminology problem however that I remember in the past I couldn't solve it either.
Imagine an LL(k) stack. In this stack, you may have termin... |
The long forms "terminal symbol" and "nonterminal symbol" suggest that you are dealing first and foremost with "symbols"; "terminal" and "non-terminal" are qualifiying attributes that specify a symbol's role in the grammar. A symbol that can be either one of terminal and non-terminal is, almost by virtue of logics, jus... |
Like with anything in CS, there is no "best something". There are always trade offs. But, perhaps this section of [Wikipedia's article on Fibonacci heap](http://en.wikipedia.org/wiki/Fibonacci_heap#Summary_of_running_times) could help you:
[Fibonacci heap](http://en.wikipedia.org/wiki/Fibonacci_heap): Amortized $\ma... |
I am currently researching for my diploma thesis in computer science with a topic in the area of distributed hash tables. Naturally, I came to the question were the term *distributed hash table* came from. (I know it is not rocket science to just derive it from *distributing a hash table*, but somebody somewhere must h... |
Origins of the term "distributed hash table" |
|distributed-systems|history| |
|data-structures|terminology|distributed-systems|hash-tables|history| |
An almost trivial solution - which uses however $\Theta(n)$ space - is to use a hash map. Recall that a hash map has amortized runtime $\mathcal{O}(1)$ for adding and looking up elements.
Hence, we can use the following algorithm:
1. Allocate a hash map $H$. Iterate over $A$. For each element $i \in A$, increase ... |
As is often the case with NP-reductions, it makes sense to look for [similar](https://en.wikipedia.org/wiki/List_of_NP-complete_problems#Compression_and_representation) problems. In particular, it is hard to encode global conditions such has "have seen some nodes" into PCP (with polynomially many tiles) which contraind... |
null |
No. Counterexample: assuming $a < b$, we have $(ab)^\ast \xrightarrow{\;\;\text{sorted}\;\;} \{ a^n b^n \;|\; n \geqslant 0 \}$, which cannot be expressed by a regular expression, by the [pumping lemma for regular languages](http://en.wikipedia.org/wiki/Pumping_lemma_for_regular_languages). |
There is always the free [Algorithmic Graph Theory](http://code.google.com/p/graphbook/) which covers graph algorithms, data structures, traversals, and several other topics. If it doesn't have what you're looking for, at least you're not out anything. |
$\newcommand\ldotd{\mathinner{..}}$Given that the occurrence of each number except a particular number in $A[1\ldotd n]$ is an odd number. Try to find the number whose occurrence is an even number.
There is an $\Theta(n\log n)$ algorithm: we sort $A[1\ldotd n]$ into $B[1\ldotd n]$, and break $B[1\ldotd n]$ into many... |
Determining the particular number in $O(n)$ time and space (worst case) |
Lets say I have node A that connects to 10 other nodes. 6 of those nodes have Characteristic 1 and the other 4 have Characteristic 2. How can I easily determining the probability of landing on a node with characteristic 1 randomly while traversing the graph? |
Determining Probability from a Graph |
|graphs|probability-theory| |
Like with anything in CS, there is no "best something". There are always trade offs. But, perhaps this section of [Wikipedia's article on Fibonacci heap](http://en.wikipedia.org/wiki/Fibonacci_heap#Summary_of_running_times) could help you:
[Fibonacci heap](http://en.wikipedia.org/wiki/Fibonacci_heap): Amortized $\ma... |
Jean Louis Krivine introduced an abstract calculus which extends the "Krivine Machine" in a very non-trivial way (note that the Krivine machine already supports the call/cc instruction from lisp):
He introduces a "quote" operator in [this article][1] defined in the following manner: if $\phi$ is a $\lambda$-term, no... |
null |
Lets say I have node A that connects to 10 other nodes. 6 of those nodes have Property 1 and the other 4 have Property 2. How can I easily determining the probability of landing on a node with property 1 randomly while traversing the graph? |
Lets say I have node A that connects to 10 other nodes. 6 of those nodes have Property 1 and the other 4 have Property 2. How can I easily determining the probability of landing on a node with property 1 randomly while traversing the graph?
To clarify this problem, I'm trying to choose the most probable path.
I h... |
A soft heap is a subtle modification of a binomial queue. It supports insert, delete, meld and findmin. The *amortized* complexity of each operation is $O(1)$, except for insert which takes $\log (1/\epsilon)$ time. The novelty of the soft heap is in beating the logarithmic bound on the complexity of a heap in the comp... |
Here is an idea for a simple algorithm; just count all occurrences!
1. Find $m = \max A$. -- time $\Theta(n)$
2. "Allocate" array $C[0..m]$. -- time $O(1)$¹
3. Iterate over $A$ and increase $C[x]$ by one whenever you find $A[\_]=x$. If $C[x]$ was $0$, add $x$ to a linear list $L$. -- time $\Theta(n)$
4. Itera... |
Let $f(n)$ be a time-constructable function.
The simulation result for single-tape TMs states that we can simulate single-tape TMs on a single-tape TM for $f(n)$ steps in time $g(n)$ where $g(n)$ is an arbitrary function in $\omega(f(n)\lg f(n))$.
Can we simulate a multi-tape TMs (number of tapes fixed) on a mu... |
Simulation on multi-tape Turing machines |
|complexity-theory|reference-request|turing-machines|machine-models|simulation| |
null |
Lets say I have node A that connects to 10 other nodes. 6 of those nodes have Property 1 and the other 4 have Property 2. How can I easily determining the probability of landing on a node with property 1 randomly while traversing the graph?
Abstract Example
===
To clarify this problem, I'm trying to choose the m... |
You can show that it is optimal given an oracle that solves the decision problem (see other answers) in polynomial time by querying if there exists a shorter solution. If your goal is to construct an optimal solution given the oracle, proceed as follows. Find the minimum total weight via binary search (or if there ar... |
Let $f(n)$ be a time-constructable function.
The usual simulation result for single-tape TMs states that we can simulate single-tape TMs on a single-tape TM for $f(n)$ steps in time $g(n)$ where $g(n)$ is an arbitrary function in $\omega(f(n)\lg f(n))$. The same result works for multiple-tape TMs.
Can we simulat... |
Let $f(n)$ be a fixed time-constructable function.
The usual simulation result for single-tape TMs states that we can simulate single-tape TMs on a single-tape TM for $f(n)$ steps in time $g(n)$ where $g(n)$ is an arbitrary function in $\omega(f(n)\lg f(n))$. The same result works for multiple-tape TMs.
Can we s... |
Universal simulation of Turing machines on a multiple-tape Turing machine |
Let $f$ be a fixed time-constructable function.
The classical universal simulation result for TMs (Hennie and Stearns, 1966) states that there is a two-tape TM $U$ such that given
* the description of a TM $\langle M \rangle$, and
* an input string $x$,
runs for $g(|x|)$ steps and returns $M$'s answer on $x... |
Universal simulation of Turing machines |
We know that $\# \textbf{P}$ is closed under polynomial sums, i.e., sum of polynomially many $\# \textbf{P}$ functions is still in $\# \textbf{P}$.
Functions in $\textbf{P}^{\# \textbf{P}}$ are those which make polynomially many (non-parallel) queries to an oracle for a $\# \textbf{P}$-Complete problem. So, the comp... |
$\textbf{P}^{\# \textbf{P}}$ distinction between $\# \textbf{P}$-Complete |
|complexity-theory|time-complexity| |
distinction between $\textbf{P}^{\# \textbf{P}}$ and $\# \textbf{P}$-Complete |
Let $M_{1}$ and $M_{2}$ be two (non-deterministic) turing machines accepting the language $L \subseteq \Sigma^{\ast}$.
Is is right to claim that:
$\#M_{1} \in \textbf{#C}$ *if and only if* $\#M_{2} \in \textbf{#C}$ ?
where $\textbf{#C}$ is a counting complexity class, that is closed under reductions (such as $... |
Counting certificates for a language |
|complexity-theory| |
Take the language to be $L=\Sigma^*$. $L$ can be solved trivially, so there is a polytime NTM that doesn't use any nondeterminism and solves $L$, call it $M$. The counting function for $M$ is $\#M(x)=1$ which is trivial.
Take $N$ be the following polytime NTM:
$N :=$ on input $x$,
1. nondeterministicly guess $... |
Take the language to be $L=\Sigma^*$. $L$ can be solved trivially, so there is a polytime NTM that doesn't use any nondeterminism and solves $L$, call it $M$. The counting function for $M$ is $\#M(x)=1$ which is trivial.
Take $N$ be the following polytime NTM:
$N :=$ on input $x$,
1. nondeterministicly guess $... |
First they are different kind of problems. One is a class of decision problems, the other one is a class of function problems. So lets interpret the question as $\mathsf{FP^{\#P}}$ vs. $\mathsf{\#P\text{-}complete}$.
Second, the kind of reductions used for completeness are not simple polynomial time Turing reduction... |
> "Is it intuitive to see that finding a Hamiltonian path is not in P while finding Euler path is?"
The assumptions in your question are not correct.
Note that **we don't know** that $\mathrm{HamPath}$ is not in $\mathsf{P}$! Someone someday might find a very clever characterization of $\mathrm{HamPath}$ (similar... |
I'm defining an intermediate language for a multi-backend code generator that I'm writing. I want to document the operational semantics for this intermediate language in a way that is readable both from within the source code and generated documentation (ocamldoc). The notation introduced used in "Types and Programmi... |
Notation for operational semantics that can be used in code comments |
|semantics|operational-semantics| |
{"Voters":[{"Id":1967,"DisplayName":"RecursivelyIronic"}]} |
null |
{"Voters":[{"Id":1967,"DisplayName":"RecursivelyIronic"}]} |
In Sipser's textbook "Introduction to the Theory of Computation, Second Edition," he defines nondeterministic time complexity as follows:
> Let $N$ be a nondeterministic Turing machine that is a decider. The **running time** of $N$ is the function $f : \mathbb{N} \rightarrow \mathbb{N}$, where $f(n)$ is the maximum... |
Why does NTIME consider the length of the longest computation? |
|time-complexity|nondeterminism| |
First, it definitely won't result in a DAG, just a digraph. You need to get from A to B and B to A in order to satisfy your condition for nodes A and B, but that itself is a cycle.
Lots of time BFS and DFS are equivalent in relation to a problem, so it doesn't matter which one you choose. Here, the real trick is not... |
In [Knuth's original paper on $LR(k)$ grammars][1], he proved that the decision problem "Given a CFL $L$, is there a $k$ such that $L$ has an $LR(k)$ grammar?" is undecidable.
Is there a similar result showing that it is undecidable whether a given CFL has an $LL(k)$ grammar for some choice of $k$? Or is this probl... |
Determining whether a CFL is $LL(k)$ for any $k$? |
|computability|formal-grammars|parsing| |
As a hint, think about the intersections as nodes and the streets as directed edges connecting intersections. Then, try thinking about the following: find all clusters of nodes that are mutually reachable from one another (such nodes are said to be [strongly-connected][1].
Hope this helps!
[1]: http://en.wik... |
Ah, but you don't know that the machine will select the shortest accepting path. All nondeterminism gives you is that the machine will select <i>some</i> accepting path, if at least one exists. So in the worst case it selects the longest. |
Because you don't know ahead of time whether or not any given input is a 'yes' instance — that is, whether there exists *any* accepting path — it makes sense for the sake of uniformity to bound the run-time independently of any particular feature of the computational paths. Thus, it makes sense to require t... |
null |
There is a well known worst case $O(n)$ [selection algorithm](http://en.wikipedia.org/wiki/Selection_algorithm) to find the $k$'th largest element in an array of integers. It uses a [median-of-medians](http://en.wikipedia.org/wiki/Selection_algorithm#Properties_of_pivot) approach to find a good enough pivot, partition... |
Bound on space for selection algorithm? |
|algorithms|space-complexity|lower-bounds| |
null |
|complexity-theory|time-complexity|nondeterminism| |
|programming-languages|semantics|operational-semantics| |
Maybe the following perspective helps:
When you are trying to construct a Eulerian path, you can proceed almost greedily. You just start the path somewhere and the try to walk as long as possible. If you detect a circle, you will delete its edges (but record that this circle was constructed). By this you decompose t... |
null |
The input format for the tool [OTT](http://www.cl.cam.ac.uk/~pes20/ott/) is based on ASCII and the rules look very much like type system/operational semantics rules. Maybe you could use that format. I'm sure that the parser for the input format is available as open source. |
In [Knuth's original paper on $LR(k)$ grammars][1], he proved that the decision problem "Given a CFL $L$, is there a $k$ such that $L$ has an $LR(k)$ grammar?" is undecidable.
Is there a similar result showing that it is undecidable whether a given CFL has an $LL(k)$ grammar for some choice of $k$? Or is this probl... |
|formal-languages|computability|formal-grammars|context-free|parsing| |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.