instruction
stringlengths
0
29.8k
⌀
In the latter you are given the string $s$ that you are looking for in the former. An algorithm for the first one is to search for a string $s$ (try all strings) and run the latter procedure and verify that the set you get is the entire set.
There is the well-known method of unbiasing of bit sequences due to von Neumann. Are there similar schemes applicable to other sequences, e.g. the result of throwing a normal die?
Unbiasing of sequences
|probability-theory|
|algorithms|graphs|search-algorithms|graph-traversal|
If they were all linked to make a condition such as ($1 < i < j < k < n$), I know how to solve, but the last loop is disconnected so I have no clue on how to do these... the ones like for(i = 1 to n); for(j = i to n); x++; I can use $1 \leq i \leq j \leq n$ and use $x_1 + x_2 + x_3 = n-1...
Analyzing programs with multiple for-loops
|algorithm-analysis|runtime-analysis|loops|
Vonbrand already provided an answer for the case where the strings are defined over $\{0,1\}$. I'm considering the larger alphabet $\{0,1,2\}$ (this can easily be extended to any other alphabet, $2$ basically stands for anything but a $0$ or a $1$). The answer still depends on $n$ and $m$ - If $m<n$, you need sep...
*For a 4 - bit multiplier there are 2<sup>4</sup> * 2<sup>4</sup> = 2<sup>8</sup> combinations. The output of 4 bit multiplication is 8 bits so the amount of ROM needed is 2<sup>8</sup> * 8 = 2048 = 2Kbits* how is it ? why does the ROM need all the combinations embedded into it ? what will be the case with RAM ...
The amount of ROM neede to implement a 4-bit multiplier?
|computer-architecture|
null
You can generalize the von-Neumann procedure canonically. Assume you have a discrete RV $X$ which you want to make fair, i.e., each event in the event space $\Omega$ of $X$ shall occur with the same probability. Then you can redraw $X$ exactly $n:=| \Omega|$ times, yielding $x_1, \ldots, x_n$. In case $x_1 \not = \ldot...
For a 4-bit multiplier there are $2^4 \cdot 2^4 = 2^8$ combinations. The output of 4-bit multiplication is 8 bits, so the amount of ROM needed is $2^8 \cdot 8 = 2048$ bits. Why is that? Why does the ROM need all the combinations embedded into it? What will be the case with RAM?
The amount of ROM needed to implement a 4-bit multiplier?
null
You can generalize the von-Neumann procedure canonically. Assume you have a discrete RV $X$ which you want to make fair, i.e., each event in the event space $\Omega$ of $X$ shall occur with the same probability. Then you can redraw $X$ exactly $n:=| \Omega|$ times, yielding $x_1, \ldots, x_n$. In case $x_1 \not = \ldot...
I've been working with suffix arrays lately, and I can't find an efficient algorithm for building a suffix array which is easy to understand. I have seen in many sites that there is an $o(n^2 \log n)$ algorithm, but I can't understand it, as many important details are omitted. There's an example at [Top Coder][1]. ...
The following simpler adaptation of von Neumann's trick is more efficient than the one described in HdM's answer. Throw your die twice. If the two answers $x,y$ are different, write $0$ if $x<y$ and $1$ if $x>y$. This way, you get an unbiased bit source. If you are so inclined, you can use this bit source to simulate f...
I've been working with suffix arrays lately, and I can't find an efficient algorithm for building a suffix array which is easy to understand. I have seen in many sites that there is an $o(n^2 \log n)$ algorithm, but I can't understand it, as many important details are omitted. There's an example at [Top Coder][1]. ...
|algorithms|data-structures|strings|
If you are storing all the value of the function (in this case, multiplication) in a big table, then the size of this table is $2^{\text{# input bits}}\cdot \text{# output bits}$. This becomes impractical rather quickly, so CPUs implement arithmetic operations differently.
I am a bit confused. Somehow I have a problem connecting two problems together. The Closest String problem and the problem of matching with mismatches. They seam to be related but, I fail to see the connection. The Closest String problem is defined as : >*Instance:* Strings $S_{1},S_{2}...S_{n}$ over alphabet $\S...
|np-complete|decision-problem|matching|
|reference-request|probability-theory|
I've been working with suffix arrays lately, and I can't find an efficient algorithm for building a suffix array which is easy to understand. I have seen in many sites that there is an $O(n \log^2 n)$ algorithm, but I can't understand it, as many important details are omitted. There's an example at [Top Coder][1]. ...
Algorithm for building a suffix array in time $O(n \log^2 n)$
As shown in the figure bellow (general architecture of ROM): to address 8-bit numbers correctly your ROM size should be: $2^8 \times 8$ bits. ![enter image description here][1] [1]: https://i.stack.imgur.com/TNLtQ.png
I have to make a regular expression from the following laguage: > {$a^kb^mc^n : $ where _k_ + _m_ + _n_ is odd} Is is possible for the sum of three numbers to be odd (other than three consecutive odd numbers)? I have this so far: > {(abbbccccc) + (abbbbbccc) + (aaabccccc) + (aaabbbbbc) + (aaaaabccc) + (aaaa...
Regular expressions derived from languages
|regular-expressions|
It seems to me that presumably the only viable satisfactory solution would be: Obtain a bit sequence from the sequence from the die, apply the von Neumann unbiasing, then generate from that a sequence for the die.
null
What you need is that either two are even, or all three are odd. This gives: $$ a (a a)^* (b b)^* (c c)^* \mid (a a)^* b (b b)^* (c c)^* \mid (a a )^* (b b)^* c (c c)^* \mid a (a a)^* b (b b)^* c (c c)^* $$
$a(aa)^\ast (bb)^\ast (cc)^\ast + (aa)^\ast b(bb)^\ast (cc)^\ast + (aa)^\ast (bb)^\ast c(cc)^\ast + a(aa)^\ast b(bb)^\ast c(cc)^\ast $
1. Not a counter model, for as you say, the antecedent is not true when $x = 0$. 1. A counter model: Every number has a number less than it in $\mathbb{R}$, however there are no least number. 1. A counter model: For $x$, let $y = 1/x$, so the antecedent holds, there is no $y$ such that for all $x$, we have that ...
Theoretically speaking, is it possible to have a Lisp/Scheme compiler that can produce code that can compete with compiled C, let's say within 15-25% margin? In my testing, I've found that the current crop of compilers (Bigloo, SBCL, Gambit, Chicken, etc) are **20-50 times slower than equivalent C code**. The **o...
Quality LISP/Scheme compilers to compete with C/C++
|optimization|compilers|
I am interested to know the complexity of $NAE$-$HORN$-$SAT$ problem. We know that $HORNSAT$ is $P$-Complete. On the other hand, $NAE$-$SAT$ is $NP$-Complete. I want to know what can we say about $NAE$-$HORN$-$SAT$ problem. Let me define the problem formally: $Given$: One Boolean formula $\phi$ is given to us in $CN...
NAE-HORN-SAT.... P or NP -Complete?
|complexity-theory|
First of all, an array *is* and has *always been* a function. It is a function from the set of indices (1..10 in your example) to *memory locations* that hold the array elements. When we write $a[i]$ in the programming language, we are just using stylized notation for saying $a(i)$, i.e., apply the function $a$ to $i...
PSB. given a tube with numbered balls(random) and tube has holes to remove ball. consider following operations 1)you can pick one or more balls from the holes and remember the order in which you picked the balls. 2) You need to tilt the pipe towards left side so that remaining balls in the pipe shifts towards ...
Intresting problem on sorting
|sorting|permutations|
Given a tube with numbered balls (random). The tube has holes to remove a ball. Consider the following steps for one operation: 1. You can pick one or more balls from the holes and remember the order in which you picked the balls. 2. You need to tilt the pipe towards left side so that remaining balls in the pipe ...
I am considering what elements an operating system for Network On Chip systems might have and the issue of file systems looms large. NoCs have an embedded heritage, and their domain of use (at least initially) is likely to be similar tasks to embedded systems. But I cannot find any studies of embedded system file ac...
Studies of file access patterns in embedded systems
|reference-request|
There are 6 possibilities which is easy to express as a regular expression $\{a(aa)^*b(bb)^*c(cc)^*|a(aa)^*(bb)^*(cc)^*|(aa)^*b(bb)^*(cc)^*|(aa)^*(bb)^*c(cc)^*\}$ which correspond to the cases all three odd, or two even and one odd. No other case is possible.
Here is a reduction of CNF-SAT. In a given CNF formula, assume we have variables $x_1, \dots, x_n$ and clauses $C_1, \dots, C_m$. We construct a DAG with edge colors as follows. We have $m$ colors, and each color corresponds to a clause. In our DAG, we have vertices $v_0$, $v_1$, ..., $v_n$, and $v_0$ is the ...
I'd appreciate any pointer for the following problem. Given a DAG G=(V,E), each edge has assigned a color from a set of colors C. Different edges may have assigned the same color. There is a special start node s and end node t. Given K, we would like to find a s-t shortest path on G that traverses exactly K disti...
Shortest path on a colored DAG
|algorithms|graphs|
This is the homework question: >$ \{w \in \{a, b, c\}^* : \text{(no symbol occurs twice in succession in w)}\} $ This is my answer: > $$\{((abc)^*| (acb)^*| (ab)^* | (ac)^*)^* | (bac)^* | (bca)^* | (ba)^* | (bc)^*)^* | ((cab)^* | (cba)^* | (ca)^* | (cb)^*)^* | ((\epsilon +a) | (\epsilon + b) | (\epsilon+c)) \} $...
Simplifying regular expressions
|regular-expressions|
Define the *run-partition number* of a permutation $\pi$, denoted $r(\pi)$, using the following process. Let $k$ be the maximal integer such that the numbers $\min(\pi),\ldots,k$ appear in increasing order in $\pi$. Remove them from $\pi$, and repeat the process. The number of rounds it takes to consume the entire perm...
Let's solve this exercise "by induction". Suppose first that the alphabet is only $a,b$. In this case, the only possible words are $ababab\ldots$ and $bababa\ldots$, and you can write a simple regular expressions for them. Now take such a word over the alphabet $a,b,c$. You can break it apart as $w_1 c w_2 c w_3 c \ldo...
What is the correct way to write a CFG? A -> B C' D C' -> C C' -> null or A -> B C' C' -> C E C' -> E
Can a CFG end have a non-terminal symbol in the middle of it?
|formal-grammars|
What is the correct way to write a CFG? A -> B C' E C' -> C C' -> null or A -> B C' C' -> C E C' -> E
Both of those are valid context-free grammars. (For the same language.) The requirement for a context-free grammar is just that the left side of the production must have exactly one non-terminal, which both of them satisfy. (Usually, to make this more clear, we'd have a convention like non-terminals are uppercase and v...
[{"Id":39,"DisplayName":"Gilles"}]
[{"Id":39,"DisplayName":"Gilles"}]
Regular expression for {a^k b^m c^n | k+m+n is odd}
|reference-request|parallel-computing|filesystems|
**Input:** A set of $\ell$ arrays $A_i$ (of numbers). <br> The elements within each array are in sorted order, but the set of arrays is not necessarily sorted. The arrays are not necessarily the same size. The total number of elements is $n$. **Output:** The $k$th smallest element out of all elements in the i...
Find the median of a list of lists
|algorithms|algorithm-analysis|
Define the *run-partition number* of a permutation $\pi$, denoted $r(\pi)$, using the following process. Let $k$ be the maximal integer such that the numbers $\min(\pi),\ldots,k$ appear in increasing order in $\pi$. Remove them from $\pi$, and repeat the process. The number of rounds it takes to consume the entire perm...
An $\ell$-way merge takes time $\Theta(n \log \ell)$ (use an efficient way to represent a priority queue of the head elements in each list), then you pick the $k$-th element in constant time. I think this is discussed in Knuth's "Sorting and searching".
An $\ell$-way merge takes time $\Theta(n \log \ell)$ (use an efficient way to represent a priority queue of the head elements in each list), then you pick the $k$-th element in constant time. I think this is discussed in Knuth's "Sorting and searching" for sorting. Getting the smallest (or largest) clearly takes $\The...
Schaefer's dichotomy theorem actually doesn't necessarily apply in this case, since the width of clauses in a NAE-HORN-SAT formula isn't bounded. What Schaefer's theorem does give you is an algorithm which decides, for each $k$, whether the restriction of NAE-HORN-SAT to clauses of width $k$ (or up to $k$) is in P or N...
null
Conditions for Famous Grammars: (YOU MUST NEVER FORGET THE FOLLOWING) 1) Regular Grammars : Grammar That is either Right linear or Left Linear Grammar This is also called Type 3 Grammar 2) Context Free Grammar : LHS must be exactly 1 Non-terminal , RHS can be any String of terminals and Non--Terminals. T...
Schaefer's dichotomy theorem actually doesn't necessarily apply in this case, since the width of clauses in a NAE-HORN-SAT formula isn't bounded. What Schaefer's theorem does give you is an algorithm which decides, for each $k$, whether the restriction of NAE-HORN-SAT to clauses of width $k$ (or up to $k$) is in P or N...
Many max flow algorithms that I commonly see implemented, Dinic's algorithm, push relabel, and others, can have their asymptotic time cost improved through the use of [dynamic trees][1] (also known as link-cut trees). - Push relabel runs in $O(V^2E)$ or $O(V^3)$ or $O(V^2\sqrt{E})$ normally, but with dynamic trees ...
Are link-cut trees ever used in practice, for max flow computation or other applications?
|graphs|data-structures|network-flow|
null
1. Not a counter model, for as you say, the antecedent is not true when $x = 0$. 1. A counter model: Every number has a number less than it in $\mathbb{R}$, however there are no least number. 1. A counter model: For $x$, let $y = 1/x$, so the antecedent holds, there is no $y$ such that for all $x$, we have that ...
I have the following problem: > Given an edge-colored DAG $G = (V,A)$, vertices $s$ and $t$, a set of colors $C$ and $k \in \mathbb{N}$, > does there exist a path from $s$ to $t$ using exactly $k$ distinct colors? Can anyone provide pointers to the complexity of this problem? More specific, is it $\mathsf{...
Shortest path on an edge-colored DAG
null
|terminology|formal-grammars|context-free|
|regular-languages|regular-expressions|
|reference-request|graphs|data-structures|network-flow|
|algorithms|graphs|shortest-path|
Path on an edge-colored DAG using exactly $k$ colors
I am interested to know the complexity of the NAE-HORN-SAT problem (not all equal). We know that HORNSAT is $\mathsf{P}$-complete, but on the other hand, NAE-SAT is $\mathsf{NP}$-complete. I want to know what can we say about NAE-HORN-SAT problem. Let me define the problem formally: > Given: One Boolean formu...