instruction stringlengths 0 29.8k ⌀ |
|---|
|regular-languages|automata|context-free|formal-grammars| |
Relation between simple and regular grammars |
I suggest you to read the Jukka's nice answer to the question "[Matching regular expressions using regular expressions][1]" on cstheory, too. An excerpt (emphasis mine):
> For example, we can modify the standard notation as follows to obtain *"compressed" regular expressions*:
> * You are allowed to remove any pr... |
Given the following recursive equation
$$ T(n) = 2T\left(\frac{n}{2}\right)+n\log n$$ we want to apply the Master theorem and note that
$$ n^{\log_2(2)} = n.$$
Now we check the first two cases for $\varepsilon > 0$, that is whether
* $n\log n \in O(n^{1-\varepsilon})$ or
* $n\log n \in \Theta(n)$.
The... |
|proof-techniques|asymptotics|recurrence-relation| |
|time-complexity|algorithm-analysis|runtime-analysis| |
From what you wrote it seems that for all $k$ you have $T(k)=k-1+T(k-1)$ and $T(1)=0$. Therefore you can get it directly:
$$T(n)=(n-1)+(n-2)+\dots+1+0 = \sum_{k=1}^{n}{(k-1)}=\frac{n(n-1)}{2}$$
So $T(n)$ is in [$Θ(n^2)$][1].
[1]: http://en.wikipedia.org/wiki/Big_O_notation#Family_of_Bachmann.E2.80.93Landau... |
The recursion you have there is this, if we count only matrix accesses:
$\qquad \begin{align}
T(1) &= 0 \\
T(n) &= T(n-1) + n - 1 \quad \text{for } n \geq 2
\end{align}$
Note that it is only an upper bound on the runtime function because the loop is not always executed. It is a *linear* recurrence relation... |
I have an algorithm, shown below, that I need to analyze. Because it's recursive in nature I set up a recurrence relation.
//Input: Adjacency matrix A[1..n, 1..n]) of an undirected graph G
//Output: 1 (true) if G is complete and 0 (false) otherwise
GraphComplete(A[1..n, 1..n]) {
if ( n = 1... |
The recursion you have there is this, if we count only matrix accesses:
$\qquad \begin{align}
T(1) &= 0 \\
T(n) &= T(n-1) + n - 1 \quad \text{for } n \geq 2
\end{align}$
Note that it is only an upper bound on the runtime function because the loop is not always executed. It is a *linear* recurrence relation... |
Since we are talking about the first programming course in a Computer Science programme, I'd say the most important aspect would be what fundamental concepts of CS it will teach your students. Since there is no language that can teach all concepts at once, you need to consider what concepts will be needed further on.
... |
An equivalent definition of NP is that it consists of all problems that are *decidable* (not just verifiable) in polynomial time by a non-deterministic Turing machine. NTMs are known to be no more powerful than TMs in the sense that the set of problems decidable by NTMs is identical to the set of problems decidable by ... |
As an introductory remark, consider the possibility of presenting more than one language (in one course). In my first term we where shown both SML and Java. The contrast had its very own and important message: choose the right tool for the job.
But now for criteria, in arbitrary order.
**Difficulty** to learn is ... |
I'll throw in my own two cents although I believe this subject is a bottomless pit. Don't get me wrong, I think it's a fascinating question, but probably not one we will solve here to everybody's satisfaction.
In a nutshell, I'd say that the language should do *what you want it to do*, in a *simple* and *unambiguous... |
- **Developing algorithmic thinking to solve problems as the main goal:** One bad thing about using an object-oriented paradigm in the first course is, that getting new learners into things like inheritance, polymorphism, etc, distracts them from the above-mentioned main goal. In fact, introduction of any secondary co... |
So, I'll dispense with my knee-jerk reaction immediately, which is that everyone should learn programming via [SICP](http://mitpress.mit.edu/sicp/) because Lisp is the Right Thing.
There have been many good criteria offered already for selecting a language... **simplicity** and **portability** being among the most i... |
null |
A Simple Grammar (s-grammar) is one in which every production is of the form $A \rightarrow aB_1B_2...B_n$ where $a$ is a terminal and all $B_i$ non-terminals, and there is only one production with any pair $\langle A,a\rangle$.
Clearly, every s-language (produced by an s-grammar) is unambiguous and easily parsed, s... |
When choosing a first programming language, there are many issues that need to be considered. Many of these have been considered in the answers above. I include 3 more as these were a part of my answer to the closed question ( http://cs.stackexchange.com/questions/1946/criteria-for-choosing-a-first-programming-language... |
**Is there a structure with ${\bf\mathcal{O}(1)}$ access to *k-th* element that can insert and delete, e.g.: in/to the middle, also in ${\bf\mathcal{O}(1)}$?** |
Structure with random access and random insert/delete in $\mathcal{O}(1)$? |
|data-structures|time-complexity|arrays|asymptotics| |
**Is there a structure with ${\bf\mathcal{O}(1)}$ amortised access to *k-th* element that can also insert and delete at—or next to—a known position in amortised ${\bf\mathcal{O}(1)}$?** |
|data-structures|time-complexity|asymptotics|arrays|amortized-analysis| |
null |
As an introductory remark, consider the possibility of presenting more than one language (in one course). In my first term we where shown both SML and Java. The contrast had its very own and important message: choose the right tool for the job.
But now for criteria, in arbitrary order.
**Difficulty** to learn is ... |
Is there a data structure with
* $O(1)$ amortised time access to the $k$-th element and
* $O(1)$ amortised time insertion and deletion at—or next to—a known position? |
Data structure with search, insert and delete in amortised time $O(1)$? |
|data-structures|time-complexity|asymptotics|amortized-analysis| |
Is there a data structure to maintain an ordered list that supports the following operations in $O(1)$ amortized time?
* **GetElement(k)**: Return the $k$th element of the list.
* **InsertAfter(x,y)**: Insert the new element y into the list immediately after x.
* **Delete(x)**: Remove x from the list.
... |
**NO.**
Fredman and Saks proved that _any_ data structure that supports these operations requires at least [$\Omega(\log n/\log\log n)$ amortized time per operation](http://dl.acm.org/citation.cfm?id=73040). (This is reference [1] in the paper by Dietz that you mention in your first comment.) The lower bound holds... |
Given a context-free grammar G, there exists a Nondeterministic Pushdown Automaton N that accepts exactly the language G accepts. (and visa versa)
There __may__ also exist a Deterministic Pushdown Automaton D that accepts exactly the language G accepts too. It depends on the grammar.
By what algorithm on the pro... |
Which Context-free Languages are accepted by Deterministic Pushdown Automata? |
|automata|context-free|pushdown-automata| |
I'll throw in my own two cents although I believe this subject is a bottomless pit. Don't get me wrong, I think it's a fascinating question, but probably not one we will solve here to everybody's satisfaction.
In a nutshell, I'd say that the language should do *what you want it to do*, in a *simple* and *unambiguous... |
It is undecidable.
Suppose that you can decide if a context free language $L$ is recognizable by a DPDA. Then you can decide the undecidable problem "is $L$ the full language $Σ^*$?":
- if no DPDA exists then $L≠Σ^*$ (since $Σ^*$ is regular)
- if a DPDA $A$ exists then let $A'$ be the DPDA recognizing the comple... |
<sup>This is supposed to become a reference question, so please excuse its terse- and broadness.</sup>
There are lots of attempts at proving either $\mathsf{P} = \mathsf{NP} $ or $\mathsf{P} \neq \mathsf{NP}$, and naturally many people think about the question, having ideas for proving either direction.
I know th... |
null |
Decide whether a context-free languages can be accepted by a deterministic pushdown automaton |
Is there a data structure to maintain an ordered list that supports the following operations in $O(1)$ amortized time?
* **GetElement(k)**: Return the $k$th element of the list.
* **InsertAfter(x,y)**: Insert the new element y into the list immediately after x.
* **Delete(x)**: Remove x from the list.
... |
The recursion you have there is this, if we count only matrix accesses:
$\qquad \begin{align}
T(1) &= 0 \\
T(n) &= T(n-1) + n - 1 \quad \text{for } n \geq 2
\end{align}$
Note that it is only an upper bound on the runtime function because the loop is not always executed. It is a *linear* recurrence relation... |
I'm applying the Compare-and-Swap technique to a SQL database to create custom row-level locking in my dataset, allowing for safe READ UNCOMMITTED isolation at the database level.
The Resource table includes a LockOwner `GUID` and a IsLocked `BIT` field. To acquire a lock, a dirty-read query gets the ID, LockOwner,... |
Compare-and-Swap in an RDBMS for custom locks and lock escalation |
|concurrency|database-theory| |
I would say, that the language (under some limitations) does not matter as much, as what you do with the language. You can learn about the same about software development, algorithms, object oriented programming, computer hardware and so forth in most languages. The key is, to develop something interesting, which utili... |
I'm applying the Compare-and-Swap technique to a SQL database to create custom row-level locking in my dataset, allowing for safe READ UNCOMMITTED isolation at the database level.
The Resource table includes a LockOwner `GUID` and a IsLocked `BIT` field. To acquire a lock, a dirty-read query gets the ID, LockOwner,... |
First of all, I will assume that by
> Additionally, the state $f_S$ of $f$ is set to a value $f_S' = f_S \pm k$, where $k$ is selected uniformly at random from $$\{0, 1, 2, ..., \lfloor n/2 \rfloor - ((f_S - x) \mod n)\} $$
you actually mean
> Additionally, the state $f_S$ of $f$ is set to a value $f_S' = f_S ... |
I'm applying the Compare-and-Swap technique to a SQL database to create custom row-level locking in my dataset, allowing for safe READ UNCOMMITTED isolation at the database level.
The Resource table includes a LockOwner `GUID` and a IsLocked `BIT` field. To acquire a lock, a dirty-read query gets the ID, LockOwner,... |
For the first point, try a counting argument. How many different messages $m(a)$ can $B$ receive, if $|m(a)|<n$? How many different strings can $A$ have?
For the second point, try first analyzing the trivial randomized protocol (randomly fixing $\log(n)$ positions of the string and sending these bits of $a$). Clearl... |
A Simple Grammar (s-grammar) is one in which every production is of the form $A \rightarrow aB_1B_2...B_n$ where $a$ is a terminal and all $B_i$ non-terminals, and there is only one production with any pair $\langle A,a\rangle$.
Clearly, every s-language (produced by an s-grammar) is unambiguous and easily parsed, s... |
There is no algorithm that given a context-free grammar, decide if a DPDA recognize the same language and compute it if it exist.
Because if such an algorithm existed, we would be able to decide the [undecidable problem of the universality of a context-free grammar][1] i.e. whether a given context-free grammar $G$ o... |
I would like to use your help with the following problem:
$L=\{<M>| L(M) is Context Free \}$, Show that $L \notin RE \cup CoRE$.
This is what I tried to do: I know that If I'll find any $L'$ language such that $L' \notin RE$ and I'll be able to show that there's reduction from $L'$ to $L$ $(L'\leq _M L)$ so the... |
$L=\{<M>| L(M) is Context Free \}$, Show that $L \notin RE \cup CoRE$ |
|formal-languages|context-free|turing-machines| |
I would like to use your help with the following problem:
$L=\{⟨M⟩ ∣ L(M) \mbox{ is context-free} \}$. Show that $L \notin RE \cup CoRE$.
I know that to prove $L\notin RE$, it is enough to find a language $L'$ such that $L'\notin RE$ and show that there is a reduction from $L'$ to $L$ $(L'\leq _M L)$.
I start... |
Proof that $\{⟨M⟩ ∣ L(M) \mbox{ is context-free} \}$ is not (co-)recursively enumerable |
Consider the following query:
SELECT Customer.Name FROM Customer
INNER JOIN Order on Order.CustomerId = Customer.Id
WHERE Customer.Preferred = True AND
Order.Complete = False
Let's suppose all of the relevant attributes (Customer.Preferred, Order.Complete, Order.CustomerId and Customer.Id... |
Optimizing a join where each table has a selection |
|optimization|database-theory|relational-algebra|databases| |
null |
To translate your statement into the relational algebra, I think it asks:
> Can we rewrite $\sigma_A(A)\bowtie \sigma_B(B)$ as $\sigma_A(\sigma_B(A\bowtie B))$?
(Where $\sigma$ is select and $\bowtie$ is join.)
The answer is "Yes," and it's a standard query optimization. To be honest, I'm not sure how to prove... |
|formal-languages|computability|context-free|turing-machines| |
I would like to use your help with the following problem:
$L=\{⟨M⟩ ∣ L(M) \mbox{ is context-free} \}$. Show that $L \notin RE \cup CoRE$.
I know that to prove $L\notin RE$, it is enough to find a language $L'$ such that $L'\notin RE$ and show that there is a reduction from $L'$ to $L$ $(L'\leq _M L)$.
I start... |
A Simple Grammar (s-grammar) is one in which every production is of the form $A \rightarrow aB_1B_2...B_n$ where $a$ is a terminal and all $B_i, i\geq0 $ are non-terminals, and there is only one production with any pair $\langle A,a\rangle$.
Clearly, every s-language (produced by an s-grammar) is unambiguous and eas... |
|concurrency|database-theory| |
I'm learning for the exam and have problems with this task.
Describe an algorithm that transform to a given €-NFA A = (Q,SIGMA, delta, q0, F) into an equal NFA without €-transitions with the same condition number. And then determine the maturity of the algorithm. The algorithm should have the running time O(|Q| · |del... |
Algorithm for NFA |
|formal-languages| |
null |
I'm learning for the exam and have problems with this task:
> Describe an algorithm that transforms a given NFA $A = (Q, \Sigma, \delta, q_0, F)$ (which may have $\epsilon$-transitions) into an equivalent NFA without $\epsilon$-transitions with the same condition number. And then determine the maturity of the algori... |
Transforming an NFA into an NFA without epsilon-transitions |
|finite-automata| |
As follows [from my previous question][1], I've been playing with the [Riemann hypothesis][2] as a matter of recreational mathematics. In the process, I've come to a rather interesting recurrence, and I'm curious as to its name, its reductions, and its tractability towards the solvability of the gap between prime numbe... |
Proving the (in)tractability of this Nth prime recurrence |
|reference-request|recurrence-relation|mathematical-analysis| |
I think the question is how to show that $L$ is not r.e. One way to do that is to reduce the complement of the halting problem to $L$, because the complement of the halting problem is not r.e.
Here's a hint about one way to do that reduction: given $M$ and $x$, we want to make a language that is context free if an... |
As follows [from my previous question][1], I've been playing with the [Riemann hypothesis][2] as a matter of recreational mathematics. In the process, I've come to a rather interesting recurrence, and I'm curious as to its name, its reductions, and its tractability towards the solvability of the gap between prime numbe... |
null |
i´ve got in a few days an exam and have problems to solve this task.
Let L be a regular language over the alphabet SIGMA. We have the operation cycle(L) := {xy : x, y 2 SIGMA und yx € L}.
And now we should show that cycle(L) is also regular.
The reference is that we could construct out of a DFA D=(Q,SIGMA,delta,... |
regular language |
|formal-languages| |
i've got in a few days an exam and have problems to solve this task.
Let $L$ be a regular language over the alphabet $\Sigma$. We have the operation
$cycle(L) = \{ xy \mid x,y\in \Sigma^* \text{ and } yx\in L\}$
And now we should show that $cycle(L)$ is also regular.
The reference is that we could construct ou... |
|formal-languages|regular-languages|finite-automata| |
prove that regular languages are closed under the cycle operator |
Consider [scheduling](https://en.wikipedia.org/wiki/Single-machine_scheduling), the task of assigning jobs with certain durations and deadlines to machines. We assume discrete time. Many such problems are NP(O)-hard.
In particular, this answer will talk about $1 \mid r_i \mid L_\max$, that is we schedule
* on on... |
As follows [from my previous question][1], I've been playing with the [Riemann hypothesis][2] as a matter of recreational mathematics. In the process, I've come to a rather interesting recurrence, and I'm curious as to its name, its reductions, and its tractability towards the solvability of the gap between prime numbe... |
I've got in a few days an exam and have problems to solve this task.
Let $L$ be a regular language over the alphabet $\Sigma$. We have the operation
$\operatorname{cycle}(L) = \{ xy \mid x,y\in \Sigma^* \text{ and } yx\in L\}$
And now we should show that $\operatorname{cycle}(L)$ is also regular.
The reference... |
Prove that regular languages are closed under the cycle operator |
|formal-languages|regular-languages|finite-automata|closure-properties| |
Is there a data structure to maintain an ordered list that supports the following operations in $O(1)$ amortized time?
* **GetElement(k)**: Return the $k$th element of the list.
* **InsertAfter(x,y)**: Insert the new element y into the list immediately after x.
* **Delete(x)**: Remove x from the list.
... |
The obvious answer is: the [powerset construction](https://en.wikipedia.org/wiki/Powerset_construction) gets rid of $\varepsilon$-transitions, so you can use it. It blows up the automaton exponentially in the worst case, though, so it is not directly applicable. However, you can use the part that deals with $\varepsilo... |
Transforming an NFA into an NFA of similar size but without $\epsilon$-transitions |
|algorithms|automata|finite-automata| |
I suggest you to read the Jukka's nice answer to the question "[Matching regular expressions using regular expressions][1]" on cstheory, too. An excerpt:
> For example, we can modify the standard notation as follows to obtain *"compressed" regular expressions*:
> * You are allowed to remove any prefix that consis... |
Who can help me with this topic: Probing with a Step Width that is a Prime Number
I am struggling with this question about defining a hashing function h(k, i) for open addressing on a table of length m, that is, with slots numbers 0, 1, 2, . . . ,m − 1.
We know that a function h(k, i) = h1(k) + i · h2(k) mod m p... |
Hashing Open Adressing - Prove |
|algorithms|complexity-theory| |
null |
The idea is to decide nondeterministically at the beginning how much the word is cycled, and have a copy of the automaton for every case.
For every state $q \in Q$, separate $D$ into two parts $A_1$ and $A_2$. $A_1$ contains the states from which $q$ is reachable and $A_2$ the states that are reachable from $q$:
... |
Who can help me with this topic: [Probing](https://en.wikipedia.org/wiki/Open_addressing) with a step width that is a prime number.
I am struggling with this question about defining a hashing function $h(k, i)$ for open addressing on a table of length m, that is, with slots numbers $0, 1, 2, \dots ,m − 1$.
We kn... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.