instruction
stringlengths
0
29.8k
⌀
Applying Baum-Welch to multiple observed sequences iteratively
|hidden-markov-models|
Consider array $A=(a_1,a_2,...,a_n)$ such that $a_i$s are positive integers. Moreover, we have $k$ binary tuples, each with length $n$. In each iteration, we choose one of those tuples, and decrease it from the array. For example, if $A=(5,7,4,2)$ and we decrease $(1,0,0,1)$ from it, it will become $(4,7,4,1)$. We cann...
null
You can reduce from exact-cover by $3$-sets (X3C): given a set $X$ of $3n$ elements $x_1, \dots, x_n$, and a collection $S = \{S_1, \dots, S_m\}$ of $m$ sets each containing exactly $3$ elements, is there an exact cover, i.e., a subset $S'$ of $S$ such that $|S'|=n$ and $\cup_{S_j \in S'} S_j = X$? Consider the inst...
Consider array $A=(a_1,a_2,...,a_n)$ such that $a_i$s are positive integers. Moreover, we have $k$ binary tuples, each with length $n$. In each iteration, we choose one of those tuples, and decrease it from the array. For example, if $A=(5,7,4,2)$ and we decrease $(1,0,0,1)$ from it, it will become $(4,7,4,1)$. We cann...
Consider array $A=(a_1,a_2,...,a_n)$ such that $a_i$s are positive integers. Moreover, we have $k$ binary tuples, each with length $n$. In each iteration, we choose one of those tuples, and decrease it from the array. For example, if $A=(5,7,4,2)$ and we decrease $(1,0,0,1)$ from it, it will become $(4,7,4,1)$. We cann...
Consider array $A=(a_1,a_2,...,a_n)$ such that $a_i$s are positive integers. Moreover, we have $k$ binary tuples, each with length $n$. In each iteration, we choose one of those tuples, and decrease it from the array. For example, if $A=(5,7,4,2)$ and we decrease $(1,0,0,1)$ from it, it will become $(4,7,4,1)$. We cann...
null
Just a quick association to your tree structures and Fibonacci numbers. The numbering scheme and hence the tree structure seems related to the concept of *exponentiation by squaring*. The power of a number (or matrix) can be recursively computed as follows. - $A^{2n} = A^n * A^n $ - $A^{2n+1} = A * A^{2n} $ I...
Just a quick association to your tree structures and Fibonacci numbers. The numbering scheme and hence the tree structure seems related to the concept of *exponentiation by squaring*. The power of a number (or matrix) can be recursively computed as follows. - $A^{2n} = A^n * A^n $ - $A^{2n+1} = A * A^{2n} $ I...
Hi i am practising standard theta notation: How could i find the standard theta notation of the following : - ```2n + 3n^2(log n)^3 + 2``` and - ```((2n^2 + 7n+5)(7n+1))/7``` So far i have used the "drop constants and find dominating term" strategy where we remove the constants from the expressions and then w...
How to find the standard theta notation of this?
|time-complexity|asymptotics|big-o-notation|
null
Let $L$ be an arbitrary language in $\Sigma_3$. Thus it can be written that $x \in L \Leftrightarrow \exists y^{p(|x|)} \forall z^{p(|x|)} \exists w^{p(|x|)} \langle x,y,z,w \rangle \in B$ where $p(\cdot)$ is some polynomial function and $B$ is some language in $P$. While giving a reduction from $L$ to $\Sigma_3$-SA...
There seems to be a misunderstanding in the linked proof. If the input is $r_1 \cdots r_k$, then $T_{i,r_i,0}$ will be true for each $i=1,\dots,k$. If $x_i$ is the $i$th bit of $x$, so that $r_i=x_i$, then we have a clause $x_i \Leftrightarrow T_{i,1,0}$ and $\neg x_i \Leftrightarrow T_{i,0,0}$, both of which are e...
Let $L$ be an arbitrary language in $\Sigma_3$. Thus it can be written that $x \in L \Leftrightarrow \exists y^{p(|x|)} \forall z^{p(|x|)} \exists w^{p(|x|)} \langle x,y,z,w \rangle \in B$ where $p(\cdot)$ is some polynomial function and $B$ is some language in $P$. While giving a reduction from $L$ to $\Sigma_3$-SA...
Let $L$ be an arbitrary language in $\Sigma_3$. Thus it can be written that $x \in L \Leftrightarrow \exists y^{p(|x|)} \forall z^{p(|x|)} \exists w^{p(|x|)} \langle x,y,z,w \rangle \in B$ where $p(\cdot)$ is some polynomial function and $B$ is some language in $P$. While giving a reduction from $L$ to $\Sigma_3$-SA...
I understand range updates in segment trees using lazy propagation where each node is an integer. But when it comes to merge sort trees, how does one increment all elements **in all arrays** by some integer 'k' and maintain the sorted order of the root node? Will it still result in a logarithmic time complexity?
Range updates in merge sort trees
|data-structures|sorting|trees|
I understand range updates in segment trees using lazy propagation where each node is an integer. Merge Sort Tree (source GFG): https://media.geeksforgeeks.org/wp-content/uploads/20220722205737/MergeSortTutorial.png But when it comes to merge sort trees (segment tree of sorted arrays as nodes), how does one perf...
Range updates in segment trees of sorted arrays (merge sort trees)
null
null
What is the smallest NFA you can design for {a^n : n =/= 1003}
null
The program executes in its virtual address space, unaware of memory mapping. So READ 11 indeed reads from the virtual address 11. Under the hood, address 11 is mapped somewhere in RAM (after the page has been mapped to RAM), and the exact location is irrelevant. It can change during program execution. How the mappi...
Perform this test: - does $\dfrac{2n + 3n^2\log^3 n + 2}{3n^2\log^3n}$ tend to a constant ? - does $\dfrac{(2n^2 + 7n+5)(7n+1)}{n^2}$ tend to a constant ?
null
I want to study the reduction from the [Diophantine Equation Problem (Hilbert's tenth problem)][1] to the [Halting problem][2]. Can you either explain it to me or give me a credible source from which I can study it? [1]: https://en.m.wikipedia.org/wiki/Hilbert%27s_tenth_problem [2]: https://en.m.wikipedia....
Reduction from Diophantine Equation Problem to Halting Problem
|reductions|halting-problem|diophantine-equation|
null
Let $[b]$ to denote $1$ if $b$ is true, $0$ if $b$ is false. We have $$ \begin{align} & \bigwedge_{b \in B \setminus B_i} b \\ \iff & \sum_{b \in B \setminus B_i} [\neg b] = 0 \\ \iff & \sum_{b \in B} [\neg b] = \sum_{b \in B_i} [\neg b] \\ \end{align} $$ Therefore, an all-except constraint can be expressed ...
I was watching [some lectures][1] by Prof. Pfenning on Proof Theory. He gave a list for some different kinds of judgments along with their calculus and computation phenomena that they can represent or model. I am looking for a more comprehensive list. I would like to compare and know the advantages and disadvantages of...
Where can I find a list of logics with their corresponding calculus and computation phenomena?
|lambda-calculus|comparison|calculus-of-constructions|pi-calculus|
I am writing an N-body simulation in C++ that has to be able to deal with large N ($N \le 10^6$). Everything has been going well so far, but now that I have started to code in collisions between bodies (which can result in mergers - which means that one body is added to the system and two are removed) I cannot help ...
Best data structure in C++ to store bodies in an N-body simulation?
|data-structures|trees|memory-management|c++|physics|
For each $i \in \{0, \dots, 1003\}$ let $p_i = (a^i, a^{1003-i})$. We can then invoke Theorem $1$ in the paper [A lower bound technique for the size of nondeterministic finite automata][1] choosing $P = \{p_1, \dots, p_{1003}\}$ to conclude that a lower bound on the number of states of any NFA is $1004$. It is ea...
null
- First Expression: $2n + 3n^2(log n)^3 + 2$ is indeed correct. - Second Expression: $\dfrac{(2n^2 + 7n+5)(7n+1)}{7}$ is not correct. The leading expression of the second expression is $\dfrac{14}{7}$$n^3$ and not $2n^2$. It seems that you missed multiplying the two expressions by each other. Which give you the fol...
null
For each $i \in \{0, \dots, 1003\}$ let $p_i = (a^i, a^{1003-i})$. We can then invoke Theorem $1$ in \[1\] choosing $P = \{p_1, \dots, p_{1003}\}$ to conclude that a lower bound on the number of states of any NFA is $1004$. It is easy to come up with a NFA that accepts the language using $1004$ states. Each stat...
For each $i \in \{0, \dots, 1003\}$ let $p_i = (a^i, a^{1003-i})$. We can then invoke Theorem $1$ in \[1\] choosing $P = \{p_0, \dots, p_{1003}\}$ to conclude that a lower bound on the number of states of any NFA is $1004$. It is easy to come up with a NFA that accepts the language using $1004$ states. Each stat...
The definition of P is given by the union of all DTIME($n^k$) languages for $k >= 0$, where DTIME($n^k$) is the set of languages for which there exist a TM time-bounded by $T(n) = O(n^k)$. However, this is where my confusion lies - if $T(n) = O(n^k)$, then $T(n) <= c.n^k$ for $n >= N$; but does this mean the TM can run...
Is this definition of the class P correct?
|complexity-theory|turing-machines|polynomial-time|
This question can be solved in 2 different approaches. The first approach is using Dynamic Programming, and the second approach this using Greedy algorithm approach. - Greedy Approach: $Algorithm$$:$ 1. Create an empty set $A$. 2. Append all leaves $l \in T$ to $A$. 3. Remove all the leaves $l$, their pa...
In the definition of $O$, i.e. in the asymptotic sense, the behavior for $n<N$ does not matter. What counts is the behavior towards infinity. Think for a second: $n<10\implies 10000\log(n+1)>2^n$.
The question is best answered with $n=2^{2^m}$ so that $$T(2^{2^m})=2T(\sqrt{2^{2^m}})+1=2T(2^{2^{m-1}})+1.$$ This has the functional form $$S(m)=2S(m-1)+1$$ and it is no big deal to find the solution of the homogeneous recurrence $c\,2^m$ and a particular solution $-1$. Now, $$S(m)=c\,2^m-1$$ is anot...
The question is best answered with $n=2^{2^m}$ so that $$T(2^{2^m})=2T(\sqrt{2^{2^m}})+1=2T(2^{2^{m-1}})+1.$$ This has the functional form $$S(m)=2S(m-1)+1$$ and it is no big deal to find the solution of the homogeneous recurrence $c\,2^m$ and a particular solution $-1$. Now, $$S(m)=c\,2^m-1$$ is anot...
The question is best answered with $n=2^{2^m}$ so that $$T(2^{2^m})=2T(\sqrt{2^{2^m}})+1=2T(2^{2^{m-1}})+1.$$ This has the functional form $$S(m)=2S(m-1)+1$$ and it is no big deal to find the solution of the homogeneous recurrence $S_h(m)=c\,2^m$ and a particular solution $S_p(m)=-1$. Now, $$S(m)=c\,2...
The question is best answered with $n=2^{2^m}$ so that $$T(2^{2^m})=2T(\sqrt{2^{2^m}})+1=2T(2^{2^{m-1}})+1.$$ This has the functional form $$S(m)=2S(m-1)+1$$ and it is no big deal to find the solution of the homogeneous recurrence $S_h(m)=c\,2^m$ and a particular solution $S_p(m)=-1$. Now, $$S(m)=c\,2...
Presumably all the accesses to the bodies that you need to perform are sequential, so a linked list would be a good candidate. (By the way, I would not delete two bodies and insert a new one, but update one and delete the other.) Anyway, before rushing to replace the data structure, I would compare the cost of the i...
Presumably all the accesses to the bodies that you need to perform are sequential, so a linked list would be a good candidate. (By the way, I would not delete two bodies and insert a new one, but update one and delete the other.) Anyway, before rushing to replace the data structure, I would compare the cost of the i...
My idea was that it is because we can construct a TM M' that simulates a TM M that is to find a solution for a PCP instance. M' accepts if M accepts, rejects if M rejects, and doesn't halt if M does not. But I'm confused about the fact that in such a way we can also construct a TM M'' that simulates M. It rejects ...
Is the set of instances of PCP, which have a solution, semi-decidable?
|turing-machines|decision-problem|semi-decidability|
I was studying the Barrington Theorem in https://homes.cs.washington.edu/~anuprao/pubs/CSE531Sp2020/lecture2.pdf when I found a doubt regarding permutations. Particularly, with conjugations. It is said, in the 2nd page, 4th point, that two cyclic permutations $\pi$ and $\sigma$, always have a permutation $\tau$ s.t....
Doubt regarding conjugations of permutations
|permutations|group-theory|
Why choose? You can have it both ways: 1. a vector that contains all the bodies, and, 2. a map from ID to index in that vector Any simple modification of the vector (push_back, swap, pop_back) would also only require a simple modification of the map, and you can use these operations to remove an element from the...
Suppose that $T(n) \le c \cdot n^k$ for all $n \ge n_0$, where $n_0$ is a constant and $k \ge 1$. Define $c' = c+\max_{n <n_0} T(n)$ and notice that, for all $n \ge 1$, the following holds: $$ T(n) \le c \cdot n^k + \max_{n <n_0} T(n) \le \big(c + \max_{n <n_0} T(n) \big) n^k = c' \cdot n^k. $$
null
The purpose of a priority queue is to get the elements by decreasing priority when they are initially unordered. So your first hypothesis does not hold. (Of course you could enqueue in priority order, but then the queue can just be a FIFO.)
As stated, the part 2 may easily fail to be possible. Take the numbers $0.2, 0.3, 0.4$. The rounded sum is $1$, but "min(abs(float - int))" rounds all three to $0$.
I am working on a problem that asks me to write an LR(1) grammar that satisfies the following rules: Consider a robot arm that accepts two commands: "Down" puts an apple in the bag and "Up" takes an apple out of the bag. Assume the robot arm starts with an empty bag. A valid command sequence for the robot arm sho...
How to make LR(1) grammar for sequence that cannot have more "Up" than "Down" for any given prefix?
|context-free|compilers|parsers|lr-k|
Given a group of cities and a starting city, we have to find a path that covers all the cities. The path doesn't need to end at the starting city. Is this a TSP problem? What is the solution for it? This is not a homework problem or an interview question. I asked ChatGPT to find the shortest paths covering 5 random...
Is this a Traveling salesman problem? If so, how to solve it?
|minimum-spanning-tree|traveling-salesman|
Suppose that $T(n) \le c \cdot n^k$ for all $n \ge n_0$, where $n_0$ is a constant and $k \ge 0$. Define $c' = c+\max_{n <n_0} T(n)$ and notice that, for all $n \ge 1$, the following holds: $$ T(n) \le c \cdot n^k + \max_{n <n_0} T(n) \le \big(c + \max_{n <n_0} T(n) \big) n^k = c' \cdot n^k. $$
I am working on a problem that asks me to write an LR(1) grammar that satisfies the following rules: Consider a robot arm that accepts two commands: "down" puts an apple in the bag and "up" takes an apple out of the bag. Assume the robot arm starts with an empty bag. A valid command sequence for the robot arm sho...
Dijkstra's algorithm might solve some cases where there are negative edges in the graph. However, it doesn't solve for every graph that has a negative edge. For instance, if you have a negative cycle, Dijkstra won't work. For graphs with negative weighted edges, you should use Bellman-Ford's algorithm. If you wan...
I am working on a problem that asks me to write an LR(1) grammar that satisfies the following rules: Consider a robot arm that accepts two commands: "down" puts an apple in the bag and "up" takes an apple out of the bag. Assume the robot arm starts with an empty bag. A valid command sequence for the robot arm sho...
This is a basic question on linked lists. You have to understand that for these types of problems, there are 2 different solutions. The iterative approach, or the recursive approach. Here, the iterative approach is easier. - Iterative Approach: 1. Define a new variable, $Sum = 0$. 2. Iterate through ...
I'm studying for the Algorithms and Computability course. I have encountered a problem that I cannot solve and cannot find any materials to help me solve it. It's the following PCP problem: We have two sets: A = (b, a, ca, bac) B = (ca, ab, a, c). The task is to find a solution to the given PCP problem o...
Proving that there is no solution to the PCP problem using induction
|automata|undecidability|induction|
I am working on a problem that asks me to write an LR(1) grammar that satisfies the following rules: Consider a robot arm that accepts two commands: $\triangledown$ puts an apple in the bag and "up" takes an apple out of the bag. Assume the robot arm starts with an empty bag. A valid command sequence for the robo...
I am working on a problem that asks me to write an LR(1) grammar that satisfies the following rules: Consider a robot arm that accepts two commands: $\triangledown$ puts an apple in the bag and "up" takes an apple out of the bag. Assume the robot arm starts with an empty bag. A valid command sequence for the robo...
I am working on a problem that asks me to write an LR(1) grammar that satisfies the following rules: Consider a robot arm that accepts two commands: $\triangledown$ puts an apple in the bag and $\triangle$ takes an apple out of the bag. Assume the robot arm starts with an empty bag. A valid command sequence for t...
I am working on a problem that asks me to write an LR(1) grammar that satisfies the following rules: Consider a robot arm that accepts two commands: $\triangledown$ puts an apple in the bag and $\triangle$ takes an apple out of the bag. Assume the robot arm starts with an empty bag. A valid command sequence for t...
null
An earlier exercise in the same textbook asks you (in effect) to create a grammar for the balanced parenthesis language (disguised as a question about elevator motions) and then prove that your grammar is LL(1). The answer to that exercise is an important prerequisite for this one, so if you haven't done it yet, go bac...
There are no control dependencies in the code fragment. The non-transitive true (read-after-write) dependencies are: * $i_2\ \delta^f\ i_3$ via register $t_4$ * $i_3\ \delta^f\ i_4$ via register $t_0$ * $i_6\ \delta^f\ i_7$ via register $t_1$ There are also output (write-after-write) dependencies: * $i_1\ \d...
An earlier exercise in the same textbook asks you (in effect) to create a grammar for the balanced parenthesis language (disguised as a question about elevator motions) and then prove that your grammar is LL(1). The answer to that exercise is an important prerequisite for this one, so if you haven't done it yet, go bac...
An earlier exercise in the same textbook asks you (in effect) to create a grammar for the balanced parenthesis language (disguised as a question about elevator motions) and then prove that your grammar is LL(1). The answer to that exercise is an important prerequisite for this one, so if you haven't done it yet, go bac...
An earlier exercise in the same textbook asks you (in effect) to create a grammar for the balanced parenthesis language (disguised as a question about elevator motions) and then prove that your grammar is LL(1). The answer to that exercise is an important prerequisite for this one, so if you haven't done it yet, go bac...
An earlier exercise in the same textbook asks you (in effect) to create a grammar for the balanced parenthesis language (disguised as a question about elevator motions) and then prove that your grammar is LL(1). The answer to that exercise is an important prerequisite for this one, so if you haven't done it yet, go bac...
null
Given a number n, the task is to find the XOR from 1 to n. Why does the following algorithm work? 1. Find the remainder of n by moduling it with 4. 2. If rem = 0, then XOR will be same as n. 3. If rem = 1, then XOR will be 1. 4. If rem = 2, then XOR will be n+1. 5. If rem = 3 ,then XOR will be 0.
Calculating XOR from 1 to n: Why does this method work?
|bit-manipulation|xor|
Here are two different ways to see this, first a more "direct reasoning" way and second by induction. Let $\oplus$ denote the XOR operation. ### Direct reasoning: If $x$ is an even number, then what is $x \oplus (x + 1)$? Notice that because $x$ is even (ends in a $0$), $x + 1$ only modifies the last bit, so that...