instruction
stringlengths
0
29.8k
⌀
My problem with CFG is, I am to generally create ones that dont have requirements such as: $a^m b^n$; $m \le n \le 2m $ I have no clue where to begin, and how to approach it. I was wondering if you can provide some hints for such daunting problems, along with how to solve that problem. This is NOT HW, this is ...
|context-free|formal-grammars|
The language $Even = \{w\in\Sigma^{\ast}\mid \text{length of }w\text{ is even}\}$ *is* regular. user5507's answer demonstrates this with an NFA, and it's a basic exercise in most texts. Then given that $L$ is regular, if we know that regular languages are closed under intersection for the purposes of the question, t...
This question is on the GRE Computer Science test booklet (not homework). I tried applying closure properties of regular languages but no success. Suppose $L$ is a regular language over $\Sigma = \{0, 1\}$. Show that the language $L'=\{w \in L \mid \text{ length of }w\text{ is even}\}$ is also regular. What I fin...
null
I'm trying to understand DPLL algorithm for solving SAT problem. And here it is: Algorithm DPLL Input: A set of clauses Φ. Output: A Truth Value. function DPLL(Φ) if Φ is a consistent set of literals then return true; if Φ contains an empty clause then r...
Understanding DPLL algorithm
|algorithms|logic|satisfiability|sat-solvers|
I'm trying to understand [DPLL algorithm][1] for solving SAT problem. And here it is: Algorithm DPLL Input: A set of clauses Φ. Output: A Truth Value. function DPLL(Φ) if Φ is a consistent set of literals then return true; if Φ contains an empty clause t...
It works because the three cases you mention will remove every non-pure variable after some number of steps, but it is crucial that you also consider the recursive step, namely $\mbox{dpll}(\phi \land l) \lor \mbox{dpll}(\phi \land \neg l)$. After a recursive step, you are guaranteed to have at least one unit clause...
I need help with the following problem: > **Input:** An undirected, unweighted graph $G = (V,E)$ and a set of vertices $F \subseteq V$. > > **Question:** > Find a vertex $v$ of $V$ such that the distance from each vertex of $F$ to $v$ is the same and all the distances are minimized? Return `None` if there is no...
Find a vertex that is equidistant to a set of vertices?
{"OriginalQuestionIds":[2016],"Voters":[{"Id":98,"DisplayName":"Raphael"}]}
As it is explained in Sipser's book, the following language is undecidable and he proves this using the computation history method. E = {[M] | M is an LBA where L(M)=empty} I wanted to see if we could use the same method used for proving undecidability of the following language in the case of LBAs too(instead o...
Proving undecidability of the language composed of LBAs where their language is empty
|turing-machines|
Consider the reduction that shows that LBA-emptiness is undecidable: you reduce from $\overline{A_{TM}}=\{<M,w>: M $ does not accept $w\}$. So the reduction takes as input $<M,w>$, and outputs an LBA $T$ such that $L(T)\neq \emptyset$ iff $M$ accepts $w$. Now, recall that an LBA is in particular a TM. So this sam...
Consider the reduction that shows that LBA-emptiness is undecidable: you reduce from $\overline{A_{TM}}=\{<M,w>: M $ does not accept $w\}$. So the reduction takes as input $<M,w>$, and outputs an LBA $T$ such that $L(T)\neq \emptyset$ iff $M$ accepts $w$. Now, recall that an LBA is in particular a TM. So this sam...
I'm trying to understand [DPLL algorithm][1] for solving SAT problem. And here it is: Algorithm DPLL Input: A set of clauses Φ. Output: A Truth Value. function DPLL(Φ) if Φ is a consistent set of literals then return true; if Φ contains an empty clause t...
For the language with lengths a integer power of two, they can be regular only if they are finite. It is easy to prove by the pumping lemma that an infinite language of such kind can't be regular (just look at the lengths of the strings).
I have on a few occasions trained neural networks (back propagation networks) with some rather complicated data sets (backgammon positions and OCR). When doing this, it seems that a lot of the work involves trying out different configurations of the networks, in order to find the optimal configuration for learning. Oft...
Adapting neural network
|machine-learning|neural-networks|learning-theory|
Can anyone suggest me some good books on cryptography? I have just starting studying cryptography but I know elementary number theory, abstract algebra and algorithms. Also please mention the difficulty level of the book. Thank you.
A good book on cryptography
|cryptography|books|soft-question|
I would have to say that **Applied Cryptography** is the best i have come across. It's a good introduction, but at the same time have a detailed level.
I think your problem is not the algorithm itself but a few surrounding notions. 1. A *literal* is a variable or its negation: $a$ or $\neg a$ for example. 2. A *clause* is a disjunction of literals: $a \lor b$ 3. A *unit clause* contains only one literal: $\neg a$ is an example 4. The *empty clause* contains ...
Hint: Each $a$ corresponds to either one $b$ or two $b$s. Form a hybrid between grammars for $a^n b^n$ and $a^n b^{2n}$.
Just read the constraint carefully. $m\le n$ tells you that you must have at least as many b's as a's. The other part: $n\le 2m$ tells you that you cannot have more than twice as much a's. Here is an EBNF description that yon convert to BNF. $S\to aSb[b]$
Popular view tells us that any kind of information is just a collection of bits, that is zeroes and ones placed in a particular order. I was thus having this thought. Suppose that I have some kind of file such as a text document, a PDF or anything else and that I also have a memory so perfect that I can remember the...
Reconstructing files from binary
|soft-question|
I assume you understand binary. If every character is a byte (8 bits), you can recover the initial file (text) by translating every byte to a character. A simple algorithm for doing that is: let initial_file be an empty text file for every byte in binary file: write character corresponding to byte in...
"Introduction to Modern Cryptography", Jonathan Katz and Yehuda Lindell. This is a great book for learning about provable security. And for actual crypto protocols and algorithms, there's always the classic: "Handbook of Applied Crypto" by Paul van Oorschot, A. J. Menezes, Scott Vanstone, and Alfred Menezes. This i...
IMHO a very good book for you may be: J. Hoffstein, J.Pipher, J. H. Silverman, An Introduction to Mathematical Cryptography. ISBN 976-1-4419-2674-6. It is published 2010 in the Springer series Undergraduate Texts in Mathematics.
Just read the constraint carefully. $m\le n$ tells you that you must have at least as many b's as a's. The other part: $n\le 2m$ tells you that you cannot have more than twice as much a's. Here is an EBNF description that yon can convert to BNF. $S\to aSb[b]$
Indeed, the wording of that sentence can lead to false conclusions. "The CPU is idle" actually means that it has no part in the memory transfer and (in principle) is free todo whatever the instructionstream(s) indicate. While this can be phrased in only a couple of words the effects are tremendous! When the CPU does...
I have $n\times k$ matrix with $k<n$ and I would like to find all its $n\choose k$ submatrices which are $k\times k$ matrices that are the concatinations of all possible $k$ rows. Actually I tried to do it with matlab but it takes too long time specially when $n>20$ and I couldn't find a way how to generate in parallel...
I would have to say that **Applied Cryptography** by Bruce Schneier is the best I have come across. It's a good introduction, but at the same time have a detailed level.
I have $n\times k$ matrix with $k<n$ and I would like to find all its $n\choose k$ submatrices which are $k\times k$ matrices that are the concatenations of all possible $k$ rows. Actually I tried to do it with Matlab but it takes too long time specially when $n>20$ and I couldn't find a way how to generate in parallel...
How to enumerate combinations in parallel
Counting all possible paths, or all possible paths with a given length, between a couple of nodes in a directed or undirected graph is a classical problem. Attention should be given to what _all_ means, due to the possibles cycles. This question is slightly different, or at least I think. **INPUT:** Be **G** a d...
All paths of less than a given length in a directed graph between couple of nodes
|algorithms|graphs|search-algorithms|shortest-path|
Files are always stored in the disk in binary format. Therefore if you know the binary version of the file, you simply know the file itself. A more interesting question is whether you can reconstruct the semantics of the file from its binary contents. Suppose you memorized the binary contents of a file, but forgot w...
Just read the constraint carefully. $m\le n$ tells you that you must have at least as many b's as a's. The other part: $n\le 2m$ tells you that you cannot have more than twice as much a's. Here is an EBNF description that yon can convert to BNF. $S\to aSb[b] \mid \epsilon$
First notice that a "file" is a sequence of 0s and 1s in binary format that are stored in some kind of persistent storage (an hard disk, a CD, an USB key, ...). According to the the *type of information* stored in the file (a plain text, a PDF document, an image, a video, a song, ...) its bits (bytes) are usually a...
First notice that a "file" is a sequence of 0s and 1s in binary format that are stored in some kind of persistent storage (an hard disk, a CD, an USB key, ...). According to the the *type of information* stored in the file (a plain text, a PDF document, an image, a video, a song, ...) its bits (bytes) are usually a...
First notice that a "file" is a sequence of 0s and 1s in binary format that are stored in some kind of persistent storage (an hard disk, a CD, an USB key, ...). According to the the *type of information* stored in the file (a plain text, a PDF document, an image, a video, a song, ...) its bits (bytes) are usually a...
If I am not missing something about your question, you can apply the standard trick for reducing the question about multiple sources and destinations to the case of single source and single destination is to add two new nodes $s$ and $t$ and connect $s$ to all sources, connect $t$ to all destinations. Now check for pat...
If I am not missing something about your question, you can apply the standard trick for reducing the question about multiple sources and destinations to the case of single source and single destination: > add two new nodes $s$ and $t$ and connect $s$ to all sources, connect $t$ to all destinations. check for ...
null
The language $Even = \{w\in\Sigma^{\ast}\mid \text{length of }w\text{ is even}\}$ *is* regular. user5507's answer demonstrates this with an NFA, and it's a basic exercise in most texts. Then given that $L$ is regular, if we know that regular languages are closed under intersection for the purposes of the question, t...
If I am not missing something about your question, you can apply the standard trick for reducing the question about multiple sources and destinations to the case of single source and single destination: > 1. Add two new nodes $s$ and $t$, > 2. Connect $s$ to all sources, > 3. Connect all destinations to $t$. ...
null
If I am not missing something about your question, you can apply the standard trick for reducing the question about multiple sources and destinations to the case of single source and single destination: > 1. Add two new nodes $s$ and $t$, > 2. Connect $s$ to all sources, > 3. Connect all destinations to $t$. ...
null
Suppose we have a function based on two inputs:$m,n$. Therefore the time complexity of the function is calculated by $T(m,n)$. Suppose that we have: $T(m,c)\in O(m^2)$ for any constant $c$ $T(c',n)\in O(n^2)$ for any constant $c'$ What can we say about $T(m,n)$? Thanks.
Time complexity based on two variables
|time-complexity|functional-programming|
With this exact phrasing, and without additional assumptions on the structure of $T$, you can't really say anything about it's asymptotic behavior in general. First, observe that the function $m^2n^2$ satisfies this constraints, so you can at least $\Omega(m^2n^2)$. However, you can get much more than that. Let $...
With this exact phrasing, and without additional assumptions on the structure of $T$, you can't really say anything about it's asymptotic behavior in general. First, observe that the function $m^2n^2$ satisfies the constraints, so you can at least $\Omega(m^2n^2)$. However, you can get much more than that. Let $f...
null
null
null
Can someone explain in plain English what does two's complement integer mean? I read it in `in JAVA long is a 64-bit signed two's complement integer` I probably don't need answer this long but this is great explanation for non-cs people with interested in programming as hobby: http://stackoverflow.com/questions/4...
two's complement integer
|complexity-theory|soft-question|integer-programming|
null
How can I sort a list of 5 integers such that in the worst case it takes 7 compares? I don't care about how many other operations are performed. I don't know anything particular about the integers. I've tried a few different divide and conquer approaches which get me down to 8 compares, such as following a mergeso...
Sort array of 5 integers with a max of 7 compares
|sorting|
|binary-arithmetic|
Two's complement is the most commonly used way to represent signed integers in bits. First, consider unsigned numbers in 8 bits. Notice that $2^8 = 256 = 100000000_2$ does not fit into 8 bits and will thus be represented as `0000 0000`. Therefore $255 + 1 =$ `1111 1111` + `0000 0001` = `0000 0000` and in that sense `11...
null
Karolis Juodele's answer is good. Here's another take. To represent a negative number over $k$ bits in two's complement: 1. Take the complement of the absolute value of the number over $k$ bits, by changing $0$ to $1$ and vice-versa. 2. Add 1 to the number obtained previously, using regular unsigned integer arit...
null
The two's complement of a number $N$ is the amount that you need to add to $N$ to get $2^k$ where $k$ is the number of binary digits needed to represent $N$; analogously three's complement would be the amount to add to get $3^k$ ($k$ is the number of ternary digits now) and you get the pattern. So this complement idea ...
null
null
Proof that if $L$ is regular over $\{0, 1\}$, then $\{w \in L \mid length(w) \text{ is even}\}$ is also regular
**$k=2$** For the case when $k=2$ Minimum $k$-Multiway cut is exactly the Minimum $s$-$t$ Cut problem. To see this simply let $(s_1, s_2) = (s,t)$ and compute a min $s$-$t$ cut. This can be solved in polynomial time by various Maximum-Flow algorithms. **$k \geq 3$** We can design a very simple 2OPT approximati...
|formal-languages|automata|machine-models|
Can a two-stack PDA accept language $L=\{a^nb^mc^nd^m \mid n \geq m\}$, which has no context-free grammar? I don't believe this has a context-free grammar, but please correct me if I'm wrong.
Can a two-stack PDA accept language $a^nb^mc^nd^m$ which is not context-free?
It depends on what the purpose is, I personally read the [A very short introduction to Cryptography][1] which was a perfect guide to someone knowing nothing about this subject. If your purpose is to begin applying readily available algorithms this is a good book. If you want to get in deap and look at the functioning ...
This can be solved using closure properties of regular languages and uniqueness of the minimal DFA. Proceed as follows: * Construct an NFA for the given regular expression. * Construct the canonical DFA for $\Sigma^l$ (a linear chain with $l+1$ states, maybe an additional error state). * Intersect the two (s...
{"OriginalQuestionIds":[10897],"Voters":[{"Id":6447,"DisplayName":"vonbrand"},{"Id":4249,"DisplayName":"Pål GD"},{"Id":1636,"DisplayName":"Luke Mathieson"},{"Id":472,"DisplayName":"Juho"},{"Id":98,"DisplayName":"Raphael"}]}
|automata|finite-automata|compilers|efficiency|nondeterminism|
In the case of LBAs (Linear Bounded Automaton), in writing a decider for the language $\qquad A = \{ \langle M,w\rangle \mid M\ \mathrm{LBA}, w \in \mathcal{L}(M) \}$ we reject the input after a specific number (number of possible different configurations) of computation steps. We say that the machine must be lo...
Recognizing loops in computation on LBA
|linear-bounded-automata|
|algorithms|algorithm-analysis|search-algorithms|correctness-proof|
As it is explained in Sipser's book, the following language is undecidable and he proves this using the computation history method. $\qquad E = \{\langle M \rangle \mid M\ \mathrm{LBA}, L(M)=\emptyset\}$ I wanted to see if we could use the same method used for proving undecidability of the following language in t...
|turing-machines|undecidability|
|reference-request|cryptography|books|
Can anyone suggest me some good books on cryptography? I have just starting studying cryptography but I know elementary number theory, abstract algebra and algorithms. Also please mention the difficulty level of the book.
A good introductory book on cryptography
|algorithms|combinatorics|parallel-computing|matrices|