instruction stringlengths 0 29.8k β |
|---|
The optimal compression rate is related to the entropy of the data.
From the Wikipedia article http://en.wikipedia.org/wiki/Shannon%27s_source_coding_theorem:
> N i.i.d. random variables each with entropy H(X) can be compressed
> into more than N H(X) bits with negligible risk of information loss,
> as N tends... |
I need to calculate the output of the sequence generated by this shift register but I cannot find anywhere how to do it. Everywhere the results are just given but there is no explanation how to do compute them. I know the the sequence will repeat every 2^3-1=7 times. Could anyone explain me how to do it. Thank you.
Sh... |
LFSR sequnce computation |
|cryptography|pseudo-random-generators|shift-register| |
I need to calculate the output of the sequence generated by this shift register but I cannot find anywhere how to do it. Everywhere the results are just given but there is no explanation how to do compute them. I know the the sequence will repeat every 2^3-1=7 times. Could anyone explain me how to do it. Thank you.
Sh... |
LFSR sequence computation |
I need to calculate the output of the sequence generated by this shift register but I cannot find anywhere how to do it. Everywhere the results are just given but there is no explanation how to do compute them. I know the the sequence will repeat every 2^3-1=7 times. Could anyone explain me how to do it. Thank you.
... |
I was solving exercises on Lambda calculus. However, my solutions are different from the answers and I cannot see what is wrong.
1. Find free variables of $(\lambda x.xy)x$.
My workings: $FV((\lambda x.xy)x)=FV(\lambda x.xy) \cup FV(x)=\{y\} \cup \{x\}=\{x,y\}$.
The model answer: $FV((\lambda x.xy)x)=\{x\}$.
... |
null |
The answer seems to be simple:
First, we XOR the two least significant bits (LSB) to get the most significant bit. The two LSB are obtained by right-shifting. So, calculating in this way, we get the sequence 110, 111, 011, 001, 100, 010, 101. |
## Generating Functions $\newcommand{\nats}{\mathbb{N}}$
Every series of natural numbers corresponds to a [generating function](https://en.wikipedia.org/wiki/Generating_function). It can often be comfortably obtained from a recurrence to have its coefficients -- the series' elements -- plucked.
This answer includ... |
###Method###
The nicest method I have seen is one that expresses the automaton as equation system of (regular) languages which can be solved. It is in particular nice as it seems to yield more concise expressions than other methods.
Let $A= (Q,\Sigma,\delta,q_0,F)$ an NFA without $\varepsilon$-transitions. For ev... |
New to the world of software verification and synthesis. It was suggested to me that the book "Principles of Model Checking" is a good ref for verification, but I am clueless about synthesis. Could someone refer a good book?
Thank you in advance. |
Reference Request for Synthesis |
|reference-request|formal-methods| |
This problem, I found it while I read a ACM's problem and It's about of dynamic programming. The problem say that you have a square matrix $n\times n$ fills with 1's or 0's, like that:
$\begin{bmatrix} 1 &1 &1 &0\\ 1 &1 &1 &1\\ 0 &0 &1 &0\\ 1 &1 &1 &1 \end{bmatrix}$
-------------------------------------------------... |
Problem contest with matrix and DP |
|dynamic-programming| |
This problem, I found it while I read a ACM's problem and It's about of dynamic programming. The problem say that you have a square matrix $n\times n$ fills with 1's or 0's, like that:
$$\begin{bmatrix} 1 &1 &1 &0\\ 1 &1 &1 &1\\ 0 &0 &1 &0\\ 1 &1 &1 &1 \end{bmatrix}$$
-----------------------------------------------... |
#include<stdio.h>
#include<iostream>
#define MAX 100
using namespace std;
int main(){
int n;
cin>>n;
bool has_all_ones[MAX][MAX][MAX];//dim, row, col
for(int row=0; row<n; row++)
for(int col=0; col<n; col++)
ci... |
The following finds the largest matrix dynamically in $O(n^3)$.
#include<stdio.h>
#include<iostream>
#define MAX 100
using namespace std;
int main(){
int n;
cin>>n;
bool has_all_ones[MAX][MAX][MAX];//dim, row, col
for(int row=0; row<n; r... |
null |
The following finds the largest matrix dynamically in $O(n^3)$.<br />
The algorithm first reads from the standard input which matrices of dimension 1x1 have all ones. Then it computes all the matrices of dimension 2x2 that have all ones. Then all 3x3 matrices, etc. up to all the n by n matrices (just one) that have al... |
The following finds the largest matrix dynamically in $O(n^3)$.<br />
The algorithm first reads from the standard input which matrices of dimension 1x1 have all ones. Then it computes all the matrices of dimension 2x2 that have all ones. Then all 3x3 matrices, etc. up to all the n by n matrices (just one) that have al... |
An $O(n^2)$ algorithm is possible.
Let $A$ be the given matrix.
You compute the side of largest square with the bottom right corner at $(i,j)$, say $S(i,j)$
Now we can compute the side of the larger square for $(i+1, j+1)$ in terms of $S(i,j), S(i+1,j), S(i,j+1)$
as
$$S(i+1,j+1) = \min \{S(i,j), S(i+1,j)... |
null |
I will assume the person stating the problem actually meant $\Theta$ where you write $O$; otherwise the question is trivial as [Juho points out](http://cs.stackexchange.com/a/3298/98). Realising this may very well have been the point of the problem (or an intended shortcut for the observant), though.
Here is one bas... |
null |
Is Huffman coding **always** optimal since it uses Shanon's ideas ?
What about text, image, video, ... compression?
Please name papers or books discussing these algorithms.
Thanks
**[UPDATE]**
Is this subject still active in the field? |
Pumping Lemma for regular language for $a^n$ where $n$ is even fails |
null |
null |
|algorithms|dynamic-programming| |
In the book 'Introduction to Algorithms 3/e', I have found the following definition of Binary Search Tree property.
Let $x$ be a node in a binary search tree. If $y$ is a node in the left subtree
of $x$, then $y.key \leq x.key$. If $y$ is a node in the right subtree of $x$, then $y.key \geq x.key$.
My confusion ... |
Binary Search Tree Property |
|search-trees| |
You're not wrong, but neither are they. The normal formulation is to have the left subtree values be strictly less than ($<$) the current value and the right greater than or equal to ($\geq$) the current value, or vice versa ($\leq$ and $>$), however using $\leq$ and $\geq$ still results in a working BST in the sense t... |
|terminology|data-structures|binary-trees|search-trees| |
Given a connected and directed graph $G=(V,E)$ with positive weights on the edges. for every $t>0$ we define $E(t)$ to be the group of edges with weight lower or equal then $t$. I need to find an efficient algorithm which compute the minimal $t$ such that $G(t)=(V,E(t))$ is connected.
I can sort all the edges with ... |
For a grapg $G$ find the minimal $t$ such $G(t)=(V,E(t))$ is connected |
|algorithms|graphs| |
The equality is allowed when multiple nodes may have the same key.
Consider:
c
b d
a c c e
In order to find all `c` elements, you have to descend both subtrees of the topmost `c`, but only the right subtree of `b`, and the left subtree of `d`. |
1. Compute a [minimum bottleneck spanning tree][1] of the graph. (Actually just compute a minimum spanning tree, as a minimum spanning tree is a minimum bottleneck tree.)
2. Determine the maximum edge weight from MBST, this will be your $t$.
3. Remove all edges whose weight is higher.
This can be done in linear ... |
For a graph $G$ find the minimal $t$ such $G(t)=(V,E(t))$ is connected |
In the book 'Introduction to Algorithms 3/e', I have found the following definition of Binary Search Tree property:
> Let $x$ be a node in a binary search tree. If $y$ is a node in the left subtree
of $x$, then $y.key \leq x.key$. If $y$ is a node in the right subtree of $x$, then $y.key \geq x.key$.
My confusio... |
null |
null |
You're not wrong, but neither are they. The normal formulation is to have the left subtree values be strictly less than ($<$) the current value and the right greater than or equal to ($\geq$) the current value, or vice versa ($\leq$ and $>$), however using $\leq$ and $\geq$ still results in a working BST in the sense t... |
Given a connected and directed graph $G=(V,E)$ with positive weights on the edges. for every $t>0$ we define $E(t)$ to be the group of edges with weight lower or equal than $t$. I need to find an efficient algorithm which computes the minimal $t$ such that $G(t)=(V,E(t))$ is connected.
I can sort all the edges with... |
null |
I tried to find a simple example for a language that is not parseable with an LL(1) parser. I finally found this language.
$$L=\{a^nb^m|n,m\in\mathbb N\land n>m\}$$
Is my hypothesis true or is this language parseable with an LL(1) parser?
One can use this simple grammar to describe $L$ (of course it is isn't L... |
Is this language LL(1) parseable? |
|context-free|parsers| |
I tried to find a simple example for a language that is not parseable with an LL(1) parser. I finally found this language.
$$L=\{a^nb^m|n,m\in\mathbb N\land n\ge m\}$$
Is my hypothesis true or is this language parseable with an LL(1) parser?
One can use this simple grammar to describe $L$ (of course it is isn'... |
Your proposed solution does not correspond to the defined language. Take the example "ab" which is a member of $L = \{a^n b^m \mid n, m \in \mathbb{N} \land n \geq m \}$, but not your grammar.
To satisfy a LL(1) grammar, the production rules must not contain left recursions and one input token corresponds to exactly... |
Your proposed solution does not correspond to the defined language. Take the example "ab" which is a member of $L = \{a^n b^m \mid n, m \in \mathbb{N} \land n \geq m \}$, but not your grammar.
To be a LL(1) grammar, the production rules must not contain left recursions and one input token corresponds to exactly one ... |
null |
1. Compute a [minimum bottleneck spanning tree][1] of the graph. (Actually just compute a minimum spanning tree, as a minimum spanning tree is a minimum bottleneck tree.)
2. Determine the maximum edge weight from MBST, this will be your $t$.
3. Remove all edges whose weight is higher.
This can be done in linear ... |
Given a directed and strongly connected graph $G=(V,E)$, weight function $w: E \to \mathbb{R}$ and two distinct vertices $u,v \in V$. We know that there aren't negative cycles.
I need to find algorithm, efficient as possible,such that for every value of $k$, $2 \leq k \leq |V|-1$, it will find the lightest weight of a... |
Find the lightest weight of a path between $u$ to $v$ that contains no more then $k$ edges (If there's one) |
|algorithms|graphs| |
Your proposed solution does not correspond to the defined language. Take the example "ab" which is a member of $L = \{a^n b^m \mid n, m \in \mathbb{N} \land n \geq m \}$, but not your grammar <ins>(as pointed out in the comments, this statement is false)</ins>.
To be a LL(1) grammar, the production rules must not co... |
<del>Your proposed solution does not correspond to the defined language. Take the example "ab" which is a member of $L$, but not your grammar.</del>
To be a LL(1) grammar, the production rules must not contain left recursions and has to be unambiguous. The following grammar <del>satisfies</del> <ins>does not satisfy... |
<del>Your proposed solution does not correspond to the defined language. Take the example "ab" which is a member of $L$, but not your grammar.</del>
To be a LL(1) grammar, the production rules must not contain left recursions and has to be unambiguous. The following grammar <del>satisfies</del> <ins>does not satisfy... |
Although the reduction from vertex cover problem to set cover problem is quite simple, I did not find anywhere the reduction in the opposite direction. From the similarity in the type of problems, I guess this reduction should be simple too. However, despite trying for some time, I could not develop this. So, any ideas... |
Reduction from set cover problem to vertex cover problem |
|np-complete|reductions| |
I am currently working my way through [An Introduction to Analysis of Algorithms][1] to stay sharp with recurrences as well as learn generating function techniques. However my analyses and the books analyses for the first few sample problems on ordinary generating functions differ. I've checked and rechecked [my work a... |
Error in Generating Function Solution |
|recurrence-relation|mathematical-analysis| |
There is a version of the Lempel-Ziv algorithm which is optimal in some scenarios. Namely, if the input comes from an ergodic Markov chain, then the asymptotic rate of the Lempel-Ziv algorithm equals the entropy. For more on that, take a look at Chapter 13 of Cover and Thomas. |
Suppose that the sets are $S_1,\ldots,S_n$ and the elements are $x_1,\ldots,x_m$. For each set $S_i$ there will correspond a vertex $S_i$. For each element $x_j$ there will correspond $n$ vertices $x_j^{(1)},\ldots,x_j^{(n)}$. There is also an additional vertex $t$. Finally, assume wlog that the optimal solution for se... |
Consider the dynamic programming formulation of Bellman-Ford:
$\qquad \displaystyle \mathrm{bf}(i,j) = \begin{cases}
0 &, i = 0 \land j = s \\
\infty &, i = 0 \land j \neq s \\
\min\limits_{k \in V}\, \big(\, \mathrm... |
|formal-languages|formal-grammars|context-free|parsers| |
Kurki-Suonio has shown some helpful properties [1]:
> **Theorem 1**
> Each LL(k) grammar is unambiguous.
That means any [inherently unambiguous language](https://en.wikipedia.org/wiki/Ambiguous_grammar#Inherently_ambiguous_languages) is not LL(1).
> **Theorem 9**
> For any $k>1$ the grammar $G$:
>
> $\... |
|complexity-theory|np-complete|reductions| |
|recurrence-relation|mathematical-analysis|check-my-proof| |
You're not wrong, but neither are they. The normal formulation is to have the left subtree values be strictly less than ($<$) the current value and the right greater than or equal to ($\geq$) the current value, or vice versa ($\leq$ and $>$), however using $\leq$ and $\geq$ still results in a working BST in the sense t... |
We can get some sort of upper bound from some complexity inclusions.
$TC^{0}$ is the class of polynomially sized, constant depth boolean circuits where we also have a $MAJORITY$ gate of unbounded fan-in, so there's a size $1$ $TC^{0}$ circuit that computes the function you want (one $MAJ$ gate with all the inputs go... |
null |
null |
Your language correspond to the famous dangling else problem and it is well known that no $LL(k)$ grammar is able to parse it. The reason is that a $LL(k)$ grammar should be able to decide if a $a$ is paired with a $b$ when the $a$ is seen and the next $k$ symbols may be $a$.
Note that to make it $LR(1)$ you can't u... |
Your language correspond to the famous dangling else problem and it is well known that no $LL(k)$ grammar is able to parse it. The reason is that a $LL(k)$ grammar should be able to decide if a $a$ is paired with a $b$ when the $a$ is seen and the next $k$ symbols may be $a$.
Note that to make it $LR(1)$ you can't u... |
I found this problem while I was reading an ACM problem and it is about dynamic programming. The problem says that you have a square matrix $n\times n$ filled with 1's or 0's, like this:
$$\begin{bmatrix} 1 &1 &1 &0\\ 1 &1 &1 &1\\ 0 &0 &1 &0\\ 1 &1 &1 &1 \end{bmatrix}$$
-------------------------------------------... |
null |
I found this problem while I was reading an ACM problem and it is about dynamic programming. The problem says that you have a square matrix $n\times n$ filled with 1's or 0's, like this:
$$\begin{bmatrix} 1 &1 &1 &0\\ 1 &1 &1 &1\\ 0 &0 &1 &0\\ 1 &1 &1 &1 \end{bmatrix}$$
-------------------------------------------... |
Kurki-Suonio has shown some helpful properties [1]:
> **Theorem 1**
> Each LL(k) grammar is unambiguous.
That means any [inherently unambiguous language](https://en.wikipedia.org/wiki/Ambiguous_grammar#Inherently_ambiguous_languages) is not LL(1).
> **Theorem 9**
> For any $k>1$ the grammar $G$:
>
> $\... |
Kurki-Suonio has shown some helpful properties [1]:
> **Theorem 1**
> Each LL(k) grammar is unambiguous.
That means any [inherently ambiguous language](https://en.wikipedia.org/wiki/Ambiguous_grammar#Inherently_ambiguous_languages) is not LL(1).
> **Theorem 9**
> For any $k>1$ the grammar $G$:
>
> $\qq... |
what is the complexity of below relation
$ T(n) = 2*T(\sqrt n) + \log n$
and $T(2) = 1$
|
what is the complexity of recurrence relation? |
|complexity-theory|recurrence-relation| |
|asymptotics|recurrence-relation| |
what is the complexity of below relation
$ T(n) = 2*T(\sqrt n) + \log n$
and $T(2) = 1$
Is it $\Theta (\log n * \log \log n)$ ?
|
null |
Yes, the answer is $\lg n \cdot \lg \lg n$:
Reason this out by expanding the recurrence and looking for a pattern:
\begin{align*}
T(n) &= 2T(\sqrt{n}) + \lg n \\
&= 2( 2T( \sqrt[4]{n} ) + \log(\sqrt{n}) ) + \lg n \\
&= 2\left( 2T(\sqrt[4]{n}) \frac{1}{2} \lg n \right) + \lg n \\
&= 4T( \sqrt[4... |
Yes, the answer is $\lg n \cdot \lg \lg n$:
Reason this out by expanding the recurrence and looking for a pattern:
\begin{align*}
T(n) &= 2T(\sqrt{n}) + \lg n \\
&= 2( 2T( \sqrt[4]{n} ) + \log(\sqrt{n}) ) + \lg n \\
&= 2\left( 2T(\sqrt[4]{n}) \frac{1}{2} \lg n \right) + \lg n \\
&= 4T( \sqrt[4... |
null |
Though he doesn't say the name Baum Welch specifically, nor HMM's (until the very end) Jason Eisner does a great job covering Expectation Maximization here:
videolectures.net/hltss2010_eisner_plm/ |
Huffman compression, with certain assumptions that usually don't apply to real files, can be proven to be optimal.
Several compression algorithms compress some kinds of files [smaller than the Huffman algorithm][1], therefore Huffman isn't optimal. These algorithms exploit one or another of the caveats in the Huffma... |
For the branch-and-cut method, it is essential to know many facets of the polytopes generated by the problem. However, it is currently one of the hardest problems to actually calculate all facets of such polytopes as they rapidly grow in size.
Considering the Travelling Salesman Problem, for which number of nodes is... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.