instruction
stringlengths
0
29.8k
⌀
|context-free|
Can anyone prove that the following is a CFL? or not? why? $$L=\{w=w_1w_2 \mid len(w_1)=len(w_2) \mbox{ and $w_1$ does not equal $w_2$}\}$$
Could anyone prove that this is a context free language or not?
null
This must be a classic in formal language theory. The Pumping Lemma will not help, because, unexpectedly, it *is* context-free. (I did not see the answer here, but it might be overlooked) The $w_1$ and $w_2$ parts must have a position where they differ. Unfortunately, we cannot distinguish the middle *and* the two m...
The language $\{ \$ a^nb^n \mid n \ge 1 \} \cup \{ \$^kw \mid k\neq 1, w\in \{a,b\}^* \}$ seems to be simple. The second part is regular (and can be pumped). The first part is nonregular, but can be pumped "into" the second part by choosing $\$$ to pump. (added) Of course, this can be generalized to $\$L \cup \{ \$^...
Claude Shannon's paper *A mathematical theory of Communication*, 1948 is beautiful. [A Mathematical Theory of Communication by Claude E. Shannon][1]. [1]: http://cm.bell-labs.com/cm/ms/what/shannonday/paper.html
I have some recurrence relationships I use to compute some coefficients of a series. I want to know what the time complexity of computing these is. Suppose I know the coefficients $a_0,...,a_n$, and I want to compute $c_0,...,c_n$ as follows $ c_{n}=\begin{cases} e^{b_{0}}, & n=0\\ \frac{1}{n}\sum_{k=1}^{n}kb_{k}c...
Computational complexity of coefficients
|time-complexity|recurrence-relation|
New to the world of software verification and synthesis. It was suggested to me that the book "Principles of Model Checking" is a good reference for verification, but I am clueless about synthesis. Could someone refer a good book?
null
I have some recurrence relationships I use to compute some coefficients of a series. I want to know what the time complexity of computing these is. Suppose I know the coefficients $a_0,...,a_n$, and I want to compute $c_0,...,c_n$ as follows $ c_{n}=\begin{cases} e^{b_{0}}, & n=0\\ \frac{1}{n}\sum_{k=1}^{n}kb_{k}c...
Does we need to use BFS or DFS algorithm while using to find the k shortest loopless paths in a graph between any two nodes? If so where can it be useful?
BFS in K shortest paths
|algorithms|
I have problem with developing algorithm couting all possibilities of this problem. > In a class taught n <= 50 children. Some couples kids like each other. Children would like to organize a party, where all the kids like it. In how many ways can you do that? (We are also consider parties, in which is one child or...
Combinatorial algorithm problem
|algorithms|graphs|algorithm-analysis|combinatorics|
there are some not-very-commonly considered forms of [trinary logic](http://en.wikipedia.org/wiki/Three-valued_logic) using 3 truth values. even entire (unusual/rare) [ternary computers](http://en.wikipedia.org/wiki/Ternary_computer) have been built from it. > is there some knowledge or reference of how to convert s...
building functionally complete boolean circuits out of trinary logic
|reference-request|logic|reductions|circuits|
An assignment questions asks the following: > Consider an array 'var a : array[1..10] of real'. Express the > semantics of this array as a function, defining the domain and > codomain (you might also be able to write the rule). In this > programming language, the subrange '1..10' is viewed as a genuine > type,...
Expressing semantics of an array as a function
|arrays|semantics|functional-programming|
I have problem with developing algorithm counting all possibilities of this problem. > In a class taught $n \leq 50$ children. Some couples kids like each other. Children would like to organize a party, where all the kids like it. In how many ways can you do that? (We are also consider parties, in which is one chi...
Your problem (assuming I understand your English correctly) is counting the number of cliques in a graph of size $n = 50$. Counting the number of cliques in a graph is #P-complete (see [this paper][1], which shows that counting the number of independent sets in a graph is #P-complete even for bipartite graphs). Seve...
There is a very nice lecture video on youtube which describes all properties. I recommend you to watch is if you are new to concept: http://www.youtube.com/watch?v=w1leqkpDaRw
It is not possible to "invert" a value. Here is a list (computed in Python) of all unary functions achievable using your gate (the order of inputs is abc): aaa aba abb abc aca acc bbb cbb cbc ccc An inverter would have one of the patterns ba?, c?a, ?cb, which none ...
Consider the case $k=1$ first. Can you use BFS or DFS? Now try to generalize.
The function is defined as follows, given array $a$, for $1 \leq i \leq 10$, $$f(i) = a[i].$$ The domain is thus $\text{dom}(f) = \{1,2,3,4,5,6,7,8,9,10\}$ and the codomain is simply $\text{codom}(f) = \bigcup_{i=1}^{10}f(i) = \bigcup_{i=1}^{10}a[i] \subset \mathbb{R}$.
You also need to take into account the size of the coefficients. Adding integer coefficients of bit-length $\ell$ takes time $O(\ell)$, and multiplying them takes time $\tilde{O}(\ell)$, i.e. $O(\ell (\log \ell)^k)$ for some $k$ (any $k > 1$ will do). Your case is slightly more complicated, since the answer is rational...
EDIT : Rewriting the problem. Given a graph with $n \leq 50 $ vertex. Find count of all $k$-cliques of this graph, where $k = 1, 2, 3, \ldots , n$. I need the most effective algorithm (implementation will be nice too). Thanks for help! Adrews
For k=1. I would like to draw your attention to the Theorem 22.5: [Cormen][1]<br/> "upon termination d.v = &eth;(s,v) for all v € V" &eth;(s,v) ... the minimum number of edges from s to v [1]: http://books.google.at/books?id=NLngYyWFl_YC&pg=PA537&lpg=PA537&dq=cormen%20bfs&source=bl&ots=BxSvDz3lHc&sig=9fYE...
If you can get a random number in the range $\{0,\ldots,n!-1\}$, you can generate a permutation on $n$ elements using the Fisher-Yates algorithm. The idea is to think of this number as encoding the numbers used in the Fisher-Yates algorithm, using "mixed-base" notation.
Just a basic question to ask **Does the write through cache copies the whole block or just the byte which is updated?** I went through the following question *Array A contains 256 elements of 4 bytes each. Its first element is stored at physical address 4096. Array B contains 512 elements of 4 bytes each. Its...
Does the write through cache copies the whole block or just the byte which is updated?
|computer-architecture|cpu-cache|
Do we need to use BFS or DFS algorithm to find the k shortest loopless paths in a graph between any two nodes? If so where can it be useful?
null
null
1. See [this answer](http://cs.stackexchange.com/a/3432/2448) - it's an example of a contradictory set of clauses where we cannot derive a contradiction without renaming variables. Note that it's not sufficient to only rename variables after the conversion to CNF, we have to rename variables to be distinct before _ever...
It is not possible to "invert" a value. Here is a list (computed in Python) of all unary functions achievable using your gate (the order of inputs is abc): aaa aba abb abc aca acc bbb cbb cbc ccc An inverter would have one of the patterns ba?, c?a, ?cb, which none ...
It makes little sense to think about how we are to encode an array as a function without explaining how we intend to implement the basic array operations. The characteristic property of an array is that we can 1. access the $i$-th element, and 2. set the $i$-th element. In addition, certain equations must be s...
null
What you want is the so-called (optimal) [local alignment](https://en.wikipedia.org/wiki/Local_alignment) of two strings. You can use the standard local alignment algorithm but allow insertions/deletions at the beginning and end (of the the shorter string) for free. In the classic dynamic programming algorithm, this...
First, the question is not well defined. If the input is of size $n$, the algorithm is measured with respect to $n$. However, the question suggests that $n$ is already exponential (in what?!) Lets assume each number takes $k$ bits, and we have $n$ different numbers to sort, where $n$ is exponential in $k$. Then...
I was wondering how should I proceed in order to show that the composition of (say) two one-way functions (either weak or strong or both together) is not a one-way function? Specifically: Say $f$ and $g$ are one-way functions (either weak or strong). How do I prove that their composition $g(f(x))$ is not necessaril...
From the Comments: A grammar is infinitely ambiguous iff there is a productive and accessible nonterminal $A$ s.t. $A\to^+A$. Nonterminals $A$ and $B$ fulfill this characterization in your first example, and so does $S$ in the second example when you add the rule $S\to\varepsilon$. I'll leave the proof of the charac...
null
This is specifically about real numbers — integers can be represented exactly. Actually, real numbers can be represented exactly too, at least the one that matter, but this is very inefficient, so for most applications real numbers are represented by a [floating point](http://en.wikipedia.org/wiki/Floating_point) appro...
|approximation|numerical-analysis|floating-point|
I have been posed with a question whereby a computer truncates numbers to x number of digits. Due to this, if this computer is trying to store a decimal number which has a binary equivalent greater than x, it truncates the remaining digits producing a different binary number. However, this binary number is still an 'ap...
Implications of truncation of numbers when converted into binary
If I have production $G_n$ > $S \rightarrow A_i b_i$ for $1 \le i \le n$ >$A_i \rightarrow a_j A_i |~ a_j$ for $1 \le i$ and $i \ne j$ 1. Prove $G_n$ is sub-productions from $2n^2 - n$ 2. Prove $G_n$ is $LR(0)$ production from $2^n + n^2 + n$
How i can use Mathematical induction to prove CFG production?
|induction|
|formal-grammars|context-free|induction|
In addition to all useful mentioned recomendations, I recommend you to find good "**survey paper**" in your area. It will help you to get the big picture of the research topics and some open and hot questions. They also contain the well known references.
It is not possible to "invert" a value. Here is a list (computed in Python) of all unary functions achievable using your gate (the order of inputs is abc): aaa aba abb abc aca acc bbb cbb cbc ccc An inverter would have one of the patterns ba?, c?a, ?cb (depending o...
You come up with an example: two functions $f,g$ which are one-way functions, but $f \circ g$ is not. To show that the latter is not a one-way function, you come up with an algorithm breaking it. Here is an example. Choose some genuine one-way function $h$. Let $f(x) = h(x) 0^{|x|}$, and let $g(x,y) = h(x)$ if $y \...
SAT[5] can be solved with resolution definitively, ie if the formula has a true assignment, resolution can find it, and if it cant be satisfied, resolution can show that no assignment exists.[4] (at least in exponential time/space.) > is there a good fully-self contained description somewhere of solving SAT with res...
description of resolution algorithm as it applies to SAT
|algorithms|complexity-theory|reference-request|logic|np-complete|
Frankly I'm very uncomfortable with the material right now. There are some things I can understand, but many I still do not. My first assignment is asking me in one question (which I do know how to do) to give a full description of a TM that accepts a language L={x in {0,1}* | x is divisible by 4}. I know that any b...
Re: Turing Machines. What is the difference between a TM accepting and deciding a language?
|terminology|turing-machines|
What you are looking for is a proof of the completeness of resolution. Here is [one example][1]. The relation to DPLL is that a run of DPLL which terminates in failure can be converted to a resolution proof that the formula is unsatisfiable. [1]: http://www.cis.upenn.edu/~cis510/tcl/resol.pdf
There are usually used as synonyms. In your example, the Turing Machine should first go all the way to the end of the input, and then check that the two rightmost digits are 0, as you suggest.
Regardless of the algorithm you use, if you have $i$ bits of random data, you can generate a maximum of $2^i$ possible permutations. If $i$ is smaller than $log_2(n!)$, then there will be some permutations which cannot be produced, and you will have, in effect, decided which permutations those are when you encode your ...
During an interview, I was asked to design an algorithm that solves the following problem : > Consider a travel from city A to city B, made of several trips by > train through other cities in between. With an access to the > unordered list of train tickets from which you can read the cities of > departure and arr...
Find the origin and the destination of a trip from a serie of tickets
|algorithms|
I was asked to design an algorithm that solves the following problem : > Consider a travel from city A to city B, made of several trips by > train through other cities in between. With an access to the > unordered list of train tickets from which you can read the cities of > departure and arrival of each trip, fi...
null
Using a hash table, record for each city mentioned how many times it was mentioned as a source and how many as destination. The source of the trip is the city that has appeared as a source an odd number of times, and similarly for the destination of the trip. That's linear time and space (with high probability).
The malicious user has to first get the malicious code into kernel space somehow. User and kernel address spaces often look contiguous under linux and various unixes, but user space isn't mapped into kernel space, and vice versa. Some variations of Unix (the Masscomp system, as I recall) made this more explicit by havi...
The details depend on the processor architecture, but generally speaking, when an interrupt is raised: * The CPU saves some registers (at least the current program counter and an indication of the current processor mode). * The CPU switches to a privileged mode. * The CPU reads a pointer value from virtual memo...
Let's say we have a fictional operating system in the user mode. Whenever an interrupt or a trap occurs, the os would switch to the Kernel mode jumping to the address determined from the interrupt vector. A malicious user could take advantage of the loophole by executing a malicious program in the kernel mode. Why i...
Dangerous interrupts
|os-kernel|
null
Yuval's answer is on right track, but being oriented graph, you need to compare number of times a city appears as arrival with number of times it appears as departure. Overall departure is the city that appears more times as departure than as arrival (usually once as departure and never as arrival) and overall arriv...
Several answers have already been given, but I still think this is somewhat cuter. Construct a bidirectional map $m: \mathcal{C} \to \mathcal{C}$ from cities to cities. This map means that if $m(x) = y$, then there is a path of tickets such that you start in $x$, take an arbitrarily long path (using only your ticke...
There is major difference. A turing machine "accepts" a language, if it enters an accepting state for any input from the langue, while it "decides" the language if it "accepts" it **and** enters a rejecting state for any input not in the language. These are different, because there is a third thing that a Turing mac...
Scripting language ------------------ I once heard the following definition of what a *scripting language* as at some conference. Namely, if its main purpose is to orchestrate components that exist in their own rights outside of the language. Consider a theatre script - it orchestrates actors who all exist independ...
There is major difference. A turing machine "accepts" a language, if it enters an accepting state for any input from the langue, while it "decides" the language if it "accepts" it **and** enters a rejecting state for any input not in the language. These are different, because there is a third thing that a Turing mac...
Frankly I'm very uncomfortable with the material right now. There are some things I can understand, but many I still do not. My first assignment is asking me in one question (which I do know how to do) to give a full description of a TM that accepts a language $L = \{ x \in \{0,1\}^* \mid x \text{ is divisible by } ...
What is the difference between a TM accepting and deciding a language?
null
There is major difference. A turing machine "accepts" a language, if it enters an accepting state for any input from the langue, while it "decides" the language if it "accepts" it **and** enters a rejecting state for any input not in the language. These are different, because there is a third thing that a Turing mac...
I have seen a few years back a nice and simple algorithm that, given a (finite) set of words in some alphabet, builds a context-free grammar for a language including these words and in some sense "natural" (e.g., the grammar doesn't produce all words in the alphabet). The algorithm is very simple, it has something lik...
an algorithm to construct a context-free grammar for a given input language
|algorithms|formal-languages|formal-grammars|
|algorithms|graphs|shortest-path|graph-traversal|
> **Possible Duplicate:** > [Show that $\{xy \mid |x| = |y|, x\neq y\}$ is context-free](http://cs.stackexchange.com/questions/307/show-that-xy-mid-x-y-x-neq-y-is-context-free) <!-- End of automatically inserted text --> Can anyone prove that the following is a CFL? or not? why? $$L=\{w=w_1w_2 \mid len(w_1)=le...