instruction
stringlengths
0
29.8k
⌀
No, these 3 conditions are not sufficient. For example, $n=4$, $A=[6,5,2,1]$, $B=[1,3,4,6]$, $k=7$. - The sum of all elements in $A$ and $B$ is $14+14=28=4\cdot7$. - The sum of the max in $A$ and the min in $B$ is $7$. - The sum of the min in $A$ and the max in $B$ is $7$. However, $A[2]+B[2]=2+4=6<7$.
null
Let's say there was a CPU with an input bus of 4 bits and the 4 bits are the opcode then the next 4 bits are the operand. It would just be an 8-bit instruction split in two. Is this possible and how would it be done with logic gates?
Can a CPU instruction be split into 2 inputs?
|data-structures|cpu|database-theory|instruction-set|
The runtime of a recursive function can be expressed as a recurrence relation in terms of the sizes of its input parameters. Your recurrence begins with $idx=0$ and has a base case (stopping condition) of when $idx=k$. The quantity $k-idx$ starts high and the recursion stops when $k-idx$ reaches $0$. So let $T(n)$ r...
Consider first the language Σ<sup>*<sup>∖ which is regular since L is regular and regular languages are closed under complementation Then consider the language Σ⁺ which is regular since we can find a regular expression for it i.e. if Σ = {0,1} then E = (0 + 1)⁺ denotes the language Σ⁺ and so by Kleene's Theorem, Σ⁺ ...
The runtime of a recursive function can be expressed as a recurrence relation in terms of the sizes of its input parameters. Your recurrence begins with $idx=0$ and has a base case (stopping condition) of when $idx=k$. The quantity $k-idx$ starts high and the recursion stops when $k-idx$ reaches $0$. So let $T(n)$ r...
I am learning how to remove epsilon productions and the result I am getting seems to vary from other results I find. Beginning productions: $$S \rightarrow bSb|Ba$$ $$B \rightarrow BdSc|S|\epsilon$$ The answer I came up with is: > S -> bSb|Ba|a B -> BdSc|dSc|S However, I am also seeing these two dif...
Removing epsilon productions from a CFG. Which is correct?
|automata|
The runtime of a recursive function can be expressed as a recurrence relation in terms of the sizes of its input parameters. Your recurrence begins with $idx=0$ and has a base case (stopping condition) of when $idx=k$. The quantity $k-idx$ starts high and the recursion stops when $k-idx$ reaches $0$. So let $T(n)$ r...
null
No. Let $L'=\emptyset$ and $n>1$. Then $L \circ L' = \emptyset$, so its minimal automaton has no states at level $n$.
Given an array $A[]$ for each $j>i$ increment all $A[i]$ by $1$ if $A[i]>=A[j]$ for example lets start with: $7, 5, 2, 1, 8$ $-> 8, 5, 2, 1, 8 (A[1] >= A[2])$ $-> 9, 6, 2, 1, 8 (A[1], A[2] >= A[3])$ $-> 10, 7, 3, 1, 8 (A[1], A[2], A[3] >= A[4])$ $-> 11, 7, 3, 1, 8 (A[1] >= A[5])$ $11, 7, 3, 1, 8$ is...
Can you simulate the following process in $O(N.log N)$
|algorithms|data-structures|balanced-search-trees|segment-trees|
Given an array $A[]$ of length $N$ For each $j>i$ increment all $A[i]$ by $1$ if $A[i]>=A[j]$ starting from left. for example lets start with: $7, 5, 2, 1, 8$ $-> 8, 5, 2, 1, 8 (A[1] >= A[2])$ $-> 9, 6, 2, 1, 8 (A[1], A[2] >= A[3])$ $-> 10, 7, 3, 1, 8 (A[1], A[2], A[3] >= A[4])$ $-> 11, 7, 3, 1, 8 (A...
Given an array $A[]$ of length $N$ For each $j>i$ increment all $A[i]$ by $1$ if $A[i]>=A[j]$ starting from left. for example lets start with: $7, 5, 2, 1, 8$ $-> 8, 5, 2, 1, 8 (A[1] >= A[2])$ $-> 9, 6, 2, 1, 8 (A[1], A[2] >= A[3])$ $-> 10, 7, 3, 1, 8 (A[1], A[2], A[3] >= A[4])$ $-> 11, 7, 3, 1, 8 (A...
Given an array $A[]$ of length $N$ For each $j>i$ increment all $A[i]$ by $1$ if $A[i]>=A[j]$ starting from left. for example lets start with: $7, 5, 2, 1, 8$ at $j=2 -> 8, 5, 2, 1, 8 (A[1] >= A[2])$ at $j=3 -> 9, 6, 2, 1, 8 (A[1], A[2] >= A[3])$ at $j=4 -> 10, 7, 3, 1, 8 (A[1], A[2], A[3] >= A[4])$ ...
Given a binary string with Kolmogorov Complexity of N, is there a string that is of length M where M>N such that M DOES NOT contains N?
Kolmogorov Complexity: Suppose a given Kolmogorov string K of length N - is there a M sized string s.t. it contains no subsequence that is K
|complexity-theory|kolmogorov-complexity|
Given a binary string with length N with Kolmogorov Complexity of at least N, is there a string that is of length M where M>N such that M DOES NOT contains N?
Given a binary string, K, with length N, and Kolmogorov Complexity N, is there a program P, of length M, and with Kolmogorov Complexity M such that: 1. P outputs K. 2. M >= N. 3. P does not contain K.
Kolmogorov Complexity: Is there a Program P which outputs Kolmogorov string K, P doesn't contain K and P is longer than K?
null
|algorithms|data-structures|balanced-search-trees|priority-queues|segment-trees|
Given an array $A[]$ of N integers. - Traverse from left to right of this array. - Let's say you are standing at index j. - For each index i, such that $j>i$ increment all $A[i]$ by $1$ if and only if $A[i]>=A[j]$. Once done move over to the next j for example lets start with: $7, 5, 2, 1, 8$ at $j=...
Given an array $A[]$ of N integers. - Traverse from left to right of this array. - Let's say you are standing at index j. - For each index i, such that $j>i$ increment all $A[i]$ by $1$ if and only if $A[i]>=A[j]$. Once done move over to the next j for example lets start with: $7, 5, 2, 1, 8$ at $j=...
Given an array $A[]$ of N integers. - Traverse from left to right of this array. - Let's say you are standing at index $j$. - For each index i, such that $i<j$ increment all $A[i]$ by $1$ if and only if $A[i]>=A[j]$. - Once done for all $i<j$ move over to the next $j$ ie $j=j+1$ for example lets start...
Given an array $A[]$ of N integers. - Traverse from left to right of this array. - Let's say you are standing at index $j$. - For each index i, such that $i<j$ increment all $A[i]$ by $1$ if and only if $A[i]>=A[j]$. - Once done for all $i<j$ move over to the next $j$ ie $j=j+1$ For example lets start...
Given an array $A[]$ of N integers. - Traverse from left to right of this array. - Let's say you are standing at index $j$. - For each index i, such that $i<j$ increment all $A[i]$ by $1$ if and only if $A[i] \ge A[j]$. - Once done for all $i<j$ move over to the next $j$ ie $j=j+1$ For example lets st...
Since the operation "add 1 to all values greater than or equal to i" preserves order, you can augment a self balancing BST with this operation. While the particulars are dependent on how the balancing is done, the idea is to keep in each node how much you need to add to its subtree, and push it to its children when you...
Given 2 arrays $A, B$ each of size $n$. If we want to find if the two arrays satisfy the condition that $A[i] + B[i] \ge k$ for all indices $i$, it's sufficient to fulfill 3 conditions below: 1. Sum of all elements of $A$ and $B$ is $\ge nk$ 2. Sum of max element of $A$ and min element of $B$ is $\ge k$ (edge cas...
null
The classical proof for the sample complexity of the hypothesis class of axis-aligned rectangles usually begins by stating that our $A(S) \subset R^*$, where $R^*$ is the target function. My only question is regarding the inclusion, surely if we have no positive samples, then there is no (obvious at least) reason to be...
Question about the proof for the sample complexity of axis-aligned rectangles
|machine-learning|learning-theory|
This question is a bit of a shot in the dark. I am asking here, though I am not convinced that such an example exists. I'd like a quick, highly intuitive example that I can throw out to my students *before* we engage in the halting problem. I will come back and explore RELs in more depth later in the lecture, but I ...
Simple, intuitive example of non recursively enumerable languages
|computability|turing-recognizable|
Suppose at least one of $L$ and $L'$ is empty. So is $L \circ L'$. Any trim automaton for $L\circ L'$ is the empty automaton. **Assume $L$ and $L'$ are nonempty from now on.** Let $A$ be the minimal trim automaton for $L\circ L'$. As your argument indicated, there must be exactly one state in $A$ at level $n$. Her...
Paging and swapping are not the same thing. The paging, which is needed for virtual memory, allows programs to run without their entire virtual address space (code and data) to be in RAM. Swapping moves an entire process to disk. while stored there, no computing occurs.
I'm at a problem I don't know better to name it - maybe it's already a well known problem... It seems quite simple: There are objects (o), each of them may be assigned freely to labels (p). A 2-dim binary matrix. Now assigments (s) can be done freely into that matrix. This defines partitions of objects, each...
Best balanced assignment
|algorithms|optimization|sets|assignment-problem|
I'm at a problem I don't know better to name it... maybe it's already a well known problem... It seems quite simple: There are objects (o), each of them may be assigned freely to labels (p). A 2-dim binary matrix. Now assigments (s) can be done freely into that matrix. This defines partitions of objects, each...
I'm at a problem I don't know better to name it... maybe it's already a well known problem... It seems quite simple: There are objects (o), each of them may be assigned freely to labels (p). A 2-dim binary matrix. Now assigments (s) can be done freely into that matrix. This defines partitions of objects, each...
null
Given an array $A[]$ of N integers. - Traverse from left to right of this array. - Let's say you are standing at index $j$. - For each index i=1 to i=j-1, such that $i<j$ increment all $A[i]$ by $1$ if and only if $A[i] \ge A[j]$. - Once done for all $i<j$ move over to the next $j$ ie $j=j+1$ For examp...
**Preliminaries**. Let $n,m \in \mathbb{N}$. Let our alphabet be $\Sigma = \{0,1\}$, with languages $ L \subseteq \Sigma^n$ and $ L' \subseteq \Sigma^m$. We follow the [standard definition](https://en.wikipedia.org/wiki/Finite-state_machine#Mathematical_model) for **deterministic** finite-state automata, in particular,...
**Preliminaries**. Let $n,m \in \mathbb{N}$. Let our alphabet be $\Sigma = \{0,1\}$, with **non-empty** languages $ L \subseteq \Sigma^n$ and $ L' \subseteq \Sigma^m$. We follow the [standard definition](https://en.wikipedia.org/wiki/Finite-state_machine#Mathematical_model) for **deterministic** finite-state automata, ...
null
We assume an automaton is deterministic throughout. As your argument indicates, there must be exactly one state in $A$ at depth $n$. Here is a rigorous proof. ------ **Claim**. If there is a path of length $i$ in $A$ from the initial state to state $s$, then $s$ is of depth $i$. **Proof**. That given path,...
We assume automata are deterministic throughout, as in the question. As your argument indicates, there must be exactly one state in $A$ at depth $n$. Here is a rigorous proof. ------ **Claim**. If there is a path of length $i$ in $A$ from the initial state to state $s$, then $s$ is of depth $i$. **Proof**. ...
[![enter image description here][1]][1] [1]: https://i.stack.imgur.com/qyS5h.png I'm trying to derive the language it represents. However, I'm kind of new to those topics. What happens if input b is gathered once or more than one time at state q without a in the stack? It does not have any transition, does ...
Simple pushdown automata question
|formal-languages|automata|pushdown-automata|
For many DFAs and PDAs, there is a computation path that will lead to a permanent reject state (and once computation reaches that reject state, any further transitions only return to that one state). For DFAs and PDAs that have such a state, these states (and all the transitions that lead to that state) are not shown i...
The left column shows you what symbol (0 or 1) is being consumed from the input. $\epsilon$ is not a consumed symbol, so whenever $q_2$ is visited, it could just as well be a $q_2$ or $q_3$ because of that $\epsilon$-transition. So upon the first $0$ symbol, the machine remains in $q_1$. Then after reading the first...
You should look into "state machines". Simple CPUs with variable length instructions have some kind of state machine. Default state is fetching the opcode, then it fetches parameters or do memory accesses, eventually going through different states to execute each instruction.
If you want to calculate time complexity using asymptotic notation, it's even easier (that's why it's so useful!). In the first for loop ``` for(int i = 1 ; i <= n ; i++) ``` the number of iterations increases linearly with the size of the input ($n$). The second, ``` for(int j = i + 1; j <= n - i; j++) ...
Given an array $A[]$ of N integers. - Traverse from left to right of this array. - Let's say you are standing at index $j$. - For each index i=1 to i=j-1, such that $i<j$ increment all $A[i]$ by $1$ if and only if $A[i] \ge A[j]$. - Once done for all $i<j$ move over to the next $j$ ie $j=j+1$ For examp...
Given an array $A[]$ of N integers. - Traverse from left to right of this array. - Let's say you are standing at index $j$. - For each index i=1 to i=j-1, such that $i<j$ increment all $A[i]$ by $1$ if and only if $A[i] \ge A[j]$. - Once done for all $i<j$ move over to the next $j$ ie $j=j+1$ For examp...
Given an array $A[]$ of N integers. - Traverse from left to right of this array. - Let's say you are standing at index $j$. - For each index i=1 to i=j-1, such that $i<j$ increment all $A[i]$ by $1$ if and only if $A[i] \ge A[j]$. - Once done for all $i<j$ move over to the next $j$ ie $j=j+1$ For examp...
Given an array $A[]$ of N integers. - Traverse from left to right of this array. - Let's say you are standing at index $j$. - For each index i=1 to i=j-1, increment all $A[i]$ by $1$ if and only if $A[i] \ge A[j]$. - Once done for all $i<j$ move over to the next $j$ ie $j=j+1$ For example lets start wi...
Since the operation "add 1 to all values greater than or equal to i" preserves order, you can augment a self balancing BST with this operation. While the particulars are dependent on how the balancing is done, the idea is to keep in each node how much you need to add to its subtree, and push it to its children when you...
Given an array $A[]$ of N integers. **pseudocode**: - Traverse from left to right of this array. - Let's say you are standing at index $j$. - For each index i=1 to i=j-1, increment all $A[i]$ by $1$ if and only if $A[i] \ge A[j]$. - Once done for all $i<j$ move over to the next $j$ ie $j=j+1$ For ex...
null
$T(n) = 5T(n/3) + 2n$ ---- (1) $5T(n/3) = 5^2T(n/9) + 5.2n/3$ ---- (2) $5^2T(n/9) = 5^3T(n/27) + 5^2.2n/9$ ---- (3) $5^3T(n/27) = 5^4T(n/81) + 5^3.2n/27$ ---- (4) . . . Adding the above equations: $T(n) = 5^4.T(n/3^4) + 2n + 5^1.2n/3^1 + 5^2.2n/3^2 + 5^3.2n/3^3 + ...$ as $n=3^{k-1}$ $T(n)...
$T(n) = 5T(n/3) + 2n$ ---- (1) $5T(n/3) = 5^2T(n/3^2) + 2n(5/3)$ ---- (2) $5^2T(n/3^2) = 5^3T(n/3^3) + 2n(5/3)^2$ ---- (3) $5^3T(n/3^3) = 5^4T(n/3^4) + 2n(5/3)^3$ ---- (4) . . . Adding the above equations: $T(n) = 5^4.T(n/3^4) + 2n + 5^1.2n/3^1 + 5^2.2n/3^2 + 5^3.2n/3^3 + ...$ as $n=3^{k-1}$ ...
$T(n) = 5T(n/3) + 2n$ ---- (1) $5T(n/3) = 5^2T(n/3^2) + 2n(5/3)$ ---- (2) [substitute $n/3$ for $n$ in previous equation and then multiply both sides by 5] $5^2T(n/3^2) = 5^3T(n/3^3) + 2n(5/3)^2$ ---- (3) $5^3T(n/3^3) = 5^4T(n/3^4) + 2n(5/3)^3$ ---- (4) $\vdots$ $5^{k-1}T(n/3^{k-1}) = 5^kT(n/3^k)...
$T(n) = 5T(n/3) + 2n$ ---- (1) $5T(n/3) = 5^2T(n/3^2) + 2n(5/3)$ ---- (2) [substitute $n/3$ for $n$ in previous equation and then multiply both sides by 5] $5^2T(n/3^2) = 5^3T(n/3^3) + 2n(5/3)^2$ ---- (3) $5^3T(n/3^3) = 5^4T(n/3^4) + 2n(5/3)^3$ ---- (4) $\vdots$ $5^{k-1}T(n/3^{k-1}) = 5^kT(n/3^k)...
Use Bluestein's FFT Algorithm, some realizations already exist. Reep in mind that this also increases the calculation error at large sizes (>10000).
Use Bluestein's FFT Algorithm, some realizations already exist. Keep in mind that this also increases the calculation error at large sizes (>10000).
$T(n) = 5T(n/3) + 2n$ ---- (1) $5T(n/3) = 5^2T(n/3^2) + 2n(5/3)$ ---- (2) [substitute $n/3$ for $n$ in previous equation and then multiply both sides by 5] $5^2T(n/3^2) = 5^3T(n/3^3) + 2n(5/3)^2$ ---- (3) $5^3T(n/3^3) = 5^4T(n/3^4) + 2n(5/3)^3$ ---- (4) $\vdots$ $5^{k-1}T(n/3^{k-1}) = 5^kT(n/3^k)...
$T(n) = 5T(n/3) + 2n$ ---- (1) $5T(n/3) = 5^2T(n/3^2) + 2n(5/3)$ ---- (2) [substitute $n/3$ for $n$ in previous equation and then multiply both sides by 5] $5^2T(n/3^2) = 5^3T(n/3^3) + 2n(5/3)^2$ ---- (3) $5^3T(n/3^3) = 5^4T(n/3^4) + 2n(5/3)^3$ ---- (4) $\vdots$ $5^{k-1}T(n/3^{k-1}) = 5^kT(n/3^k)...
I asked this question specifically about why the JVM has a separate area for local variables: https://stackoverflow.com/q/76086392/1463507 It was answered satisfactorily within the scope of the question, but it made me realise my real question is actually not what I asked, but rather this: Is it possible to compi...
Compile procedural code to pure stack operations
|compilers|stacks|
null
Yes, that is an error, because C is reachable from S by using the production rule S->aBC and derives the string ababb using production rule C->abb and B->b. Hence C is reachable.
I'm at a problem I don't know better to name it... maybe it's already a well known problem? It seems quite simple: There are objects and labels in a n:m relation. (Each of the n objects may be assigned from 0 to m labels). Let s be the sum of the overall assignments of all objects. You can take it as a 2-dim...
I'm at a problem I don't know better to name it... maybe it's already a well known problem? It seems quite simple: There are objects and labels in a n:m relation. (Each of the n objects may be assigned to any subset of the m labels). Let s be the sum of the overall assignments of all objects. You can take it...
I'm at a problem I don't know better to name it... maybe it's already a well known problem? It seems quite simple: There are objects and labels in a n:m relation. (Each of the n objects may be assigned to any subset of the m labels). Let s be the overall sum of the label-assignments of all objects. You can t...
I'm at a problem I don't know better to name it... maybe it's already a well known problem? It seems quite simple: There are objects and labels in a n:m relation. (Each of the n objects may be assigned to any subset of the m labels). Let s be the overall sum of the label-assignments of all objects. You can t...
Perhaps - if you want to avoid the Halting stuff - you can use the set $L$ of incompressible strings: You start from the definition: a string $x$ is compressible if there is a TM (or a generic "program" in some programming language) smaller in size than $|x|$ that outputs $x$ (when run on empty input) If there is...
null
Rather than converting to binary, it is more convenient to convert the page size to hexadecimal ($\text{0x10000}$). This hints you which are the significant hex-digits in the address.
null
It is known that Christofides’ algorithm returns a 3/2-approximation for the traveling salesman problem, assuming that the distances obey the triangle inequality. Suppose that we weaken the triangle inequality to the setting where distances obey the guarantee that for each triple $i, j, l \in V$ it is the case that $d...
Chistofides' algorithm for the traveling salesman problem with relaxed triangle inequality
|algorithms|graphs|algorithm-analysis|approximation|traveling-salesman|
null
Suppose that I have some nested algebraic data type (ie. something one can construct via `data`s in Haskell) that is serializeable (so no functional fields `a -> b`) is there any literature or known algorithms about how to _automatically_ derive an _efficient_ delta encoding of a change to that data type. ``` data ...
Literature on delta encoding serializeable ADTs
|functional-programming|haskell|
I am trying to use a boundary integral equation method to solve for laplace equation given the control points of a NURBS curve. But my BIEM is giving me very large error for numerical functions. I first did an analytical example of a circle and it work perfectly with negligible error, but then when I moved on to do ...
Help with Boundary Integral Equation Method with laplace equation (Given NURBS curve)