instruction
stringlengths
0
29.8k
⌀
let n = 1 in let plus_and_print x = print (x + n) in let incrementBy2_and_print a = let n = n + 2 in plus_and_print n in (* Notice: arg a of incrementBy2_and_print is not used *) let n = 100 in (plus_and_print 5; let n = 40 in (incrementBy2_and_print 0; print n)) I w...
I have the following OCaml code, what would be the output for static scoping and dynamic scoping?
|dynamic-programming|static-analysis|ocaml|
null
I am reading this paper on RSA attacks and it describes the equation where ed = 1 mod φ(N) This confuses me because wouldn’t 1 mod of anything (not 1) just always be equal to 1?
Confusion on RSA attack equation
|encryption|
null
null
Let h : {0, 1}∗ → {a, b}∗ be the function defined by h(e) = e, h(0) = aa and h(1) = b, and for words of length two or greater: h(a1a2 . . . an) = h(a1)h(a2) . . . h(an) for n ≥ 2 and ai ∈ {0, 1}. For a language L ⊆ {0, 1}∗ we define h(L) = {h(w) | w ∈ L} ⊆ {a, b}∗ For each of the following languages, give a ...
For each of the following languages, give a regular expression over {a, b} that corresponds to h(L):
|automata|finite-automata|regular-expressions|
null
Facing confusion due to two different texts stating different ways to show examples of ambiguous grammar, though the example exists in the first book. The second book gives a different example, as shown [![attachment][1]][1]. The first text is: Compliers and Compiler Generators An Introduction With C++, by Patri...
Correct way to show example of ambiguous grammar
|untagged|
null
null
null
This is what is known as a modular inverse. The easiest way to think about this is to think of the multiplication table in modular arithmetic. Let's start with the modulus being a prime number, 5. $$\begin{array} {}\times{} & 0 & 1 & 2 & 3 & 4 \\ \hline 0 & 0 & 0 & 0 & 0 & 0 \\ 1 & 0 & 1 & 2 & 3 & 4 \\ 2 & 0...
null
null
Since circuits and processors are heavily influenced and designed based upon boolean logic, which is itself a subset of propositional logic, could there be different interpretations of hardware or software based on another logic, like linear temporal logic or a description logic? I mean, for example, could it be pos...
Could there be a computer or components based on a non-classical logic?
|computer-architecture|logic|compilers|software-engineering|
null
(An isogram is a word in which no letters repeat.) I'd like to know if there's a standard name for this problem, and/or any standard algorithms. If not, I'm interested if anyone has any ideas about how to solve it efficiently. **Input.** - A list $X$ of $n$-many isograms. **Output.** - An isogram $y$. ...
Prefix permutation problem
|optimization|compilers|permutations|program-optimization|word-combinatorics|
(An isogram is a word in which no letters repeat.) I'd like to know if there's a standard name for this problem, and/or any standard algorithms. If not, I'm interested if anyone has any ideas about how to solve it efficiently. **Input.** - A list $X$ of $n$-many isograms. **Output.** - An isogram $y$. ...
(An isogram is a word in which no letters repeat.) I'd like to know if there's a standard name for this problem, and/or any standard algorithms. If not, I'm interested if anyone has any ideas about how to solve it efficiently. **Input.** - A list $X$ of $n$-many isograms. **Output.** - An isogram $y$. ...
Minimum number of swaps to achieve prefix constraints
Minimum number of swaps to achieve prefix constraint
(An isogram is a word in which no letters repeat.) I'd like to know if there's a standard name for this problem, and/or any standard algorithms. If not, I'm interested in whether anyone has any ideas about how to solve it efficiently. **Input.** - A list $X$ of $n$-many isograms. **Output.** - An isogr...
The arithmetic expression you provided `12 + 7 * 45 / 9 - 6 + 5` will cause the parser to return syntax error because `12` is not part of the language (same problem for `45`...). Specifically, it is not a token and will be recognized as the symbol `1` followed by `2` that is obviously illegal. To manage numbers in the ...
You provided a grammar of the shape: - $E \rightarrow E - E$ - $E \rightarrow E * E$ - $E \rightarrow F$ - $F \rightarrow a | b | c$ The second last production has $E$ on its LHS; it is a unit production that can be removed to produce the grammar: - $E \rightarrow E - E$ - $E \rightarrow E * E$ - $E \r...
By *rule*, I assume you mean a transition. You can do this by first replacing the original DFA, $M$, with a new one that records whether or not an $a$ has ever been read, as follows: - for each state $q$ of $M$, it has two states: - $q_b$ ("$q$ before $a$") - $q_a$ ("$q$ after $a$") - for each transiti...
I found an NP-complete problem, [Applying a permutation on a sequence with multiplication,][1] that reduces to my problem. The reduction produces an input to my problem where sequence $a_i$ is the set $L$, $M=\{1,2,3, ..., n\}$, and C=x. This proves that the problem of numerical perfect matching is NP-complete for u...
**Toughness** is defined as $$ t(G)=\min _S \frac{|S|}{c(G-S)} $$ where $c$ is the number of connected components and the minimum is taken over all vertex cuts $S$ of $G$ (Graph toughness was first introduced by Václav Chvátal (1973)). A graph is $t$-tough if $t(G)\ge t$. Testing whether a graph is q-tough is c...
Algorithm for calculating the toughness of a graph
|graphs|
Let $G$ be a graph. **Toughness** is defined as $$ t(G)=\min _S \frac{|S|}{c(G-S)} $$ where $c$ is the number of connected components and the minimum is taken over all vertex cuts $S$ of $G$ (Graph toughness was first introduced by Václav Chvátal (1973)). A graph is $t$-tough if $t(G)\ge t$. Testing whether a g...
I found an NP-complete problem, [Applying a permutation on a sequence with multiplication,][1] that reduces to my problem. The reduction produces an input to my problem where sequence $a_i$ is the set $L$, $M=\{1,2,3, ..., n\}$, and C=x. This proves that the problem of numerical perfect matching is NP-complete for u...
Though the meaning of "transition to state B after transitioning from state A" is quite unclear, you don't need any special device to memorize if the state A has been reached or not. It suffices to define a set of states from which you can reach A, and another set of states that includes A and such that no transition r...
I found an NP-complete problem, [Applying a permutation on a sequence with multiplication,][1] that reduces to my problem. The reduction produces an input to my problem where sequence $a_i$ is the set $L$, $M=\{1,2,3, ..., n\}$, and C=x. This proves that the problem of numerical perfect matching is NP-complete for u...
Let $G$ be a graph. **Toughness** is defined as $$ t(G)=\min _S \frac{|S|}{c(G-S)} $$ where $c$ is the number of connected components and the minimum is taken over all vertex cuts $S$ of $G$ (Graph toughness was first introduced by Václav Chvátal (1973)). A graph is $l$-tough if $t(G)\ge l$. Testing whether a g...
Detecting whether a machine $M$ is *looping* (meaning that it has reached the same configuration (**not only of its internal state but also of the tape**) twice), is indeed as "easy" as recording the configurations as we simulate $M$ and checking whether the current one was already seen. This method is of course inc...
Imagine there are n children, and they are divided into three separate rooms (Room A, Room B, Room C) without knowing how many children are in each room. As before, their foreheads are marked with either red or blue mud, but now the father also adds a third color, green. Furthermore, some children are wearing glasse...
The Multi-Room Muddy Forehead Puzzle with Varied Color Perception
|algorithms|algorithm-analysis|search-algorithms|
null
{a2nbn+k+1ak ∈ {a, b}∗ | n ≥ 0, k ≥ 0}
For each of the following languages, give a regular expression over {a, b}
I think this paper will help you: https://link.springer.com/article/10.1007/s00453-022-00964-6
This method will not detect n:= 0; while true do n:= n+1 so it is not universal.
Consider this problem: We want to mark some integer numbers such that we mark the minimum number of the numbers and satisfy some constraints. Each constraint wants that at least $k$ numbers in interval $[i,j]$ should be marked such that $i \leq j$ and $k \leq j-i+1$. Is this problem NP-HARD? If yes, please prove it....
Is minimum interval hitting problem NP-HARD?
|algorithms|np-complete|np-hard|constraint-satisfaction|intervals|
I have read that pure Aloha's vulnerable time is 2*transmission time. But shouldn't it also include propagation time? What if a frame is propagating in media and gets collided with another frame (transmission of frame is completed)?
Question on vulnerable time of pure aloha, and why it does include propagation time
|computer-networks|
null
It should be solvable in Polynomial time (in the number of constraints + $\max j$) by MaxFlow algorithms. Consider first [this link explaining how you can determine the minimum amount of flow on a network with edge demands][1]. Then build the following network: Start with a source node $s$, then create a set $J$ of ...
I am trying to find a resource which explains how to compute the constrained Delaunay triangulation of a set of points and edge constraints, I found [these slides][1] by Jonathan Shewchuck, but without the presenter it's hard to follow. Ideally I am looking for a strategy that only involves edge flipping, without th...
Constrained Delaunay triangulation algorithm?
|graphs|computational-geometry|discrete-mathematics|triangulation|
This is what is known as a modular inverse. The easiest way to think about this is to think of the multiplication table in modular arithmetic. Let's start with the modulus being a prime number, 5. $$\begin{array} {}\times{} & 0 & 1 & 2 & 3 & 4 \\ \hline 0 & 0 & 0 & 0 & 0 & 0 \\ 1 & 0 & 1 & 2 & 3 & 4 \\ 2 & 0...
This is what is known as a modular inverse. The easiest way to think about this is to think of the multiplication table in modular arithmetic. Let's start with the modulus being a prime number, 5. $$\begin{array} {}\times{} & 0 & 1 & 2 & 3 & 4 \\ \hline 0 & 0 & 0 & 0 & 0 & 0 \\ 1 & 0 & 1 & 2 & 3 & 4 \\ 2 & 0...
null
null
null
null
It's easy to do this using the technique of finding individual contribution of each element. Consider a subarray, each unique element contributes 1 to answer, but if there are multiple occurences of it, only one will contribute to answer. so rather than finding distinct elements for each subarray, we take an elem...
How to use importance sampling identity to obtain the Chernoff bounds as given below? Let X have moment generating function $\phi(t)= E[e^{tX}]$. Then, for any c > 0 , $P[X\geq c ]\leq e^{-tc} \phi(t), \text{if t > 0}$ $P[X \leq c]\leq e^{-tc}\phi(t), \text{if t<0} $ ***Solution:*** Here's an exampl...
null
null
Computers make heavy use of sequential logic (as opposed to combinatorial). Isn't this an instance of temporal logic ? One might think of implementing fuzzy logic in hardware, which would be reminiscent of analog computers. But I can't see the benefit. Tri-state logic computers have been tried. And abandoned due ...
I need help with this problem, so if anyone is willing to help me, I would be grateful. How can I return the Hamming sequence that has been encoded to the initial sequence? For example, I have the sequence `111101000010`, how to return it to the starting sequence, it is Hamming code `(12,8)`? I'm not asking for s...
Hamming's algorithm returns the coded sequence to the initial sequence
|hamming-code|
<s>The arithmetic expression you provided `12 + 7 * 45 / 9 - 6 + 5` will cause the parser to return syntax error because `12` is not part of the language (same problem for `45`...). Specifically, it is not a token and will be recognized as the symbol `1` followed by `2` that is obviously illegal. To manage numbers in t...
I have a table of fixed positive integer values of anything up to several dozen. There are six columns and several hundred rows. I must choose exactly two values from each column, and zero or one value from each row, for a total of twelve cells selected. Having chosen them, their values are summed for a total score....
How to choose cells from a table to maximize their sum, with selection constraints?
|algorithms|optimization|heuristics|
null
Hi I saw a picture in a group and I asked to myself what exactly is this? Is this a minimal over fitting or like unpresensitive train dataset? However I read it on the net but still have problem in the graph! And then I read the following text on the net and again I asked to myself is it a unpresensitive validation dat...
How to distinguish between Unrepresentative Train Dataset and minimal overfitting from a learning c
|machine-learning|reinforcement-learning|
I need help with this problem, so if anyone is willing to help me, I would be grateful. How can I return the Hamming sequence that has been encoded to the initial sequence? For example, I have the sequence `111101000010`, how to return it to the starting sequence, it is Hamming code `(12,8)`? I'm not asking for s...
I need to create a parity-check matrix, H, for a MET-LDPC code. I know that H will still be two-dimensional and have only 0s and 1's, just like "normal" LDPC codes. I am aware of the modified degree distribution functions (because of the multiple edge types). **How do I translate the two degree distribution func...
Multi Edge Type LDPC codes - How to construct H?
|coding-theory|error-correcting-codes|huffman-coding|
[Manders and Adleman](https://dl.acm.org/doi/10.1145/800113.803627) showed that it is NP-complete to decide given integers $a, b, c \geq 0$ in binary encoding whether $ax^2 + by = c$ has a solution over the non-negative integers. What is known about the complexity of deciding whether $a\binom{x}{2} +by = c$ has a solut...
Complexity of $a\binom{x}{2} +by = c$
|complexity-theory|number-theory|integer-programming|
I was going through the [Wikipedia page on Quines](https://en.wikipedia.org/wiki/Quine_(computing)) and did not understand this paragraph - > A quine is a fixed point of an execution environment, when the execution environment is viewed as a function transforming programs into their outputs. Quines are possible in any...
What are quines (layman friendly)?
|algorithms|turing-machines|compilers|turing-completeness|
null
My laptop started doing this recently It does this sometimes when I wake it from sleep /standby. It just restarts. And sometimes when I turn it on (from having it properly shut down the day before). In both cases the device restarts (since the uptime resets) and a kernel power error gets logged in the event vi...