instruction stringlengths 0 29.8k ⌀ |
|---|
{"OriginalQuestionIds":[307],"Voters":[{"Id":2205,"DisplayName":"A.Schulz"},{"Id":4249,"DisplayName":"Pål GD"},{"Id":4304,"DisplayName":"Merbs"},{"Id":98,"DisplayName":"Raphael"}]} |
In situations like these, where you are wondering about the difference between two phrases, the correct thing to do is to look up some definitions and think about them. You will discover several variations, perhaps something like this:
1. A machine "eats" a language $L$ if on input $x$ it halts and outputs $1$ if $... |
|reference-request|efficiency|cpu-cache| |
The best strategy to find the best suitable algorithms for caching is to read survey papers in this area. I recommend the paper [A survey of Web cache replacement strategies](http://dl.acm.org/citation.cfm?id=954341) by Podlipnig and Böszörmenyi (2003) which reviews many general techniques for caching. |
<sup>From a [comment](http://cs.stackexchange.com/questions/6357/what-precisely-is-infinite-ambiguity-in-a-grammar#comment12681_6357) by [Sylvain](http://cs.stackexchange.com/users/885/sylvain):</sup>
A grammar is infinitely ambiguous iff there is a productive and accessible nonterminal $A$ s.t. $A \Rightarrow^+ A$.... |
|formal-languages|formal-grammars|context-free|proof-techniques|induction| |
If I have production $G_n$
> $S \rightarrow A_i b_i \quad$ for $1 \le i \le n$
>$A_i \rightarrow a_j A_i \mid a_j\quad$ 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$ |
|randomness|sampling|permutations| |
|operating-systems|security|os-kernel| |
|algorithms|formal-languages|reference-request|formal-grammars|machine-learning| |
Construct a context-free grammar for a given set of strings |
The ideal random permutation algorithm of [Fisher and Yates][1] (Algorithm P in Knuth vol.2) for a sequence of $n$ objects requires $n-1$ random numbers.
In some card games one first does a "cut" and then a ripple shuffle. The cutting point is a random value, the subsequent shuffling could be considered as determin... |
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 ... |
I would say that write-through cache always knows which addressable units need to be written, so there is absolutely no reason why it should write the rest of the block. Therefore it does not.
I am intentionally saying "addressable units", because (though I am not sure) it would generally be aligned units of the sam... |
How do I calc RTT , do I strat to measure the time from the beginning of the segment trasmition or from the moment all the segment had been trasmitted ?
The end time is the moment the sender gets the "ACK" . |
RTT (Round Trip Time) calculation |
|computer-networks| |
How do I calc RTT , do I strat to measure the time from the beginning of the segment transmition or from the moment all the segment had been transmitted ?
The end time is the moment the sender gets the "ACK" . |
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).
Edi... |
They 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. |
I'm looking for the name (or *a* name if there isn't one already) of this relation between $G_1=\left<\Sigma_1,\mathcal{N}_1,\mathcal{R}_1,S_1\right>$ and $G_2=\left<\Sigma_2,\mathcal{N}_2,\mathcal{R}_2,S_2\right>$:
$$\exists f_\Sigma\in\Sigma_1\times\Sigma_2,f_\mathcal{N}\in\mathcal{N_1}\times\mathcal{N}_2 \text{ sur... |
Is there a name for this relation on CFGs? |
|terminology|formal-grammars|context-free| |
How do I calculate RTT, do I start to measure the time from the beginning of the segment transmition or from the moment all the segment had been transmitted?
The end time is the moment the sender gets the "ACK". |
The best way to measure RTT is to send a _single_ message packet and wait for the acknowledgement.
Starting your measurememt differently would only add unnecessary details because you start measuring delays not caused by the network. This is why pings are usually used measure RTT.
But it s nothing but an impl... |
I'm looking for the name (or *a* name if there isn't one already) of this relation between $G_1=\left<\Sigma_1,\mathcal{N}_1,\mathcal{R}_1,S_1\right>$ and $G_2=\left<\Sigma_2,\mathcal{N}_2,\mathcal{R}_2,S_2\right>$:
$$\exists f_\Sigma\in\Sigma_1\times\Sigma_2,f_\mathcal{N}\in\mathcal{N_1}\times\mathcal{N}_2 \text{ sur... |
This is a kind of (surjective) homomorphism, but the traditional definition is defined only over terminal symbols, not nonterminals.
Your definition would merge unrelated nonterminals from the first grammar with each other in the second grammar, thereby allowing (the image of) unrelated parts of the grammar to get... |
I am studying formal language theory and have been asked to prove the following (which I know to be axiomatically true):
$\forall L, L^*=(L^*)^*$
I've started with
$def. L^* = \bigcup_{i \in \mathbb{N}} L_i, L_0=\{{\epsilon}\}, L_1=\{L\}, L_{i+1}=\{uv|u\in L_i, v\in L\}$
$then (L^*)^* = \bigcup_{i \in \math... |
How to show that L*=(L*)*? |
|formal-languages| |
null |
First your integer numbers are converted into binary numbers. <br/>For example, in CPU integer 2 is converted to 0010.
> A `digital comparator` or magnitude comparator is a hardware electronic
> device that takes two numbers as input in binary form and determines
> whether one number is greater than or less than o... |
Construct a context-free grammar for a given set of words |
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 ... |
We should prove that $L^* \subset (L^*)^*$ and then $(L^*)^* \subset L^*$.
The first case follows from showing that for every set $A$, we have $A \subset A*$, then let $A = L*$. The second follows from noticing that every $(L^*)^*$ is made of factors of $L^*$ and every word of $L^*$ is made of factors of $L$, there... |
It's a big problem if you can't tell whether your proof counts as a proof or not. Perhaps it's better to write the proof "in words". Here is an example.
Since $M \subseteq M^*$ for every language $M$, clearly $L^* \subseteq (L^*)^*$. Now suppose $w \in (L^*)^*$. Then $w = w_1 \ldots w_\ell$ for some $w_1,\ldots,w_\e... |
null |
You can save a lot more on memory if you just allow logarithmic time complexity. You can implement a kD segment tree that will need N * 2^k bits memory, and runs in logarithmic time complexity for both subtasks, and linear time complexity for building the tree.
If you strictly want O(1), precompute everything. |
The round trip time is the time required to go and return, so it must be measured from the _start_ of the transmission to the _start_ of the reception of the response. If you measure from the end of the packet to the end of the ACK, you are subtracting the package length and adding in the length of the acknowledgement'... |
The train tickets form a directed walk. The departure place will have one more leaving arc than entering arcs, and the destination one more entering arc than leaving ones. |
A cache works by transferring a block at a time from/to RAM, so it copies a full block. |
You don't have to reorder everything:
**A** is the ticket that has no matching departure<br>
**B** is the ticket that has no matching destination
When you're looking for efficiency, abuse the specifics of the system. |
Your problem is one version of famous : "**subgraph isomorphism problem**" which is Np-complete. It is a computational task in which two graphs G and H are given as inputs, and one must determine whether G contains a subgraph that is isomorphic to H. There are many solutions on web for this problem like: http://en.wiki... |
Something that you should consider is to do some statistics on different data size. Send different data packet size, measure RTT, Then you can measure **Avg**. RTT based on data size, its **variance** and **jitters**. there are some open source tools for measuring these numbers like **Wireshark**: http://www.wireshark.... |
It replaces whole block of memory.
http://en.wikipedia.org/wiki/Cache_algorithms |
null |
Looking at the document _Fundamentals of Computing Series_, [The Stable Marriage Problem][1].
Theorem 1.2.3 - page 12:
> In a man-optimal version of stable matching, each woman has worst
> partner that she can have in any stable matching.
Proof:
> Suppose not. Let $M_0$ be the man-optimal stable matchin... |
null |
Suppose that we take an initial search problem and we add c > 0 to the costs on all edges. Will uniform-cost search return the same answer as in the initial search problem? |
Uniform-cost Search Problem |
|graphs|search-algorithms|search-trees|search-problem| |
Suppose that we take an initial search problem and we add $c > 0$ to the costs on all edges. Will [uniform-cost search][1] return the same answer as in the initial search problem?
[1]: http://en.wikipedia.org/wiki/Uniform-cost_search |
Suppose that we take an initial search problem and we add $c > 0$ to the costs on all edges. Will [uniform-cost search][1] return the same answer as in the initial search problem?
Definitions: Uniform-cost search is also known as lowest cost first. Initial search problem can be any graph with a start and a goal stat... |
null |
I think you might be referring to [Sequitur](http://sequitur.info/). |
For a language $L$ with pumping length $p$, and a string $s\in L$, the pumping lemmas are as follows:
**Regular version**:
If $|s| \geq p$, then $s$ can be written as $xyz$, satisfying the following conditions:
1. $|y|\geq 1$
2. $|xy|\leq p$
3. $ \forall i\geq 0: xy^iz\in L$
**Context-free version**:
If $|... |
What's the reason for the second condition of the pumping lemma(s)? |
|regular-languages|context-free|pumping-lemma| |
Consider the language of words over $\{a,b\}$ consisting of words with an equal number of $a$s and $b$s. This language is context-free but not regular. To show that it is not regular using the pumping lemma, you start with the word $a^pb^p$ and pump $y$, which must consist solely of $a$s. Without condition (2), this wo... |
null |
The answer is no, solutions may differ. If suppose your optimal solution in a graph was $s \in \mathbb{R}$ for a path of length $\ell$. If you add $c > 0$ to all edges, this new path will get cost $s + \ell c$.
If there is a different (worse) solution of cost $s - \epsilon$, where $0 < \epsilon < c$, and with a pa... |
The shortest path may indeed change. This is not because of some property of the uniform cost search, but rather, the property of the graph itself. Note that adding a constant positive cost to each edge affects more severely the paths with more edges. Here is an example, where the shortest path has cost $5$:
![enter... |
The shortest path may indeed change. This is not because of some property of the uniform cost search, but rather, the property of the graph itself. Note that adding a constant positive cost to each edge affects more severely the paths with more edges. Here is an example, where the shortest path has cost $5$:
![enter... |
null |
Suppose you have a sequence generated by an i.i.d. process (such as repeatedly rolling a die and recording the values in order) parameterized by some K-dimensional vector $\vec{\gamma}$ (the probabilities associated with each side of the die), which is unknown. But, if you assume some distribution $Q$ on $\vec{\gamma}$... |
Bayesian Coding |
|data-compression| |
The proof tells you how it is proved. When proving that a language isn't regular/context free it is quite useful to be able to limit the area containing the pumped string. The classical example is proving $\{a^n b^n \colon a \ge 0\}$ non-regular: If you take $\sigma = a^p b^p$, where $p$ is the lemma's constant, then w... |
An article that claims to introduce it: [IELR(1): Practical LR(1) Parser Tables for
Non-LR(1) Grammars with Conflict Resolution][1] by Joel E. Denny and Brian A. Malloy, Clemson University, is freely available from Malloy's site.
What they are worth is something I can't answer. (Personally I don't understand the ne... |
Whenever they ask for _shortest_ paths in a graph, it is a safe bet that some form of BFS is called for (you need to first check the neighbors of the starting point, if none qualifies you need to check all their neighbors, and so on. I.e., BFS). |
null |
The proof tells you how it is proved. When proving that a language isn't regular/context free it is quite useful to be able to limit the area containing the pumped string. The classical example is proving $\{a^n b^n \colon a \ge 0\}$ non-regular: If you take $\sigma = a^p b^p$, where $p$ is the lemma's constant, then w... |
Suppose you have a sequence generated by an i.i.d. process (such as repeatedly rolling a die and recording the values in order) parameterized by some K-dimensional vector $\vec{\gamma}$ (the probabilities associated with each side of the die), which is unknown. But, if you assume some distribution $Q$ on $\vec{\gamma}$... |
null |
Suppose you have a sequence generated by an i.i.d. process (such as repeatedly rolling a die and recording the values in order) parameterized by some K-dimensional vector $\vec{\gamma}$ (the probabilities associated with each side of the die), which is unknown. But, if you assume some distribution $Q$ on $\vec{\gamma}$... |
The caching strategies could be very "domain specific" like efficient data caching for numerical data structure, graph data structures and algorithms, bio-informatics data structure, etc.. This is a nice Ph.D thesis about it: "Cache-efficient Algorithms and Data Structures: Theory and Experimental Evaluation"(http://ww... |
The caching strategies could be very "domain specific" like efficient data caching for numerical data structure, graph data structures and algorithms, bio-informatics data structure, etc.. This is a nice Ph.D thesis about it: ["Cache-efficient Algorithms and Data Structures: Theory and Experimental Evaluation"](http://... |
Something that you should consider is to do some statistics on different data size. Send different data packet size, measure RTT, Then you can measure **Avg**. RTT based on data size, its **variance** and **jitters**. there are some open source tools for measuring these numbers like [**Wireshark**](http://www.wireshark... |
Your problem is one version of famous [**subgraph isomorphism problem**](http://en.wikipedia.org/wiki/Subgraph_isomorphism_problem) which is NP-complete. It is a computational task in which two graphs G and H are given as inputs, and one must determine whether G contains a subgraph that is isomorphic to H. There are ma... |
There is a very nice [lecture video on Youtube](http://www.youtube.com/watch?v=w1leqkpDaRw) which describes all properties. I recommend you to watch is if you are new to the concept. |
Let's consider a simpler question. Suppose that you know your graph is a tree. Then you can find the source node in linear time. Just select a random node, if it is the root then you have your answer, if not it should be a child or parent then traverse back until you reach the root. This can be done in $O(|V|-1)$. |
As mentioned before by other people the are variety of Turing machines with a little bit different definitions like two-way infinite tapes, arbitrary numbers of read-write heads, multiple tapes, ... See this [link](http://plato.stanford.edu/entries/turing-machine/#Equiv). The point is that all of them are "equivalent" ... |
This is an interesting history article titled ["A Short History of Computational Complexity"](http://people.cs.uchicago.edu/~fortnow/papers/history.pdf) which will give you a big picture in this area. |
null |
For selection/bubble sorting network algorithms, the main tricky point is that "**some operations are overlapped**" or in other words because of **pipeling**!
You can see more information in the following reference: http://fileadmin.cs.lth.se/cs/Personal/Rolf_Karlsson/lect10.pdf
This is the reason why the time comp... |
I am looking for algorithms to prioritize equipment renewals.
Input: (years since last renewal, cost of renewal, importance of renewal).
Output: An ordering of the equipment according to which it will be renewed.
I do not know if there are any algorithms for this particular problem. If you have any idea how to... |
Prioritization Algorithm |
|algorithms| |
null |
It all depends on how you define how you decide a an equipment is to be renewed. But at the end, you may sort the lists lexicographically. That is, define a _comparison function_ that takes as input two sets $X = (x _1, ..., x_k)$ and $Y = (y _1, ..., y _k)$, it will return true if $X \succ Y$ and false otherwise, wher... |
The [XOR linked list][1] is perhaps the most prominent example of storing a reversible hash of two values and using a known value and the stored hash value to derive the other value. Is there a term for the general mechanism (or a way to describe it very concisely)?
As a related question, are there other somewhat r... |
Is there a term for the general method used in XORed linked list? |
|terminology| |
I am looking for algorithms to prioritize equipment renewals.
Input: (years since last renewal, cost of renewal, importance of renewal).
Output: An ordering of the equipment according to which it will be renewed.
I do not know if there are any algorithms for this particular problem. If you have any idea how to... |
On Facebook HackerCup 2013, they asked the following question:
> Your friend John uses a lot of emoticons when you talk to him on
> Messenger. In addition to being a person who likes to express himself
> through emoticons, he hates unbalanced parenthesis so much that it
> makes him go :(
>
> Sometimes he puts ... |
Facebook Hackercup 2013: Balanced Smileys |
|algorithms|data-structures|binary-trees| |
Given the clarification to the question, it is a 0-1 knapsack problem (your knapsack is the money available, the value is the objective function), and look for ways to solve that one, for example following the [Wikipedia lead][1].
[1]: http://en.wikipedia.org/wiki/Knapsack_problem#0-1_knapsack_problem |
|algorithms|context-free|binary-trees|parsing| |
The solution is correct because the "}" and "{" symbols are considered "optional" parentheses.
(:):):(:::) → (}}{}
The left one is an example of an input string, the right is the preprocessed version of it. If you read the algorithm, you see that they keep _two_ values,
min_level, max_level = (0, 0).
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.