instruction
stringlengths
0
29.8k
⌀
|strings|sets|enumeration|
Given a list of strings enumerated over a finite alphabet, what's the most efficient way to get a string by its index number?
We want to design a **[Deterministic Finite Automaton (DFA)][1]** that **accepts** Binary Representation of Integers which are divisible by 3. > Now, by **accept**, in layman terms, we can say that when we are done with scanning string, we should be in one of the multiple possible Final States. > > More Formally...
Easier problem: Suppose you want the $i$th string, from all length-$k$ strings over that template. Can you find the $i$th string? This is easy. I'll let you figure out how to do that. Your problem: Suppose you want the $i$th string. Well, there are $1+6+6^2+\dots+6^k$ strings of length $\le k$ over this alphabet...
Easier problem: Suppose you want the $i$th string, from all length-$k$ strings over that template. Can you find the $i$th string? This is easy. I'll let you figure out how to do that. Your problem: Suppose you want the $i$th string. Well, there are $1+6+6^2+\dots+6^k$ strings of length $\le k$ over this alphabet...
null
null
I have a question about the use of calibration in neural networks and its relation to accuracy. In [Guo et al.][1] it says: "Because the parameter T does not change the maximum of the softmax function, the class prediction remains unchanged. **In other words, temperature scaling does not affect the model’s accuracy**."...
Why does Calibration of NN not lead to higher accuracy?
|neural-networks|
I have a coding problem I'm running into that feels like it's solved: Given a (directed) graph, and an equivalence relation on nodes, merge the equivalent nodes in a way that preserves the graph structure to create a "factor" graph, in the sense that every edge connected to one of the equivalent nodes is connected t...
Algorithm for "Factoring" Graph by Equivalence Relation
|algorithms|graphs|
I am trying to do some runtime analysis on a problem, but get stuck on some details. I have a string $P$ of length $n$, where I am allowed to halve substrings inside of it and keep the right-hand side of it to form new strings. We can now halve substrings in the new string. The length of the substrings that are halv...
Big O notation for halving substrings in a string of length n
|algorithms|time-complexity|runtime-analysis|
I am trying to do some runtime analysis on a problem, but get stuck on some details. I have a string $P$ of length $n$, where I am allowed to halve substrings inside of it and keep the right-hand side of it to form new strings. We can now halve substrings in the new string. The length of the substrings that are halv...
I am trying to do some runtime analysis on a problem, but get stuck on some details. I have a string $P$ of length $n$, where I am allowed to halve substrings inside of it and keep the right-hand side of it to form new strings. We can now halve substrings in the new string. The length of the substrings that are halv...
Presumption: We're talking about CPU. At the lowest level, we have only logic gates. [We may go even lower than that ;) ]. In that sense even `add` is a combination of logic operation, else CPUs have much more instructions besides addition. For arithmetic: subtraction can be represented as `a + (-b)`, multiplicat...
According to my syllabus, this is a dynamic programming problem yet the explanation to the problem I’m supplied with is really confusing and not close to being understandable. The problem is such: You are required to give change equal to `n` (n is a positive nonzero integer, not necessarily bigger than biggest co...
Finding minimal amount of coins to reach n
|dynamic-programming|linear-complexity|
Say you have the finite alphabet $\{a,b,c,d,e,f,g\}$ and an enumeration of finite strings over it by the shortlex order (length-lexicographic ordering), starting with the empty string, i.e., $\epsilon, a, b, c, d, e, f, g,$ $aa, ab, ac, \cdots,$ $gg, \cdots, aaa, aab, aac,$ $\cdots, ggg, \cdots$. What's the most e...
|algorithms|strings|enumeration|
Given a list of strings enumerated over a finite alphabet, what's the most efficient way to get a string by its index?
Motivation & Question --- So I can [theoretically build][1] a "computer" to calculate the exact anti-derivative of a particular function. > Using classical calculations and the Robin boundary condition I show > that one calculate the anti-derivative of a function within time $2X$ > (I can compute an integral b...
What is the quickest algorithm to numerically integrate this function?
|complexity-theory|numerical-algorithms|physics|
null
I have a coding problem I'm running into that feels like it's solved: Given a (directed) graph, and an equivalence relation on nodes, merge the equivalent nodes in a way that preserves the graph structure to create a "factor" graph, in the sense that every edge connected to one of the equivalent nodes is connected t...
Is There a Term for "Factoring" a Graph by an Equivalence Relation on Nodes?
|graphs|terminology|
Motivation & Question --- So I can [theoretically build][1] a "computer" to calculate the exact anti-derivative of a particular function. > Using classical calculations and the Robin boundary condition I show > that one calculate the anti-derivative of a function within time $2X$ > (I can compute an integral b...
This problem is similar to the [Knapsack problem][1]. The only difference is that in your case you need to minimize (the amount of coins) instead of maximize (the amount of items in the bag). The problems are very similar, I think you can get the solution alone :) [1]: https://en.wikipedia.org/wiki/Knapsack_pr...
null
null
null
Pipelined processors suffer from stalls due to different kind of hazards and one way of dealing with it is to implement forwarding of different types. For example ALU-ALU forwarding or full forwarding (MEM stage -> EX stage). A result of implementing forwarding in a pipelined processor is that we get an increased throu...
Forwarding in pipelined processors can increase throughput by decreasing amount of stalls, but can it in some cases impair performance?
|performance|cpu-pipelines|
>Given a Min-Heap with $n$ elements. <br> Assume that we choose $\lceil \log_2n \rceil$ elements from the heap (not in any specific order/index's), and we subtract a value $k>0$ from all of their keys. <br> Suggest an algorithm to fix the min-heap that runs in $O((\log_2n)^2)$. **My thoughts:** <br> In a min heap...
Fixing the min-heap after subtracting a value from a couple random elements in it
|data-structures|heaps|
You already know the Suurballe algorithm that works for paths with same source and same destination vertices. So to solve your problem, you can just add a dummy vertex S to your graph and connect Start node of path1 and start node of path2 to S with edge weight 0. Add a dummy vertex E to your graph and connect End node...
I've been assigned to find the loop invariant for the following code: i=0; j=n-1; while(i < n/2){ l = A[i]; r = A[j]; A[j] = l; A[i] = r; j = j-1; i = i+1; } I understand the code function (reverses array), the guard (`i < n/2`), and I can find different i...
Finding the loop invariant for Array Reversal
|correctness-proof|first-order-logic|loop-invariants|
null
It doesn't change the model's prediction (which class it predicts), but it *does* change the model's confidence in its prediction (the value of the corresponding softmax output). The point of uncertain estimation is to make this confidence reflect the degree of certainty we should have in the model's prediction. Th...
null
The invariant will express that we have performed a partial reversal, i.e. the array zones `A[0..i[` and `A[n-i..n[` have been swapped the intended way, while the middle is unchanged. So, if you denote the *initial* content of the array as `Z`, the invariant is like Forall k: k < i => A[k] = Z[n-k] and n/2 > ...
It’s easier to figure out if k is large, say k = 100. You start by creating two heaps with 50 elements each, one with the 50 smallest of the first 100 numbers with fast access to the largest one, and one with the 50 largest, with fast access to the smallest one. The median of all 100 items can be found in O(1). ...
A complete $k$-CNF formula is a $k$-CNF formula which contains all clauses of size $k$ or lower it implies. Deciding the satisfiability of a complete $k$-CNF formula is clearly a tractable problem since a $k$-CNF formula is satisfiable as long as it does not contain the empty clause. Let define the (Complete/Assign)...
null
First you remove the O(log n) items from the heap. You can do this by finding their indices then removing them starting with the highest index. Make sure that your removal algorithm doesn’t move any items at lower indices. Then you modify the keys any way you like and move them back into the heap. Operations on the...
A complete $k$-CNF formula defined on $n$ variables $(k\le n)$ is a $k$-CNF formula which contains all clauses of size $k$ or lower it implies. Let define the (Complete/Assign) 3-SAT problem : Given $F$, a complete 3-CNF formula on $n$ variables and $I$, a partial assignment of $l$ literals among $n\ (l\le n)$. Let...
null
It’s easier to figure out if k is large, say k = 100. You start by creating two heaps with 50 elements each, one with the 50 smallest of the first 100 numbers with fast access to the largest one, and one with the 50 largest, with fast access to the smallest one. The median of all 100 items can be found in O(1). ...
$L=\{a^ib^ja^k \mid j \text{ is odd, then } k=i^2+j ;\text{ } j \text{ is even, then } k =i+j\}$ I tried writing $L$ as the union of the language created with $j$ odd and the one with $j$ even. When $j$ is odd, I can prove using the pumping lemma that it is not a cfl. When $j$ is even, I can prove that it is...
Is $L=\{a^ib^ja^k \mid j \text{ is odd, then } k=i^2+j ;\text{ } j \text{ is even, then } k =i+j\}$ context-free?
|formal-languages|finite-automata|context-free|pumping-lemma|
null
$L=\{a^ib^ja^k \mid j \text{ is odd, then } k=i^2+j ;\ j \text{ is even, then } k =i+j\}$ I tried writing $L$ as the union of the language created with $j$ odd and the one with $j$ even. When $j$ is odd, I can prove using the pumping lemma that it is not a cfl. When $j$ is even, I can prove that it is a cfl ...
Is $\{a^ib^ja^k \mid j \text{ is odd, then } k=i^2+j ;\ j \text{ is even, then } k =i+j\}$ context-free?
|formal-languages|context-free|pumping-lemma|
null
The invariant will express that we have performed a partial reversal, i.e. the array zones `A[0..i[` and `A[n-i..n[` have been swapped the intended way, while the middle is unchanged. So, if you denote the *initial* content of the array as `Z`, the invariant is For all integer k: 0 ≤ k < i => A[k] ...
What is being summed and why? `s'` is the next state. Don't we just want the next state with the max value? There is an `s'` under the summation, so are all the possible the `s'` in P and the `s'` in `V(s')` being summed? Or is everything to the right of the summation being summed? The `s`, the `a`, the `s'` and ...
What is being summed in the Bellman Equation and why?
|dynamic-programming|mathematical-programming|reinforcement-learning|
What is being summed and why? `s'` is the next state. Don't we just want the next state with the max value? There is an `s'` under the summation, so are all the possible `s'` in P and the `s'` in `V(s')` being summed? Or is everything to the right of the summation being summed? The `s`, the `a`, the `s'` and the ...
The invariant will express that we have performed a partial reversal, i.e. the array zones `A[0..i[` and `A[n-i..n[` have been swapped the intended way, while the middle is unchanged. So, if you denote the *initial* content of the array as `Z`, the invariant is like Forall k: k < i => A[k] = Z[n-k] and n/2 > ...
We can prove $L$ is not a CFL using the pumping lemma by choosing the string $a^pb^{1}a^{p^2+1}$, where $p$ is the constant in the pumping lemma. Since $|vwx|\le{p}$, we can have: If $v$ or $x$ contains more than one type of letter, so when we pump the order breaks. If both $v$ and $x$ contain only $a$'s then ...
What is being summed and why? `s'` is the next state. Don't we just want the next state with the max value? There is an `s'` under the summation, so are all the possible `s'` in P and the `s'` in `V(s')` being summed? Or is everything to the right of the summation being summed? The `s`, the `a`, the `s'` and the ...
I heard a few times that if we allow computations with infinite precision, we could have unrealistic powers of computation up to the point of solving NP problems efficiently. Is it true? If yes: - what is the model of computations used to define infinitely precise arithmetic? Like do we need to assume that accessin...
Solving efficiently NP problems with infinite precision
|np-complete|computation-models|
We can prove $L$ is not a CFL using the pumping lemma by choosing the string $a^pb^{1}a^{p^2+1}$, where $p$ is the constant in the pumping lemma. Since $|vwx|\le{p}$, we can have: If $v$ or $x$ contains more than one type of letter, so when we pump the order breaks. If both $v$ and $x$ contain only $a$'s then ...
What is being summed and why? $s'$ is the next state. Don't we just want the next state with the max value? There is an $s'$ under the summation, so are all the possible $s'$ in $P$ and the $s'$ in $V(s')$ being summed? Or is everything to the right of the summation being summed? The $s$, the $a$, the $s'$ and th...
|dynamic-programming|
We can prove $L$ is not a CFL using the pumping lemma by choosing the string $a^pb^{1}a^{p^2+1}$, where $p$ is the constant in the pumping lemma. Since $|vwx|\le{p}$, we can have: If $v$ or $x$ contains more than one type of letter, so when we pump the order breaks. If both $v$ and $x$ contain only $a$'s then ...
null
I would love to learn visual AI and what better way than creating a bot to play offline games. The problem is with no experience in AI other than Azure through my college, I have no experience. Does anyone have resources that could aid in my learning or any tips for getting started? All will be appreciated.
Where should I start for making an AI Bot that processes on screen prompts
|machine-learning|artificial-intelligence|
null
More generally you should read about [deep reinforcement learning][1]. [1]: https://en.wikipedia.org/wiki/Deep_reinforcement_learning
null
null
null
proof that if L is Context-free language then exists n>0 $ n\in \mathbb{N} $ such that >$ \forall z\in L $ that that sustains $ |z|\ge n $ exists a dissolution $ z=uvwxy $ that sustains >$ I. |vwx|\ \ I.|x|+|v|\geq2 \ \ III.\forall i\geq 0 : uv^iwx^iy\in L$ HINT: n needs to be bounded $ n\leq 2^{2k}$ which give...
pumping lemma for context-free language proof
|context-free|pumping-lemma|
According to my syllabus, this is a dynamic programming problem yet the explanation to the problem I’m supplied with is really confusing and not close to being understandable. The problem is such: You are required to give change equal to `n` (n is a positive nonzero integer, not necessarily bigger than biggest co...
I'm wondering if a language (A) is a decidable language, meaning it is a language in R, and language (B) is a regular language, is the intersection between A and B regular? Why/Why not???
Decidability of intersection of regular and decidable languages
|turing-machines|regular-languages|automata|
|automata|finite-automata|context-free|pumping-lemma|
null
Complexity of the (Complete/Assign) 3-SAT problem?