instruction
stringlengths
0
29.8k
⌀
I want to know how hardwares write a byte in memory?\ If there is difference between writing process in RAM and ROM I would like to know as well. Specially I want to know: 1. Is hardware writes values bit by bit? (I mean like writing first bit then go to next) 2. Is there a header that move around and change ...
How hardware write a byte in memory?
|memory-management|memory-hardware|memory-access|
null
|computer-architecture|memory-management|memory-hardware|memory-access|
null
null
null
null
I have different time intervals (contains partial or full overlaps). I provided the sample input and output so that it would be easy to understand. Sample Input: `[1-5, 2-3, 3-5, 3-5, 3-6]` Sample Output: `[(1-2):1, (2-3):2, (3-5):4, (5-6):1]` The above output informs that, for the interval (1-2), there is o...
Best data structures to store overlapping intervals?
|algorithms|data-structures|trees|
You can compute the desired output in time $O(n \log n)$, where $n$ is the number of intervals, without any advanced data structure. For the sake of simplicity suppose that there are no intervals of length $0$ and that the set of all endpoints of the intervals is $\{1,2,\dots,k\}$. Clearly $k \le 2n$. This can be gu...
null
You can compute the desired output in time $O(n \log n)$, where $n$ is the number of intervals, without any advanced data structure. For the sake of simplicity suppose that there are no intervals of length $0$ and that the set of all endpoints of the intervals is $\{1,2,\dots,k\}$ with $k=O(n)$. This can be guarante...
null
null
null
null
null
You can't get a relative error on a zero quantity. Only absolute error. Full stop.
null
Lets say the alphabet is **Σ=∅**,what are the possible languages of this alphabet? According to my definitions: - I know that an alphabet is a finite set of symbols **Σ** - I know words is a set of all finite symbols consisting of letters from the alphabet (**Σ***) and an empty string part of all words **ε ∈ Σ**...
Suppose we have an empty alphabet Σ=∅, what are the possible languages of this alphabet?
|automata|sets|
|formal-languages|automata|sets|
Actually your list of properties already solves the problem. As $\varepsilon$ is an element of $\Sigma^*$ and we cannot have any longer word due to the lack of symbols, we have $\varnothing^*=\{\varepsilon\}$. A language is a subset of $\varnothing^*$, and as $\varnothing^*$ has only one element, there are two possi...
null
I have different time intervals (contains partial or full overlaps). I provided the sample input and output so that it would be easy to understand. Sample Input: `[1-5, 2-3, 3-5, 3-5, 3-6]` Sample Output: `[(1-2):1, (2-3):2, (3-5):4, (5-6):1]` The above output informs that, for the interval (1-2), there is o...
Although both direct and random access terms can be used interchangeably, based on the definitions mentioned it might give rise to slightly different meanings. This could be one of the possible interpretations of the definitions. **Direct Access** > individual blocks or records have a unique address based on phys...
Could we say that Dynamic programming is nothing but recursion + Memoization? Although the formal definition of dynamic programming is that the problem should have an optimal substructure property, which in a way is nothing else but recursion.
Defining dynamic programming
|dynamic-programming|recursion|memoization|
In the Introduction to Algorithms Book By Thomas H. Cormen, Third Edition, they give an approximation algorithm for the Vertex Cover Problem with 2-approximation ratio: [![enter image description here][1]][1] [1]: https://i.stack.imgur.com/S4ER8.jpg Where ***G*** is undirected graph. The complexity of thi...
Why the APPROX-VERTEX-COVER algorithm is O(V+E)?
|algorithms|graphs|time-complexity|
null
You can use a boolean array of length $|V|$ to check whether a vertex $u$ has already been seen or not. Assuming $V = \{0, 1, …, n-1\}$, the algorithm could be re-written as: ``` Input: graph G as an adjacency lists array Initialize C as an empty set for u = 0 to n - 1 do for v in G[u] do if neith...
You can use a boolean array of length $|V|$ to check whether a vertex $u$ has already been seen or not. Assuming $V = \{0, 1, …, n-1\}$, the algorithm could be re-written as: ``` Input: graph G as an adjacency lists array Initialize C as an empty set for each edge e = {u, v} in E do if neither u nor v is m...
I have different time intervals (contains partial or full overlaps). I provided the sample input and output so that it would be easy to understand. Sample Input-1: `[1-5, 2-3, 3-5, 3-5, 3-6]` Sample Output-1: `[(1-2):1, (2-3):2, (3-5):4, (5-6):1]` The above output informs that, for the interval (1-2), there ...
null
{"OriginalQuestionIds":[47216],"Voters":[{"Id":755,"DisplayName":"D.W."}]}
### Question Let $L$ be a regular language. Let's say we sort $L$ by length and then lexicographically; then let $L_p \subset L$ be every $p$th word in $L$ according to this sort. Is $L_p$ regular as well? ### Example For example, let's use $L = a^*b^* = \{\epsilon, a, b, aa, ab, bb, aaa, aab, abb, ...\}$. The...
Is every $p$th word in a regular language regular?
|regular-languages|
null
[![enter image description here][1]][1] [1]: https://i.stack.imgur.com/ATgOh.png The right answer is Theta(n log logn). But, can someone explain why it is the case? I know intuitively that it is because k is k^2 each time, so it couldn't be (logn) for the second loop. However, what is the actual mathematica...
What is the time complexity of the following program
|algorithms|algorithm-analysis|
Hint: If $n=2^{16}$, how many times does the inner loop iterate? Try to work out the exact answer -- I'm sure you can figure it out. What about if $n=2^{32}$? $n=2^{64}$?
The answer is yes: Theorem 4 in "Numeration systems on a regular language" (Leconte and Rigo) shows that any arithmetic progression in a regular language is regular.
I think the only thing missing in your analysis is the cost of adding the two vertices to the set $C$,which at the very least be $O(1)$ per vertex, if $C$ is implemented as a simple list. With that you will get the $O(V+E) $ bound.
null
null
Suppose I have the mesh of an geometrical object (Interval in 1d, Region in 2d, Volume in 3d). How can I find out whether a point lies on its boundary or not? I am looking for algorithms with explanations. Any resource would **also** be appreciated.
Finding whether a point lies on the boundary of an geometrical object or not?
|computational-geometry|image-processing|python|c++|polygons|
null
Let $L_1$ be a context-free language and $L_2$ be a regular language. Then $L_1 \cap L_2$ is context-free. Part of a proof given in the book "Formal languages and automata": Let $M_{1}=\left(Q, \Sigma, \Gamma, \delta_{1}, q_{0}, z, F_{1}\right)$ be an npda that accepts $L_1$, $M_{2}=\left(P, \Sigma, \delta_{2}, p_{...
Given two binary matrices of the same size with the same element counts, how can we find a map mapping ones to ones such that the sum of differences of distances of all pairs of neighbors is minimised, where the distance of each cell is the number of steps it needs to walk horizontally, vertically or diagonally to reac...
Finding a map between two matrices that minimises distance differences of neighbors
|algorithms|matrices|
*Let L be a regular language. Then there exists a regular expression r such that L = L(r).* **Proof for NFAs with only 2 states (can be generalized!), partly seen during a lecture and completed by me:** Let $M=\left(Q, \sigma, \delta, q_0, F\right)$ be an nfa that accepts $L$ The nfa $M$ has only two states $q...
proof that there exists a regular expression r for every NFA with only 2 states
|formal-languages|regular-languages|automata|regular-expressions|
Starting with a digit k, 10-k steps lead to 10. 9 further steps change the 1 to 10 and 10 steps change the 0 to 10. So on average 9.5 steps double the number of digits. 95 steps more than multiply the number of digits by 1000, 95k steps multiply the number of digits by 1000^k. So the number of digits grows exponentiall...
i want to show that for all $CFL$ and not $REG$ languages $L \subseteq \{0,1\}^*$, exists $L_1,L_2\subseteq\{0,1\}^*$ with $L_1$ is $REG$ and $L_1 \subseteq L_2 $ and $L \subseteq L_2 $ with $L \neq L_2$ I struggle at showing it for all $L$. What I did so far is some kind of a little sketch. Let $L_1 = L(01...
Show for every $CFL$ $L$ that's not $REG$ exists $L_1,L_2$ with $L_1$ is $REG$ and $L_1 \subseteq L_2$ and $L_2$ is not $REG$ and $L \subseteq L_2$
|formal-languages|regular-languages|context-free|closure-properties|
i want to show that for all $CFL$ and not $REG$ languages $L \subseteq \{0,1\}^*$, exists $L_1,L_2\subseteq\{0,1\}^*$ with $L_1$ is $REG$ and $L_1 \subseteq L_2 $ and $L \subseteq L_2 $ with $L \neq L_2$ I struggle at showing it for all $L$. What I did so far is some kind of a little sketch. Let $L_1 = L(01...
Your approach is not going to work. If $L=\{00\}$ (say) then you will not have $L \subseteq L_2$. Hint for a better approach: Could $L$ be $\{0,1\}^*$? Why or why not?
I know that to illustrate speed-up advantage of Grover's algorithm we can apply "square root": if the brute force search takes 100 hours, Grover's quantum search algorithm should take about 10 hours. What would be similar numbers for Shor's algorithm for, say, 10-digit numbers?
Quantum algorithms speedup illustration
|quantum-computing|
i want to show that for all $CFL$ and not $REG$ languages $L \subseteq \{0,1\}^*$, exists $L_1,L_2\subseteq\{0,1\}^*$ with: - $L_1$ is $REG$ - $L_2$ is $CFL$ and not $REG$ - $L_1 \subseteq L_2 $ - $L \subseteq L_2 $ and $L \neq L_2$ I struggle at showing it for all $L$. What I did so far is some kind ...
i want to show that for all $CFL$ and not $REG$ languages $L \subseteq \{0,1\}^*$ exists $L_1,L_2\subseteq\{0,1\}^*$ with: - $L_1$ is $REG$ - $L_2$ is $CFL$ and not $REG$ - $L_1 \subseteq L_2 $ - $L \subseteq L_2 $ and $L \neq L_2$ I struggle at showing it for all $L$. What I did so far is some ki...
Since $L$ is not regular it is different than $\Sigma^*$. What would happen if you choose a word $u\notin L$ and consider $L\cup \{u\}$?
Given two binary matrices of the same size with the same element counts, how can we find a map mapping ones to ones such that the sum of differences of distances of all pairs of neighbors is minimised, where the distance of each cell is the number of steps it needs to walk horizontally, vertically or diagonally to reac...
Given two binary matrices of the same size with the same element counts, how can we find a map mapping ones to ones such that the sum of differences of distances of all pairs of neighbors is minimised, where the distance of each cell is the number of steps it needs to walk horizontally, vertically or diagonally to reac...
The depth is the order of constraints (requirements in the order of execution before a bug is found) that a scheduler has to follow to find a bug. The issue that you are trying to solve here is a lost update that happens when you modify the X in both threads. Let suppose the following sequence. Thread 1 executes from...
Each time a thread read the shared variable, increments the local variable, and writes back. Note that writing can occur by a thread only after the reading operation. So in the case of 2 threads, x can be incremented only once before writing back by a thread.
I'm a SW engineer. I'm just curious why computers become slow over time. "Slow" here I mean from a usual user PoV: - It takes more time to launch an application. - Application UI takes longer to respond user interactions. Sometimes even freeze and unresponsive. - Playing video files on local HDD becomes noncontin...
I expect that solving the problem exactly is likely to be NP-hard. However, here is an approach that I expect will probably be good enough for practical purposes. It uses a subroutine to solve the following problem: given an integer range $[\ell,u]$, find a mapping $\psi$ such that $\ell \le \text{dist}(p,\psi(p)) ...
null
null
I expect that solving the problem exactly might be NP-hard. However, here is an approach that I expect will probably be good enough for practical purposes. It uses a subroutine to solve the following problem: given an integer range $[\ell,u]$, find a mapping $\psi$ such that $\ell \le \text{dist}(p,\psi(p)) \le u$ ...
I'm a SW engineer. I'm just curious why computers become slow over time. "Slow" here I mean from a usual user PoV: - It takes more time to launch an application. - Application UI takes longer to respond user interactions. Sometimes even freeze and unresponsive. - Playing video files on local HDD becomes noncontin...
After $m$ operations, a single digit becomes a string of about $2^{\log_{10}\frac m{10}}$ digits, as the number of digits doubles about every ten operations. So just writing the result takes time $\Omega(n\,m^{0.301\cdots})$ and $O(n+m)$ is not possible. A possible method is to precompute the expansions of the ten d...
The number of iterations of the inner loop can be found by solving the recurrence $$k_{i+1}=k_i^2,\\k_0=2.$$ Taking the $\lg$, we have $$\lg k_{i+1}=\lg k_i^2=2\lg k_k,\\\lg k_0=1,$$ which can be readily solved as a geometric progression. Alternatively, taking the $\lg\lg$, the recurrence becomes $$\lg\...
The number of iterations of the inner loop can be found by solving the recurrence $$k_{i+1}=k_i^2,\\k_0=2.$$ Taking the $\lg$, we have $$\lg k_{i+1}=\lg k_i^2=2\lg k_i,\\\lg k_0=1,$$ which can be readily solved as a geometric progression ($\lg k_i=2^i$). Alternatively, taking the $\lg\lg$, the recurrence b...
null
Given a real matrix $M \in \mathbb{R}^{n \times m}$ and a vector $v \in \mathbb{R}^{n}$ I would like to find an element $x \in \mathbb{R}^m$ such that $v - Mx$ has maximum number of zeros. If the matrix $M$ has rank $n$ then it is easy to find some $x$ where $xM = v$. But in the case where $m<n$ the best I can think...
Element in linear subspace with maximum number of zeros
|algorithms|optimization|linear-algebra|
null
Issue: I am having a hard time figuring out how to use the worst case for Rolling Hash, especially if the occurrences are only "a and b" for the string. Not only that but it is a bit of a hassle to figure out the process if the pattern that we tried to find from the given string will only contain one character occurren...
How to use a worst case scenario in Rolling Hash: Rabin Karp Algorithm when the given string only contains the occurrences of "a and b?"
|algorithms|complexity-theory|hash|rolling-hash|
null
Asymptotic complexity evaluations are not appropriate to decide which implementation is the fastest, and the best you can do is to rely on empirical evaluation. This said, there will be no absolute answer because the running time of an algorithm is not a deterministic function of the problem size. On the opposite, i...