instruction stringlengths 0 29.8k ⌀ |
|---|
Generally, if a soldier was called out before, its position in the line equals the number of distinct soldiers between the two calls. This is because of the fact that after a callout of a soldier, its position equals $1$, and this number will increase by $1$ after each new callout of another soldier standing behind him... |
From your explanations I understand that "most accurate" should be understood as "longest".
- Sort the search strings by decreasing length.
- Perform searches of the strings in that order.
- Every time you find a match, delete these characters from the target string.
E.g. "Big Apple", "Google", "Apple".
... |
Question is to simplify (LM*)* and I couldn't figure out a way to simplify it. Since (L+M)* = M*.(L.M*)*, I guess we can say that it cannot be simplified more. So how do we prove that they are the same and expression $(LM^*)^*$ cannot be simplified more |
How to prove (L+M)* = M*.(L.M*)* |
|automata|finite-automata|regular-expressions|proof-techniques| |
Let $\mathcal{A}$ be a family of integer matrices, $\mathcal{B}$ a family of integer vectors, and $k$ an integer. Define $L(\mathcal{A}, \mathcal{B}, k)$ to be the following family of decision problems.
> INPUT: a matrix $A\in \mathcal{A}$ and a vector $b\in \mathcal{B}$,
>
> OUTPUT: "True" if there exists a real ... |
I have a total order represented as a Hasse diagram (basically a linked list of ordered elements) and a concurrency oracle.
The concurrency orracle is a function, that tells me which pairs of elements of the total order, are concurrent - should not be ordered.
My goal is to use the information provided by the ora... |
Given a set $S$, a value function $v(s)$ and a cost function $c(s)$ for all $s \in S$, and integers $B$ and $K$, the classic formulation of the Knapsack problem asks if there is a subset $S' \subseteq S$ in which $\sum_{s \in S'} v(s) \geq K$ and $\sum_{s \in S'} c(s) \leq B$.
Is there a variation/special case of t... |
Knapsack with no capacity |
|complexity-theory|knapsack-problems| |
Generally, if a soldier was called out before, its position in the line equals the number of distinct soldiers between the current and the previous callout. This is because of the fact that after a callout of a soldier, its position equals $1$, and this number will increase by $1$ after each new callout of another sold... |
Given a set $S$, a value function $v(s)$ and a cost function $c(s)$ for all $s \in S$, and integers $B$ and $K$, the classic formulation of the Knapsack problem asks if there is a subset $S' \subseteq S$ in which $\sum_{s \in S'} v(s) \geq K$ and $\sum_{s \in S'} c(s) \leq B$.
Is there a variation/special case of t... |
> how does this not cause issues for programming in DYALOG APL?
Truth to be told, it *does* cause issues, but maybe not the issues you'd think: The real issue is the introduction of a global variable that governs core language behaviour. If one expects divisions by zero, then it is wise to set a local value for `⎕DI... |
You are testing whether n is divisible by consecutive i, for 2 ≤ i up to some limit. You want that limit to be small, to avoid unnecessary tests. Usually people start at their very first attempt with trying 2 ≤ i ≤ n-1 which does roughly n divisions is n is a prime.
If n is not prime, then it has a smallest prime f... |
null |
How is the number of collisions affected by the order of insertion of elements in a hash table using double hashing?
I've tried uing different hash function for double hashing with different set of values. The position of the elements in the hash table seem to change but the number of collsion remains the same so fa... |
Effect of Insertion order on number of collisions in Double Hashing |
|untagged| |
Is there any algorithm that can efficiently construct a [generalized suffix tree](https://en.wikipedia.org/wiki/Generalized_suffix_tree) or array (or something similar) for a prefix tree (trie)?
In particular, I'm wondering:
- How time-efficient an algorithm for this can be
- How space-efficient the resulting ... |
Generally, if a soldier was called out before, its position in the line equals the number of distinct soldiers between the current and the previous callout. This is because of the fact that after a callout of a soldier, its position equals $1$, and this number will increase by $1$ after each new callout of another sold... |
Is there any algorithm that can efficiently construct a [generalized suffix tree](https://en.wikipedia.org/wiki/Generalized_suffix_tree) or array (or something similar) for a set of strings represented by a prefix tree (trie)?
In particular, I'm wondering:
- How time-efficient an algorithm for this can be
- Ho... |
null |
See [Guy Steele's slides](https://groups.csail.mit.edu/mac/users/gjs/6.945/readings/Steele-MIT-April-2017.pdf) for what I refer to by "Computer Science Metanotation".
I often make use of the BNF syntax observed there, as a substitute for algebraic data types in functional programming languages. Alas, it loses quite ... |
Function types in Computer Science Metanotation |
|programming-languages|notation| |
null |
null |
Given a graph $G$, how can we generate all possible color vectors that could be generated via greedy coloring?
N.B. Greedy coloring takes a graph and an order of vertices. It traverses vertices following that order and, while visiting a vertex $v$, puts the minimum color absent in all neighbors of $v$.
If $G$ ... |
This is a very old question, but is a good question and deserves an answer.
The basic issue is that if we let the probabilistic algorithm run for an unbounded amount of time (and randomness), it can solve NL in a trivial way. In fact, it can solve NL in RL, and even ZPL. But it does so by running in an exponential a... |
Yes, there are examples, though I don't know of any elementary ones. Before I give one, notice that
$$
n^{\log n} = (2^{\log n})^{\log n} = 2^{(\log n)^2} = O(2^{\text{poly}(\log n)})
$$
where $\text{poly}$ is a polynomial function (in this case quadratic).
For this reason, the time complexity you are interested... |
null |
null |
Kernel registers can only be accessed in kernel mode, but are particular to a process. In x86 they include, for example, a pair of registers which demlimit the address space of the process. |
Suppose there is an array having at most 10 elements between 1 to 10^18. Suppose the array has elements B1,B2,.Bn. We can choose sequence A1,A2,A3,..An such that 0<=Ai<=Bi. Count How many sequences satisfy A1|A2|A3|..|An=A1+A2+A3+..An, where | is bitwise OR.
|
Find Number of subsequences such that bitwise OR is same as sum |
|algorithms|dynamic-programming|counting|bit-manipulation| |
See [Guy Steele's slides](https://groups.csail.mit.edu/mac/users/gjs/6.945/readings/Steele-MIT-April-2017.pdf) for what I refer to by "Computer Science Metanotation", specifically the bits about BNF.
I often make use of the BNF syntax observed there, as a substitute for algebraic data types in functional programming... |
null |
Suppose you want to compute $$\binom{n}{k}$$ for given $k$ and $n$. A simple way is to use brute-force that running time will be $O(n^{k})$. Now if we set $k=O(\log n)$ we achieved desired bound. |
I was reading [Deterministic Black Box PIT Testing for Generalized Depth 3 Arithmetic Circuits - Karnin and Shpilka](https://www.cs.tau.ac.il/~shpilka/publications/KarninShpilka_BB_PIT.pdf)
>In the **Theorem 3.4** they told $rank(C|_V)\geq rank(C)$
How is this possible? Since $sim(C|_V)=C|_V$ and by the definitio... |
Why $rank(C|_V)\geq rank(C)$ for $r$-rank preserving subspace |
|complexity-theory|circuits| |
Why $rank(C|_V)\geq rank(C)$ for $r$-rank preserving subspace for depth 3 circuits |
null |
In the "First Draft" JvN described an adder circuit to do binary addition, which was a much faster way of doing computer addition than using decimal lookup tables as the ENIAC had done. JvN's main reference was McCulloch and Pitts' neuron model (although Eckert and Mauchly claimed it was their idea).
However, CS ha... |
Did Jon von Neumann know about Claude Shannon's work when he wrote the "First Draft of a Report on the EDVAC?" |
|history|digital-circuits| |
null |
Your numbers are less than $10^{18} < 2^{60}$, so only bits 0 to 59 can be set. Prove that for 59 >= b >= 0, bit number b is set in at most one of the $A_i$, and go from there. |
I have two optimization problems $A$ and $B$, and I recently managed to show that there exist functions $f$ and $g$ that are computable in polynomial time, such that for any instance $x$ of $A$ there holds
$$OPT_A(x) + g(x) = OPT_B(f(x)).$$
I know that $A$ is NP-hard, which implies that $B$ must be NP-hard as well.... |
Does adding a polynomial-time function impact APX-hardness? |
|complexity-theory| |
{"Voters":[{"Id":755,"DisplayName":"D.W."}]} |
I was reading [Deterministic Black Box PIT Testing for Generalized Depth 3 Arithmetic Circuits - Karnin and Shpilka](https://www.cs.tau.ac.il/~shpilka/publications/KarninShpilka_BB_PIT.pdf)
>In the **Theorem 3.4** they told $rank(C|_V)\geq rank(C)$
How is this possible? Since $sim(C|_V)=C|_V$ and by the definitio... |
I have experimented with a grammar that I could turn into a strict left-to-right finite state automaton driven algorithm (bottom up, table driven). The FSA could be complex, that's not a problem. It doesn't need to deal with infinite recursive structures.
I then moved the grammar into BNF, and built a standard SLR ... |
Parsing algorithms |
|parsers| |
**TLDR**; Looking for Explanation of Cook-Levin theorem palatable to CS first years who are theory averse
I'm a prof. teaching first year algorithms+programming and want to give my students a taste of deeper CS theory.
In the very last week of class, I want to cover (in two lectures) the key idea behind Turing Ma... |
Explanation of Cook-Levin Suitable for First Years |
|complexity-theory|education| |
It seems useful to characterize terminating programs. While trying to formulate that as a well-defined question I was wondering about the following problem:
Is there a maximal decidable set of terminating programs?
A set is maximal if it is not the subset of another such set. A program may be a Turing Machine or ... |
Is there a maximal set of programs that terminate? |
|undecidability|halting-problem| |
I anticipate that the Cook-Levin theorem and its proof will be too much for CS first-years. I do not recommend that you try to teach that.
Instead, I recommend that you show them something awesome that is appropriate for their level of development and understanding. Maybe show them two lectures on machine learning... |
Your proof is correct. There is no maximal set. Yes, your conclusion is right, there is no optimal termination decider, as you can always come up with another one that detects one more terminating program. It's like noting that there is no largest number: for any number you name, I can always name one that is bigger... |
null |
Working on logic design in class, and I'm trying to figure out how to write a specific logic function [and by write, I mean something along the lines of (x NOR y) OR (a NOR b), for example]
It asks to assume 2 variables, X and Y, both of which consist of 3 bits (x2,x1,x0, and y2,y1,y0). I need to write a logic funct... |
How do you write a logic function to determine if one 2s complement binary number is less than another? |
|logic|circuits|digital-circuits|comparison| |
null |
null |
**Layers:** We shall denote in the following the layer number by the upper script $\ell$. We have $\ell=0$ for the input layer, $\ell=1$ for the first hidden layer, and $\ell=L$ for the output layer. The number of neurons in the layer $\ell$ is denoted by $d^{(\ell)}$. In particular, $d^{(0)}$ is the number of inputs a... |
How to calculate the upper bound of the gredient of a multi layer ReLu neural network |
|gradient-descent| |
**Layers:** We shall denote in the following the layer number by the upper script $\ell$. We have $\ell=0$ for the input layer, $\ell=1$ for the first hidden layer, and $\ell=L$ for the output layer. The number of neurons in the layer $\ell$ is denoted by $d^{(\ell)}$. In particular, $d^{(0)}$ is the number of inputs a... |
For each bit, you can `XOR` to check if they are different (if they are not, then no need to compare) and if they are different, you can use the value in `Y` (if `(X,Y)` is `(0,1)` we need to return true) and or the results together. If all the `XORs` return 0, the two numbers are equal. Now to implement your specific ... |
If you have n cities, and you increase every single distance by the same distance d, then the length of every tour is increased by the same amount n x d. So whether tour A is better than your B or not is unchanged, and the optimal tour stays the same. For the decision problem: instead of deciding whether there is a tou... |
This page shows you the formula for a one-bit subtractor with borrows in and out. You can use this as a building block for a three-bits subtractor:
https://www.geeksforgeeks.org/full-subtractor-in-digital-logic/.
$$D=(A\oplus B)\oplus B_{\text{in}}\\B_{\text{out}}=((\lnot A)\land (B_{\text{in}}\lor B))\lor(B\land ... |
See [Guy Steele's slides](https://groups.csail.mit.edu/mac/users/gjs/6.945/readings/Steele-MIT-April-2017.pdf) for what I refer to by "Computer Science Metanotation", specifically the bits about BNF.
I often make use of the BNF syntax observed there, as a substitute for algebraic data types in functional programming... |
I was reading [Deterministic Black Box PIT Testing for Generalized Depth 3 Arithmetic Circuits - Karnin and Shpilka](https://www.cs.tau.ac.il/~shpilka/publications/KarninShpilka_BB_PIT.pdf)
>In the **Theorem 3.4** they told $rank(C|_V)\geq rank(C)$
How is this possible? We have $sim(C|_V)=C|_V$. $V$ is $R_{\mathc... |
I was reading [Deterministic Black Box PIT Testing for Generalized Depth 3 Arithmetic Circuits - Karnin and Shpilka](https://www.cs.tau.ac.il/~shpilka/publications/KarninShpilka_BB_PIT.pdf)
>In the **Theorem 3.4** they told $rank(C|_V)\geq rank(C)$
We have $C|_V$ which is simple (i.e. $sim(C|_V)=C|_V$) and minim... |
If you will introduce SAT then you could use a SAT solver to do Soduku. |
If you have just two bit values A and B, then(A > B) = A AND NOT B, and (A >= B) = A OR NOT B.
With two bits A1,A2 and B1,B2 (A > B) = (A1 > B1) OR (A1 >= B1) AND (A2 > B2), (A >= B) = (A1 > B1) OR (A1 >= B1) AND (A2 >= B2).
You can add more bits in the same way. Creating a circuit, you’d check what logic is re... |
If you have n cities, and you increase every single distance by the same amount d, then the length of every tour is increased by the same amount n x d. So whether tour A is better than tour B or not is unchanged, and the optimal tour stays the same. For the decision problem: instead of deciding whether there is a tour ... |
null |
null |
The comment basically has the right idea: What you want is some kind of LR parsing; GLR is fine.
You see, if a grammar is not $LR(k)$ but you try to build a $LR(k)$ automaton for it anyway, then the automaton is still correct and will still parse it just fine. The catch is that it is nondeterministic. Shift-reduce a... |
Given a preorder traversal of a tree, say a-b-c-d-e-f, you can guess a tree as follows:
- use the first element as the root,
- partition the rest of the sequence in a number of subsequences than will correspond to descendants,
- repeat recursively.
E.g.
abcdefg
a
bc def g
... |
**Applying a Simulating Halt Decider to the Linz Halting Problem Proof**
A simulating halt decider correctly predicts whether or not its correctly simulated input can possibly reach its own final state and halt. It does this by correctly recognizing several non-halting behavior patterns in a finite number of steps o... |
Given a preorder traversal of a tree, say a-b-c-d-e-f, you can guess a tree as follows:
- use the first element as the root,
- partition the rest of the sequence in a number of subsequences than will correspond to descendants, left to right,
- repeat recursively.
E.g.
abcdefg
a
/... |
Recently, I’ve been interested in the console of the Source game engine, more specifically, its `alias` command, which allows one command to invoke others. It may allow recursion (i.e. running `alias freeze freeze` will cause inputting `freeze` to freeze the engine), but does not allow parameters (i.e. running "`alias ... |
If you have an elimination rule for tuples which introduce the left and right pair into the type checking context, what do you do if one of the elements is quantified/Skolemized. Isn't it impossible to prevent the Skolem value from escaping its scope here? |
How do you deal with Skolem functions which escape their scope in elimination rules? |
|logic|type-theory|type-checking| |
Recently, I’ve been interested in the console of the Source game engine, more specifically, its `alias` command, which allows one command to invoke others. It may allow recursion (i.e. running `alias freeze freeze` will cause inputting `freeze` to freeze the engine), but does not allow parameters (i.e. running "`alias ... |
The problem MATCH is defined as follows: given a finite set S of strings of length n over the alphabet {0, 1, ∗}, determine if there exists a string w of length n over the alphabet {0, 1} such that for every string s ∈ S, s and w have the same symbol in at least one position. For example, if S = {001∗, ∗100, 10 ∗ 0, 10... |
Prove that the problem MATCH is NP-complete |
|complexity-theory|computability|algorithm-analysis|np-complete|np-hard| |
I think the language's grammar should look like
S -> aScc | bB | epsilon
B -> bB | epsilon
This way, there is no way to reach the string bcc, which is not in the language.
|
If the language required twice as many c's as a's,
the equivalent grammar should look like
S -> aScc | bB | epsilon
B -> bB | epsilon
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.