instruction
stringlengths
0
29.8k
⌀
The best known lower bounds for *explicit* functions are $\Omega(n)$. The only superpolynomial lower bounds are in restricted models of circuits, such as monotone circuits and bounded-depth circuits. NP-hard problems are expected to have exponential circuit complexity $2^{n^{\Omega(1)}}$; this is a non-uniform versi...
To create a CFG you begin with an Abstract Syntax Tree (AST). So I assume you have an AST available. The first step is to collect the nodes in the tree into basic blocks. This step is optional but reduces the number of nodes in the CFG which improves performance. So if you have the source code: if a: ...
null
I know that for $n \times n$ matrix, it takes $O(n^2)$ time complexity to compute the largest eigenpair of the matrix using Power method or etc. I'm interested to further extend the case so that now we're interested in finding $d$ largest eigenpairs, but for a "symmetric" matrix. What is the time complexity of this alg...
Complexity of finding $d$ largest eigenvectors of a symmetric matrix
|algorithms|time-complexity|matrices|linear-algebra|
Im trying to gain a better understanding of Big O and this is something that im unsure about. Say we have an array containing N elements that is inputted by the user, from my understanding iterating over each element from this array gives O(n) as we are looping over the array N times. Now we do the samething, we ite...
Time complexity when taking certain elements and iterating over them?
|big-o-notation|
null
null
The power method takes $O(n^2)$ time *per step*. It is an iterative algorithm, and convergence is geometric. The absolute speed of convergence depends on the ratio between the two largest eigenvalues. The usual generalisation of the power method to the top $d$ eigenpairs is the [Lancosz algorithm][1], if the matrix ...
In doing running-time analysis, we often assume the worst-case. That is, what scenario will lead to the maximum possible running-time. As for your question about the second array, you can assume that in the worst-case, everything from the first array was transferred to the second array. That is, in the worst-case the s...
I'm trying to gain a better understanding of Big O. Here is something that I'm unsure about. Say we have an array containing N elements that is inputted by the user. From my understanding iterating over each element from this array gives O(n) as we are looping over the array N times. Now we do the same thing, we ...
null
We know that $L = \{xy | x, y \in (a + b)^*, |x| = |y|, x ≠ y\}$ is context free. But my question is how we check in $PDA$, $x ≠ y?$ For example $x=0^n1^n$ and $y=1^{2n}.$ We can easily draw $PDA$ by checking one $0$ against three $1s$ but how can we check $x ≠ y?$
How could we check $x ≠ y$ in $PDA$ for $L = \{xy | x, y \in (a + b)^*, |x| = |y|, x ≠ y\}$
|context-free|pushdown-automata|
We know that $L = \{xy | x, y \in (a + b)^*, |x| = |y|, x ≠ y\}$ is context free. But my question is how we check $x ≠ y$ in $PDA?$ For example $x=0^n1^n$ and $y=1^{2n}.$ We can easily draw $PDA$ by checking one $0$ against three $1s$ but how can we check $x ≠ y?$
null
If two strings $w_1, w_2$ of the same length are different from each other, then you can find a specific position where they differ: $$w_1 = \underbrace{\square\ldots \square}_{k\text{ symbols }}\;x\;\underbrace{\square\ldots\ldots \square}_{\ell\text{ symbols }}$$ $$w_2 = \underbrace{\square\ldots \square}_{k\...
null
In shannon capacity, it uses log operation. > bandwidth * log<sub>2</sub>(1 + SNR) Why they use log operation instead of just using SNR?
why use log operation in shannon capacity?
|computer-networks|
null
We know that $L = \{ xy | x, y \in (a + b)^*, |x| = |y|, x≠y\}$ is context free. But my question is how we check $x ≠ y$ in $PDA?$ For example $x=0^n1^n$ and $y=1^{2n}.$ We can easily draw $PDA$ by checking one $0$ against three $1s$ but how can we check $x ≠ y?$
null
Assume a **bloom filter** that is composed of $H = \{H_1, ..., H_k\}$ hash functions, and uniformly maps elements from an input set $X$ to an array $A$ of size $n$. Let $X_1, X_2$ (not same) be two input sets of size $m$. After applying the same bloom filter to both input sets, we receive the arrays $A_1$ and $A_2$ (bo...
I have to find equivalence classes for different languages based on Myhill-Nerode. I'm struggling a little bit finding these equivalence classes; for example, the language $L=b^∗a^n|n≡0mod5$ with alphabet {a,b}. My first solution would be: $[ϵ][b^∗][b^∗a][b^∗aa][b^∗aaa][b^∗aaaa]$ Would these be the correct classe...
Myhill Nerode equivalence classes
|automata|
null
I have to find equivalence classes for different languages based on Myhill-Nerode. I'm struggling a little bit finding these equivalence classes; for example, the language $L=\{b^*a^n\mid n≡0\pmod5\}$ with alphabet $\{a,b\}$. My first solution would be: $[ϵ],[b^∗],[b^∗a],[b^∗aa],[b^∗aaa],[b^∗aaaa]$. Would these b...
In order to check that these are the correct classes, you need to check three things: 1. Any two words in the same class are equivalent. 1. Any two words in different classes are inequivalent. 1. Every word belongs to one of the classes. Good luck!
I have to find equivalence classes for different languages based on Myhill-Nerode. I'm struggling a little bit finding these equivalence classes; for example, the language $L=\{b^*a^n\mid n≡0\pmod5\}$ with alphabet $\{a,b\}$. My first solution would be: $[\epsilon],[b^∗],[b^∗a],[b^∗aa],[b^∗aaa],[b^∗aaaa]$. Would ...
Myhill–Nerode equivalence classes for the language $b^ia^{5j}$
|formal-languages|automata|
Tp is same as Tt for pure aloha Tfr is also same as Tt
I just had an exam. There is the same question, we being ask to find all vertex that not part of cycle. The function is like this (In C) void HasCycle(int hasCycle[], int size, Graph g); In my function, I use 1. An array to track **visit status**(Using hasCycle provided). Then I will run DFS on the v...
I am a student want to study randomized algorithm. Someone recommend [cs271][1] to me, but it's restricted now. Can someone recomend a good resource to study randomized, thank you a lot. [1]: https://people.eecs.berkeley.edu/~sinclair/cs271/s20.html
Is there any open resource to study randomized algotithm?
|algorithms|randomized-algorithms|
null
Apologies in advanced if this is solved problem, I could not find a solution, but might just be me not knowing what to search for. Assume we have an alphabet `Σ={a,b,c,d}` which describes a language `L`. We save `n` many unique words of `L` in a set `S`. (e.g. `S={a, c, abc, cd, db}`). What would be the most eff...
I can recommend you the book from Michael Mitzenmacher and Eli Upfal called "Probability and Computing". I bought a hard copy of it recently and I absolutely don't regret it. It's very detailed and goes through many different probabilistic tools along with important chapters from randomised algorithms. It is compleme...
Can we determine in polynomial time if the language accepted by an NFA is finite? The case of DFA is simple, but converting the NFA to DFA is exponential... Also, I ran into this post: https://cs.stackexchange.com/questions/117241/determine-if-an-nfa-accepts-infinite-language-in-polynomial-time But there is no so...
Determining if NFA accepts an infinite language in polynomial time
|finite-automata|polynomial-time|
I need a layout algorithm and use it in the GUI, but I can't use existing GUI toolkits at the moment, so I would like to find a layout algorithm. I only need to do a single row layout, and here is the description of the algorithm. ### Input Data First, there are three sequences. $$\begin{split} A &= x_1,x_2,...
A Single Row GUI Layout Algorithm
|algorithms|graphics|user-interface|
The problem of determining whether an NFA accepts an infinite language is the same as determining whether there is a cycle that contains at least one accepting state in the NFA viewed as a directed multi-graph. The one or more transitions from one state to another state can be replaced by one simple edge. In this w...
Since $\epsilon$-transitions can be removed in polynomial time, let us assume for simplicity that the NFA does not contain any $\epsilon$-transitions (though the argument can be modified to accommodate them). Suppose that the NFA contains $n$ states, and denote by $L$ the language it accepts. If $L$ is infinite then...
The problem of determining whether an NFA accepts an infinite language is the same as determining whether there is a cycle that contains at least one reachable accepting state in the NFA viewed as a directed multi-graph. The one or more transitions from one state to another state can be replaced by one simple edge....
We know that $L = \{ xy | x, y \in (0 + 1)^*, |x| = |y|, x≠y\}$ is context free. But my question is how we check $x ≠ y$ in $PDA?$ For example $x=0^n1^n$ and $y=1^{2n}.$ We can easily draw $PDA$ by checking one $0$ against three $1s$ but how can we check $x ≠ y?$
How could we check $x ≠ y$ in $PDA$ for $L = \{xy | x, y \in (0 + 1)^*, |x| = |y|, x ≠ y\}$
What is the most efficient data structure for a dynamic set of words over a finite alphabet $\Sigma$ which supports the following operations? - Add a word. - Remove a word. - Determine a shortest word which is not in the set. Does it help if all words have the same length? **A real world example:** I was thi...
Shortest word not in dynamic set
|data-structures|
To prove the claim $$ P(Mr = 0 ) \leq \frac{1}{2} $$ it is enough to prove it for any row vector $m = (M_{i,1},...,M_{i,n})$ that has at least one non-zero coefficient. Thus, we continue by induction on $n$. > $n= 1 $ base case The base case is trivial since $$ P(mr=0) = P(r=0) = \frac{1}{2} $$ in ...
Suppose I have a variant of the knapsack problem: $$\max_{x} \sum_{i=1}^n v_ix_i$$ $$(\sum_{i=1}^n w_ix_i - W)^2 \leq k$$ for $v_i, w_i \in \mathbb{R}$, $x_i \in \{0,1\}$ and $k \in \mathbb{R}, k > 0$. Is it known if the decision problem $\sum_{i=1}^n v_ix_i > V$ for some $V$ is NP-Complete?
Knapsack with quadratic constraint
|np-complete|np-hard|decision-problem|knapsack-problems|
The problem is clearly in $\mathsf{NP}$. You can see that it is $\mathsf{NP}$-hard by a reduction from subset sum: given a set $X = \{ x_1, \dots, x_m \}$ of positive integers and another integer $T>0$, is there a subset $S$ of $X$ such that $\sum_{x \in S} x = T$? To reduce to your version of subset sum, create $n=...
|formal-grammars|
I've been going through some questions on old homework and faced a question that confused me somehow. ***Question:*** Given a language $$L=\{\langle M\rangle\ |\ M\ is\ a\ turing\ machine.\ M\ goes\ through\ some\ configuration\ (q,s,i)\ infinite\ times\ on\ input\ \epsilon\}$$ determine weither it's decideable, if ...
Is $L=\{\langle M\rangle\ |\ M\ is\ a\ turing\ machine.\ M\ goes\ through\ some\ configuration\ (q,s,i)\ infinite\ times\}$ acceptable or decidable?
|formal-languages|turing-machines|proof-assistants|
Consider a deterministic finite automaton $M(k) = (Q, Σ, \delta, 0, F)$, with $k ≥ 2$ and $Q = \{0,1,...,k-1\}$ $Σ = \{0,1\}$ $\delta(q,a) = (q+a) \space mod \space k$ $F = \{0\}$ If $L$ is the language recognised by $M(k)$, describe a deterministic finite automaton that recognises the concatenation L ⋅...
Finding a DFA for concatanation
|finite-automata|
I came across the below question where the solution to the "Set Cover Problem" is discussed when the subsets are of size EXACTLY 2. https://cs.stackexchange.com/questions/77575/set-cover-problem-with-sets-of-size-2 The solution described involves constructing an Edge Cover for a slightly different graph (Create a g...
Set Cover Problem where size of the subsets is ATMOST 2
|algorithms|np-complete|np|matching|set-cover|
An NFA (with $\epsilon$-moves or not) can be viewed naturally as a directed multi-graph. <!-- a natural forgetful functor --> We will use "state" and "node" interchangeably. Whether an NFA accepts an infinite language is the same as whether there is a path from the initial state to an accepting state that contains a...
null
Can we determine in polynomial time if the language accepted by an NFA is infinite? The case of DFA is simple, but converting an NFA to a DFA may take exponential time. Also, I ran into this post, https://cs.stackexchange.com/questions/117241/determine-if-an-nfa-accepts-infinite-language-in-polynomial-time. But...
Determining if an NFA accepts an infinite language in polynomial time
|regular-languages|finite-automata|polynomial-time|infinity|
If two strings $w_1, w_2$ of the same length are different from each other, then you can find a specific position where they differ: $$w_1 = \underbrace{\square\ldots \square}_{k\text{ symbols }}\;x\;\underbrace{\square\ldots\ldots \square}_{\ell\text{ symbols }}$$ $$w_2 = \underbrace{\square\ldots \square}_{k\...
|context-free|formal-grammars|decidability|
Looks like a trick question. $L^7 = L$, so you already have a DFA for it. The words in $L$ are those where the symbol $1$ occurs a multiple of $k$ times. If you concatenate seven of them, the total number of $1$ symbols is still a multiple of $k$. So $L^7 \subseteq L$. On the other hand, $\epsilon \in L$, so you hav...
I'm having a problem with an exercise, I'm supposed to calculate the *exact* worst case runtime and the worst case runtime in *Big O Notation* for a given algorithm. This is what I'm struggling to understand, I think I know how to recognize what's the runtime using the big O Notation as it's only a nested loop bu...
Difference between an exact and Big O Notation for worst case runtime
|algorithms|runtime-analysis|big-o-notation|
Since the start state of your DFA is also the final state, it accepts the empty string. Then, it would be the case that $L = L^i$, for $i \ge 1$ (in your case $i=7$). Say you have a DFA $M_i$ for $L^i$. We prove that $w$ is accepted by $M_i$ if and only if $w$ is accepted by $M$. * **If $w$ is accepted by $M_i...
null
Is Set Cover with subsets of size ≤2 NP-complete?
It would be the case that $L = L^i$, for $i \ge 1$ (in your case $i=7$). Say you have a DFA $M_i$ for $L^i$. We prove that $w$ is accepted by $M_i$ if and only if $w$ is accepted by $M$. * **If $w$ is accepted by $M_i$ then $w$ is accepted by $M$.** Observe that once a string is accepted by $M$, $M$ must be at...
|computability|context-free|pushdown-automata|
How do we check $x ≠ y$ in $PDA$ for $L = \{xy | x, y \in (0 + 1)^*, |x| = |y|, x ≠ y\}?$
From my understanding, a CPU register is a temporary storage or working location built into the CPU itself. The CPU includes some functional units such as the ALU (which is part of the chip, as far as I know). In a 64 bit architecture, we have 16 general purpose registers, that seem to be often used in ASM programs ...
Are all CPU computations done using registers?
|computer-architecture|cpu|memory-hardware|memory-access|assembly|
Is Set Cover problem with subsets of size ≤2 solvable in polynomial time?
I came across the below question where the polynomial time solution to the "Set Cover Problem" is discussed when the subsets are of size EXACTLY 2. https://cs.stackexchange.com/questions/77575/set-cover-problem-with-sets-of-size-2 The solution described involves constructing an Edge Cover for a slightly different g...
The problem is clearly in $\mathsf{NP}$. You can see that it is $\mathsf{NP}$-hard by a reduction from subset sum: given a set $X = \{ x_1, \dots, x_m \}$ of positive integers and another integer $T>0$, is there a subset $S$ of $X$ such that $\sum_{x \in S} x = T$? To reduce to your version of subset sum, create $n=...
null
**Background** In the classic formulation of the knapsack problem with both weight and volume constraints, we are given a collection of $n$ items where item $i$ has weight $w_i\in\mathbb{N}$, volume $u_i\in \mathbb{N}$, and value $v_i\in\mathbb{N}$. We aim to fill a bag with weight capacity $W$ and volume capacity $...