instruction
stringlengths
0
29.8k
⌀
null
null
The <b>three disk</b> raid-6 is trivial: Just store the same information on disk 1, disk 2 and disk 3. Any two disks may fail and you can still recover the data. So a three disk raid-6 is basically just a three disk raid-1. In the <b>four disk</b> case, there are two data "disks" (let's call them $A$ and $B$) and tw...
|algorithms|graphs|
null
So I have been given the task of creating an PDA that recognises the language a^2n b^3n | n = 0,1,2...}. Am I right in thinking that it needs to have atleast 3 times number of b's than a's? So for example: aabbb would be accepted aaabb would NOT be accepted However how do I show that using JFlap because I am unf...
Understanding of Push down automata with a difference?
|finite-automata|pushdown-automata|
So I have been given the task of creating an PDA that recognises the language $\{a^{2n} b^{3n} \mid n = 0,1,2,\dots\}$. Am I right in thinking that it needs to have at least 3 times number of $b$'s than $a$'s? So for example: $aabbb$ would be accepted $aaabb$ would NOT be accepted However, how do I show t...
|formal-languages|pushdown-automata|
Yes the number of b's is at least 3 times the number of a's except when n=0 in which case you get the empty string. Your language is equivalent to $\{(aa)^n(bbb)^n:n=0,1,\dots\}$. So if you can find a PDA for $\{a^nb^n\}$, then you can find one for your language.
I have an input array and I have to select a number of T intervals from it so that the "profit" is maximal. Profit means the sum of all the elements of the interval, except for the first element. An interval can consist of a single element, meaning that the profit for such an interval is 0. The array may contain negati...
Select optimal subintervals from array
|dynamic-programming|
Yes the number of b's is at least 3 times the number of a's except when n=0 in which case you get the empty string. Your language is equivalent to $\{(aa)^n(bbb)^n:n=0,1,\dots\}$. So if you can find a PDA for $\{a^nb^n\}$, then you can find one for your language. Here is the transition function $\delta$ (the stack init...
Search for maximum subsequence sum problem, [here][1] you will find a linear time solution. Bentley's ["Programming Pearls"][2] gives several alternative algorithms and some history. The linear time solution is obvious in hindsight, but it took several tries by experts to come up with it... [1]: http://wordalign...
null
Assuming you mean simple cycles (otherwise the number is infinite) - yes, of course the number can be exponential: consider the complete graph on $n$ vertices, then every sequence of distinct vertices can be completed to a simple cycle. So you get at least $n!$ cycles. Even if you ignore cyclic permutations of a cyc...
Can the number of cycles in a graph (undirected/directed) be exponential in the number of edges/vertices? I'm looking for a polynomial algorithm for finding all cycles in a graph and was wondering if it's even possible.
Number of cycles in a graph?
|graphs|
null
null
The problem you want to solve is #CYCLE. Unless P=NP, it cannot be solved, for a proof look at the chapter on Counting Complexity in Arora and Barak. It is a gadget construction that reduces solving Hamiltonian path to #CYCLE and hence unless P=NP, Hamiltonian cycle - a NP-Complete problem cannot have a poly time sol...
try [Latent Semantic Analysis](http://en.wikipedia.org/wiki/Latent_semantic_analysis) or the similar [Latent Semantic Indexing](http://en.wikipedia.org/wiki/Latent_semantic_indexing) which reduces documents to vectors, and typically finds principal components via [Singular value decopmosition, SVD](http://en.wikipedia....
null
The <b>three disk</b> raid-6 is trivial: Just store the same information on disk 1, disk 2 and disk 3. Any two disks may fail and you can still recover the data. So a three disk raid-6 is basically just a three disk raid-1. In the <b>four disk</b> case, there are two data "disks" (let's call them $A$ and $B$) and tw...
For clarity let $T= (V,E)$ be a tournament and let $a \rightsquigarrow b$ denote a path from $a$ to $b$ in $T$. 1. A simple directed cycle clearly gives a tournament with more than one ranking. 2. Suppose there is more than one ranking. Then there exists subpaths $a \rightsquigarrow b$ and $b \rightsquigarrow a$ ...
This is hierarchical clustering method. As you remove edges, at some point the graph will become disconnected: the connected components are your top-level communities. As you keep removing edges, the top-level communities become disconnected too, and you can think of the new smaller connected components as sub-communit...
There is no systematic way, since the expressions in the loop may be arbitrary. For your particular case, assuming that the statements executed are $O(1)$, then the complexity is obviously $O(n)$. If you instead want to determine the exact number of iterations, you may reason as follow. As noted by @blob, you are count...
There is no systematic way, since the expressions in the loop may be arbitrary. For your particular case, assuming that the statements executed are $O(1)$, then the complexity is obviously $O(n)$. If you instead want to determine the exact number of iterations, you may reason as follow. As noted by @blob, you are count...
There is no systematic way, since the expressions in the loop may be arbitrary. For your particular case, assuming that the statements executed are $O(1)$, then the complexity is obviously $O(n)$. If you instead want to determine the exact number of iterations, you may reason as follow. As noted by @blob, you are count...
There is no systematic way, since the expressions in the loop may be arbitrary. For your particular case, assuming that the statements executed are $O(1)$, then the complexity is obviously $O(n)$. If you instead want to determine the exact number of iterations, you may reason as follow. As noted by @blob, you are count...
The following pushdown automaton should do the trick. I publish this only because the existing answer can be improved upon. (Note, I am using $e$ to denote $\epsilon$- (or $\lambda$-) transitions. ![enter image description here][1] The idea is that the left-hand part counts the number of $a$'s (modulo 2). Each...
In my textbook, Data Structures and Algorithms in Java, the author says when implementing a queue using a linked list you choose the front of the queue to be at the head of the list, and the rear of the queue to be at the tail of the list. In this way, you remove from the head and insert at the tail. The author then...
Implement Queue with a Linked List; Why would it be bad to insert at the head and remove at the tail?
|time-complexity|linked-lists|abstract-data-types|
In a single linked list, every element has a pointer to the next element. If you have an additional pointer to the tail element, it takes you a constant number og operations to _add_ to the list at the tail: get the tail pointer, add an element after the tail, put this new element as new tail. Removing from the head...
Removing from the head and inserting at the tail are both constant time operations with a singly linked list, assuming head and tail pointers. Inserting at the tail is also constant time. But removing from the tail means moving the tail pointer toward the head, and since you don't have a back pointer you can't do tha...
You can try simple probabilistic graphical models, the simplest one being [Naive Bayes][1]. One way to do this would be to represent a portion of text as a word frequency vector, that will be associated with a topic (the "class variable"). Then you use many such texts that are associated with topics to train your mo...
In my textbook, Data Structures and Algorithms in Java, the author says when implementing a queue using a linked list you choose the front of the queue to be at the head of the list, and the rear of the queue to be at the tail of the list. In this way, you remove from the head and insert at the tail. The author then...
Implement queue with a linked list; why would it be bad to insert at the head and remove at the tail?
Understanding of push down automata with a difference?
I have two languages $C_1$ and $C_2. \left(\Sigma=\{0,1\}\right)$: $C_1=\{xyz|x,z \in \Sigma^*, y \in \Sigma^*1\Sigma^*, \text{where} |x|=|z| \geq |y|\}$, and $C_2=\{xyz|x,z \in \Sigma^*, y \in \Sigma^*1\Sigma^*1\Sigma^*, \text{where} |x|=|z| \geq |y|\}$ I want to show that $C_1$ is a CFL, while $C_2$ is not a CF...
Proving that a language is CFL, and that a language is not a CFL
|formal-languages|context-free|pumping-lemma|pushdown-automata|
I have an input array and I have to select an indefinite number of intervals from it so that the "profit" is maximal and I have exactly T elements selected in total, where T is given. Profit means the sum of all the elements of an interval, except for the first element. An interval can consist of a single element, mean...
A graph $G$ is *[chordal](http://en.wikipedia.org/wiki/Chordal_graph)* if it doesn't have induced cycles of length 4 or more. Chordal graphs are precisely the class of graphs that admit a *clique tree* representation. A clique tree $T$ of $G$ is a tree in which the vertices of the tree are the maximal cliques of $G$. A...
What is the maximum number of shortest paths between any pair of vertices in a chordal graph?
|graphs|combinatorics|shortest-path|discrete-mathematics|
Instead of a general "formula", you should try to work out from principles first, at least in the beginning. You can see that the number of executions are: $$\sum\limits_{i=1}^{n} \sum\limits_{j=1}^{i} \sum\limits_{k=j}^{i} 1$$ We try solving them one step at a time. The innermost (right-most) summation can be so...
null
It can be exponential in $n/2$. The following graph has $2^{n/2} - 2$ shortest paths between the endpoints:![enter image description here][1] [1]: https://i.stack.imgur.com/ML108.png
It can be exponential in $n/2$. The following graph has $2^{(n/2) - 2}$ shortest paths between the endpoints:![enter image description here][1] [1]: https://i.stack.imgur.com/ML108.png
null
It can be exponential in $n/2$. The following graph has $2^{(n/2) - 2}$ shortest paths between the endpoints:![enter image description here][1] [1]: https://i.stack.imgur.com/ONiuq.png
It can be exponential in $n/2$. The following graph has $2^{(n/2) - 1}$ shortest paths between the endpoints:![Chordal graph with exponentially many shortest paths between a pair][1] This graph has $2^{(14/2)-1} = 2^6 = 64$ different shortest path, each corresponding to a selection of "ups" and "downs". [1]: h...
First you have to realize that the extremes of the strings are of the form $0^n10^{2n-1}$ and $0^{2n-1}10^n$. You can get a language similar to that by the grammar $S \to 1 \mid 0S00 \mid 00S0$. From this some fine-tuning is needed. First to get $1$'s at the places where now only $0$'s are. Then to get the boundery con...
True, all (general purpose) programming languages are believed to be equivalent to the Turing machine. (According to the Church-Turing thesis, they will not compute more, and usually it is clear how to simulate a TM in your favourite language). That does not mean that programming a Turing machine is a practical thing t...
Proving that a specific language is a CFL, and that another language is not a CFL
Consider the following variant of the FACTORING problem: <blockquote> MULTIPLE-FACTORING: Given three integers $1 \leq K \leq M \leq N$ decide if there are at least $K$ factors of $N$ less than $M$ </blockquote> FACTORING $\leq_m$ MULTIPLE-FACTORING (just pick $K=1$) and MULTIPLE-FACTORING $\leq_T$ FACTORING (...
Karp reduction between FACTORING and a variant of it
|factoring|
I have a question whether a language can accept infinite numbers I have to reduce Lempty to Linf where Lempty ={e|L(Pe) is null} Linf={e|L(Pe) is infinite} so can i define a program P like this " input n Run Pe on 1...n for n steps if Pe accept any number then enter an infinite loop and...
Can a Language accept Infinite numbers
|computability|regular-languages|turing-machines|church-turing-thesis|
I have a question whether a language can accept infinite numbers I have to reduce $L_\text{empty}$ to $L_\text{inf}$ where $L_\text{empty} =\{P_e \mid L(P_e) \text{ is null} \}$ and $L_\text{inf}=\{P_e \mid L(P_e) \text{ is infinite}\}$. so can i define a program P like this input n Run Pe on 1....
|computability|reductions|undecidability|
I have a question whether a language can accept infinite numbers I have to reduce $L_\text{empty}$ to $L_\text{inf}$ where $L_\text{empty} =\{e \mid L(P_e) \text{ is null} \}$ and $L_\text{inf}=\{e \mid L(P_e) \text{ is infinite}\}$. where e is the godel number of the program so can i define a program P l...
null
There aren't enough initial values, but still. Define: $$ A(z) = \sum_{n \ge 0} T[n] z^n $$ Properties of ordinary generating functions give for the recurrence: $$ T[n + 4] = T[n + 3] + T[n + 1] + T[n] $$ $$ \frac{A(z) - T[0] - T[1] z - T[2] z^2 - T[3] z^3}{z^4} = \frac{A(z) - T[0] - T[1] z - T[2] z^2}{z^3...
A language cannot contain infinite numbers, since by definitions it is a set of *finite* numbers. The language itself could be infinite, though: it could contain infinitely many numbers. In your solution, in the first case, you first enter an infinite loop and then "start accepting infinite numbers", but once you've...
If you have a dynamic array where the size `s` becomes `4s` when you fill the array and there is no delete operations. How much do you spend per insert? I am asking because when the size doubles, you only spend 3 dollars per insert (based on [this][1] analysis). But when you make the size 4 times bigger, then for so...
amortized analysis accounting method
|amortized-analysis|
If you have a dynamic array where the size $s$ becomes $4s$ when you fill the array and there are no delete operations. How much do you spend per insert? I am asking because when the size doubles, you only spend 3 dollars per insert (based on [this][1] analysis). But when you make the size 4 times bigger, then for s...
This question arises from my reading of ["Types and Programming Languages"][1] ([WorldCat][2]) by Benjamin C. Pierce. On page 36 is the definition for *satisfied* > A rule is *satisfied* by a relation if, for each instance of the rule, > either the conclusion is in the relation or one of the premises is > not. ...
|satisfiability|operational-semantics|small-step-semantics|term-rewriting|
I have two languages $C_1$ and $C_2. \left(\Sigma=\{0,1\}\right)$: $C_1=\left\{xyz\mid x,z \in \Sigma^*, y \in \Sigma^*1\Sigma^*, \text{ where } |x|=|z| \geq |y|\right\}$, and $C_2=\left\{xyz\mid x,z \in \Sigma^*, y \in \Sigma^*1\Sigma^*1\Sigma^*, \text{ where } |x|=|z| \geq |y|\right\}$ I want to show that $C_1$...
If you have an array that expands when it is completely filled and the new size is `N = N + 1 + ceiling(log2(N))` (N is the current size, and then N becomes the new size) (log2 is log base 2). How can you do an amortized analysis for this? It is confusing because the size of the expansion of the array increases a...
How to do amortized analysis for an expanding array?
|amortized-analysis|
null
null
I am currently learning how randomised Hashing works. So, you have a class (aka family) $H$ of hash functions, each of which maps the universe $U$ to the hash table $N$. That class is called "strongly universal" or "pairwise independant" if $\forall x,y \in U, x \neq y: \forall z_1,z_2 \in N: \Pr\limits_{h \in H}[...
Hash function - uniformity / strong universality
|algorithms|randomized-algorithms|
This looks like a homework problem, so I will try to highlight the skeleton of the proof. 1. The cost of inserting and taking an element out of an array is `1` 2. The cost of resizing an array is equal to the number of elements moved to the new/bigger array. 3. As a simple case, consider you increase the size...
This looks like a homework problem, so I will try to highlight the skeleton of the proof. 1. The cost of inserting and taking an element out of an array is 1 2. The cost of resizing an array is equal to the number of elements moved to the new/bigger array. 3. As a simple case, consider you increase the size o...
I am currently learning how randomised Hashing works. So, you have a class (aka family) $H$ of hash functions, each of which maps the universe $U$ to the hash table $N$. That class is called "strongly universal" or "pairwise independent" if $\forall x,y \in U, x \neq y: \forall z_1,z_2 \in N: \Pr\limits_{h \in H}[...
Arnab provided the answer. The family $\mathcal{H} = \{h_i : i \in N\}$, where $h_i(x) = i$ for all $x \in U$, is uniform but not pairwise independent. Similarly you can come up with families which are pairwise but not $3$-wise independent, and so on. To give a simple example, let $X,Y$ be two independent uniformly ...
First you have to realize that the extremes of the strings are of the form $0^n10^{2n-1}$ and $0^{2n-1}10^n$. You can get a language similar to that by the grammar $S \to 1 \mid 0S00 \mid 00S0$. From this some fine-tuning is needed. First to get $1$'s at the places where now only $0$'s are. Then to get the boundary con...
|machine-learning|natural-language-processing|
Constructing PDA for $a^{2n} b^{3n}$
|complexity-theory|reductions|factoring|np|
I don't know much about yacc, bison, flex or lex and please correct me if I'm wrong but a programming language is also a Turing machine and a Turing machine is defined as the tuple $(Q, \Gamma, b, \Sigma, \delta, q_0, F)$ where $Q$, $\Gamma$, $b \in \Gamma$, $\Sigma \subseteq \Gamma \smallsetminus \{ b \}$ as input, $\...
null
I have to reduce $L_\text{empty}$ to $L_\text{inf}$ where $\qquad L_\text{empty} = \{e \mid |L(P_e)| = 0 \}$ and $\qquad L_\text{inf}= \{e \mid |L(P_e)| = \infty \}$. where $P_e$ is the program with Gödel number $e$, and $L(P_e)$ the language it accepts. So can I define a program $P$ like this ...
Can I use infinite numbers in a reduction?
{"OriginalQuestionIds":[10399],"Voters":[{"Id":98,"DisplayName":"Raphael"}]}