instruction stringlengths 0 29.8k ⌀ |
|---|
Milliseconds for a million elements means nanoseconds per elements. One nanosecond may be half a dozen instructions. That’s difficult. Let’s set a goal of few (less than ten) milliseconds.
For a generic algorithm that handles all kind of data this is tough. But let’s say your million numbers were picked at random f... |
These are all antipodal pairs. You can find them efficiently by following the polygon edges in clockwise order, every time finding the opposite-most vertex by revolving clockwise.
The opposite corner advances as many times as there are vertices (because it follows the polygon), at the expense of one extra test per ... |
Notice that *for a fixed side*, the distances to the vertices are a multiple of the area formed by the side and the vertices.
In the figure, you see all antipodal pairs. You can obtain them efficiently by following the polygon edges in clockwise order, every time finding the opposite-most vertex by revolving clockwi... |
muyustan
there are some mathematic concepts i think may useful for you.
first, the picture you show above is a directed graph. the difference between bidirected graph and directed graph is that each node in bidirected graph have two side:
VdX{left,right}, and each edge on bidirected graph is pair of two side, and ... |
muyustan;
there are some mathematic concepts i think may useful for you.
first, the picture you show above is a directed graph. the difference between bidirected graph and directed graph is that each node in bidirected graph have two side:
VdX{left,right}, and each edge on bidirected graph is pair of two side, and e... |
there are some mathematic concepts i think may useful for you.
first, the picture you show above is a directed graph. the difference between bidirected graph and directed graph is that each node in bidirected graph have two side:
VdX{left,right}, and each edge on bidirected graph is pair of two side, and every endpoi... |
null |
null |
In binary, the EEPROM addresses are
00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000001
00000000 00000000 00000000 00000010
...
00000000 00001111 11111111 11111110
00000000 00001111 11111111 11111111
What is common to all ? |
Arrows are there to indicate which is the traversal direction. [Directed]
No arrows implicitly mean that both directions can be taken. [Bidirectional or undirected]
IMO, a graph where every arrow has the reverse counterpart could be considered both as a directed or undirected graph (depending on context). |
i have seen this [question](https://cs.stackexchange.com/questions/68423/context-freeness-of-anbmck-mid-n-leq-m-leq-k-and-its-complement) where someone was asking if $\{a,b,c\}^* \setminus \{a^nb^mc^k \mid n \leq m \leq k\}$ is context free.
Then there was an [answer](https://cs.stackexchange.com/a/68429/136833) tha... |
Is \{a,b,c\}^* \setminus \{a^nb^mc^k \mid n \leq m \leq k\} context free? |
|formal-languages|context-free|pumping-lemma| |
Is $\{a,b,c\}^* \setminus \{a^nb^mc^k \mid n \leq m \leq k\}$ context free? |
First of all, context-free languages are not closed under complement.
Moreover, $L' = \{a^n b^m c^k \mid n > m > k\}$ is not the complement of $L=\{a^n b^m c^k \mid n \le m \le k\}$. As (one of the many possible choices for a) witness, notice the empty word $\varepsilon$ does belongs to neither $L$ nor $L'$. |
{"Voters":[{"Id":6759,"DisplayName":"Steven"}]} |
You ask:
~~~
Isn't that also the complement of the language?
~~~
Here *that* refers to $L' = \{a^n b^m c^k \mid n > m > k\}$ but I'm not sure what *the language* refers to. It could be $L=\{a^n b^m c^k \mid n \le m \le k\}$ or $L'' = \{a,b,c\}^* \setminus L$.
In any case:
- $L'$ is not the complement of $L$. ... |
{"Voters":[{"Id":6759,"DisplayName":"Steven"}]} |
You ask:
~~~
Isn't that also the complement of the language?
~~~
Here *that* refers to $L' = \{a^n b^m c^k \mid n > m > k\}$ but I'm not sure what *the language* refers to. It could be $L=\{a^n b^m c^k \mid n \le m \le k\}$ or $L'' = \{a,b,c\}^* \setminus L$.
In any case:
- $L'$ is not the complement of $L$. ... |
null |
{"Voters":[{"Id":755,"DisplayName":"D.W."}]} |
No. $\{a^nb^mc^k\mid n>m>k\}$ is not the complement of $\{a^nb^mc^k\mid n\le m\le k\}$, for two reasons.
(1) The negation of the logical statement "$P\land Q$" is not "$\lnot P\land \lnot Q$", it is "$\lnot P\lor \lnot Q$".
(2) The original language consists of only strings in the language $a^*b^*c^*$, so the com... |
A turing machine is defined as a 7-tuple $M = \langle Q, \Gamma, b, \Sigma, \delta, q_0, F \rangle$. The set $F$ in the tuple is the set of _final states_ or accepting states. So any other states other than the ones in $F$ are the rejecting states. You can consider the language that $M$ covers as $L$. So $L'$ will be t... |
Usually, the first symbol means what you expect to read from the input (1), the second what is the symbol at the top of the stack (2) and the third what will happen with the stack (3).
1. $\lambda$ or $\varepsilon$ means the empty string, so this transition can be used without consuming any symbol from the input, i... |
null |
This is the same idea that is in the Varshamov-Tenengolts code with some modifications as explained in the answer above by @Steve.
Since $p=11$ is prime, the set of integers modulo 11, denoted $GF(11),$ is a field (nonzero elements are invertible, you have distributive law, etc). If we have a parity check of the fo... |
null |
Here is a succinct but somewhat abstract description of the technique based on [1]. Also reading [2] to understand the universal automaton before approaching this description is recommended.
---
Let $L \subseteq \Sigma^*$. If $L$ is regular, one can find finitely many words $U = \{ u_1, u_2, \cdots u_n \}$ such t... |
Prove or disprove: deterministic Turing machine equivalence Nondeterministic Turing machine such that word accepts if and only if there are exactly 2 accepted paths and all the others reject or no stop.
I know that need at least 1 accepted path to accepting a word in a nondeterministic turning machine. At firs... |
Prove or disprove: deterministic Turing machine equivalence Nondeterministic Turing machine such that word |
|formal-languages|turing-machines| |
Here is a succinct but somewhat abstract description of the technique based on [1]. Also reading [2] to understand the universal automaton before approaching this description is recommended.
I am also assuming that you are familiar with quotients and some basic properties of them (e.g, Myhill-Nerode Theorem). These... |
Take a look at _Micheal Sipser_ __Introduction to the Theory of Computation__ 3rd edition pages 178 and 179.
In short, the proof uses a three-tape turning machine $D$ (which is equivalent to an ordinary turning machine) to _simulate_ a nondeterministic TM $N$ with a deterministic one. Then, $D$ will try all the po... |
Neural networks are good at image analysis. They are also being used in video games which could outperform professional human players. I wonder if they can also play a purely object-finding game where a player needs to find objects in a photo as shown in the picture.[![enter image description here][1]][1]
[1]: h... |
Are there already Neural Network AIs that can play object-finding games? |
|artificial-intelligence|neural-networks|computer-games| |
Prove or disprove: deterministic Turing machine equivalence Nondeterministic Turing machine such that word accepts if and only if there are **exactly 2 accepted paths and all the others reject or no stop.**
I know that need at least 1 accepted path to accepting a word in a nondeterministic turning machine. At ... |
Take a look at _Micheal Sipser_ __Introduction to the Theory of Computation__ 3rd edition pages 178 and 179.
In short, the proof uses a three-tape turning machine $D$ (which is equivalent to an ordinary turning machine) to _simulate_ a nondeterministic TM $N$ with a deterministic one. Then, $D$ will try all the po... |
I was reading this question over on the [quantum computation stackexchange](https://quantumcomputing.stackexchange.com/questions/5815/why-cant-a-quantum-computer-strongly-simulate-itself), and the top answer stated that you can't (strongly) simulate even a probabilistic turing machine, on itself. I was just curious if ... |
I was reading this question over on the [quantum computation stackexchange](https://quantumcomputing.stackexchange.com/questions/5815/why-cant-a-quantum-computer-strongly-simulate-itself), and the top answer stated that you can't (strongly) simulate even a probabilistic turing machine, on itself. I was just curious if ... |
To accept a string, you must start in $q_0$ and end in $q_0$ or in $q_3$.
A path from $q_0$ to $q_0$ can make a cycle through $q_5$ (so you can have $(ba)^*$) or through $q_1,q_2,q_3,q_4$ (and so $a(ba)^*a(ba)^*a$), and then you can put these together to obtain $((ba)^*+a(ba)^*a(ba)^*a)^*$.
A path from $q_0$ to $... |
Describing the Language of a DFA with 7 States |
|automata|finite-automata|regular-expressions| |
null |
There are many different general strategies when designing algorithms for a problem like divide and conquer, greedy, dynamic programming, etc. I understand that it is not always obvious which to use for a problem. However, I am at a complete loss as to how to even begin to make educated guesses. I assume intuition play... |
Are there any guidelines on how to decide algorithm strategy when approaching a problem? |
|algorithms|algorithm-design| |
Here's Python code to do what you want fairly efficiently. It seems similar to [rici's answer](https://cs.stackexchange.com/a/143204/82867), but I didn't read through their answer to write this.
```python
from typing import Set, List
from itertools import combinations
def group_iterator(s: Set, k: int) -> List[... |
My rules of thumb and advice are:
1. When you have a problem and you're not sure which paradigm might be applicable, try them all.
2. Practice, practice, practice. As you get more practice with algorithm design questions, you'll start to get a "sixth sense" (an intuition) for when a particular paradigm might be ... |
As is often the case in ML, the only way to find out is to try it (or find someone else who has already tried it). You might be interested in methods for object detection, which basically do what you are asking for. The dataset they are trained on has a critical impact on their performance; they need to be trained on... |
No. $\{a^nb^mc^k\mid n>m>k\}$ is not the complement of $\{a^nb^mc^k\mid n\le m\le k\}$, for two reasons.
(1) The negation of the logical statement "$P\land Q$" is not "$\lnot P\land \lnot Q$", it is "$\lnot P\lor \lnot Q$".
(2) The original language consists of only strings in the language $a^*b^*c^*$, so the com... |
The design of algorithms essentially rests on the properties of the problem addressed. These range from elementary to highly sophisticated.
Examples:
- Computing the sum of a sequence exploits associativity of addition, so that accumulation to a single variable is possible (this can be seen as an elementary greed... |
null |
Suppose I have an encrypted string of bytes. "T37mQkZosCsrcbqf/rvSWbd67qH3sXMggKdVd8fzMdg="
Suppose I know that somewhere in the original plain text string I know there is a string of numbers in ascii: "1234567"
Is is realistically possible to figure out the encryption key, or the rest of the string with just thi... |
Is it possible to decrypt a string given part of the original string |
|security|encryption| |
I do have a seemingly fundamental question which I somehow struggle to intuitively make sense of.
*Setting:*
Let us consider a randomized algorithm R that has t steps. In each step, it is fed with random input data (s1,...st), where each si is drawn from some exponentially large set (uniformly random). Moreover, a... |
Probability that an Algorithm Deviates from Its Behaviour after Multiple Rewinding |
|runtime-analysis|probabilistic-algorithms| |
Probability that an Algorithm Deviates from Its Behaviour after Multiple Rewindings |
Before having to figure out the encryption key, you would have to figure out the cryptosystem, which could be anything.
Also, be aware that many modern cryptosystems use a different key for encrypting (public key) and decrypting (private key). |
> $ \widehat{\delta(q, a)} = \hat{\delta}^{}(\hat{q}, a)$
The equality above is the definition of $\hat\delta$, given $\delta$. Let us paraphrase item 3.
>3. For each transition rule of $M$ of the form
$$
\delta(q, a)=\delta(q, a),
$$
find the sets to which $q$ and $\delta(q, a)$ belong. If $q \in\hat q$ and... |
Please help me to find the Time Complexity of the recurrence relation $T(n)=4T(\frac{n}{2})+\frac{n^3}{log_2n}$ using iterative method. |
Iterative solution of recurrence relation $T(n)=4T(\frac{n}{2})+\frac{n^3}{log_2n}$ |
|algorithms|time-complexity|algorithm-analysis|runtime-analysis|recurrence-relation| |
I want to support two operations:
1. Insert a (key, value) pair into the data structure in $O(\log n)$ time. The key can be assumed to be a unique integer.
2. Given an integer query value $v$, I want to return the (key, value) pair $P$ such that the value of $P$ is as great as possible amongst all (key, value) pair... |
Data Structure to Support Max Value of Keys Greater than Given Value |
|data-structures| |
I do have a seemingly fundamental question which I somehow struggle to intuitively make sense of.
*Setting:*
Let us consider a randomized algorithm R that has t steps. In each step, it is fed with random input data (s1,...st), where each si is drawn from some exponentially large set (uniformly random). Moreover, a... |
I'm trying to use a VAE ([CNN-VAE][1] to be exact) to reduce the dimension of some images I have in a dataset.
I successfully trained my VAE, but now I'm not sure of the latent variable to return.
Should I use $\mu$, $\sigma^2$, or $z$ (which is sampled from $\mu$ and $\sigma^2$) ?
[ under chosen plainte... |
Assuming that the encryption mechanism is not completely broken, having partial knowledge about the plaintext does not help figure out the rest of the plaintext. A property of an encryption mechanism is [ciphertext indistinguishability](https://en.wikipedia.org/wiki/Ciphertext_indistinguishability) under chosen plainte... |
I have a range-query problem to solve. This problem requires not only range queries and update, but also insert or delete an element of the array. There is a series of operations that must be done in the order that they appear in the input. The operations can be one of the following: update a position of the array with... |
|data-structures|search-trees|range-query|segment-trees| |
Assuming that $n$ is a power of $2$ and that $T(1)=1$.
$$
\begin{align*}
T(n) &= 4 T(n/2) + \frac{n^3}{\log n} \\
&= 4 \left(4 T(n/4) + \frac{(n/2)^3}{ \log (n/2)}\right) + \frac{n^3}{\log n} \\
&= 16 T(n/4) + \frac{n^3}{2 \log(n/2)} + \frac{n^3}{\log n} \\
&=16 \left(4 T(n/8) + \frac{(n/4)^3}{ \log (n/4)}\righ... |
Similar to what you asked, [this Problem on the maximum height of solders](http://www.spoj.com/problems/QMAX3VN/) involves range queries and insertions of elements.
I solved that problem using [treap](https://threadsiiithyderabad.quora.com/Treaps-One-Tree-to-Rule-em-all-Part-1), which can be used to solve your probl... |
Assuming that $n$ is a power of $2$ and that $T(1)=1$.
$$
\begin{align*}
T(n) &= 4 T(n/2) + \frac{n^3}{\log n} \\
&= 4 \left(4 T(n/4) + \frac{(n/2)^3}{ \log (n/2)}\right) + \frac{n^3}{\log n} \\
&= 16 T(n/4) + \frac{n^3}{2 \log(n/2)} + \frac{n^3}{\log n} \\
&=16 \left(4 T(n/8) + \frac{(n/4)^3}{ \log (n/4)}\righ... |
Assuming that $n$ is a power of $2$ and that $T(1)=1$.
$$
\begin{align*}
T(n) &= 4 T(n/2) + \frac{n^3}{\log n} \\
&= 4 \left(4 T(n/4) + \frac{(n/2)^3}{ \log (n/2)}\right) + \frac{n^3}{\log n} \\
&= 16 T(n/4) + \frac{n^3}{2 \log(n/2)} + \frac{n^3}{\log n} \\
&=16 \left(4 T(n/8) + \frac{(n/4)^3}{ \log (n/4)}\righ... |
Given a $n \times m$ rectangular grid of cells each with an integral weight: $w_{i,j}$ and two integer parameters $w \ge 2$ and $h \ge 2$ (for group width and height respectively). Select the subset of cells that maximizes the combined weight of the selected cells and is constrained such that each selected cell is a pa... |
The simplest is to use $\mu$ as the output. You could also use $z$ as the output, but that will make your dimension reduction randomized, which in some settings might be undesirable (and others might be desirable). |
Yes. Store the pairs in a [self-balancing binary search tree](https://en.wikipedia.org/wiki/Self-balancing_binary_search_tree), keyed on "key", with each pair stored in a leaf of the tree, with the pairs in sorted order by their key ("from left to right" as you walk over the leaves).
Augment the tree, as follows: e... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.