instruction stringlengths 0 29.8k ⌀ |
|---|
It is quite easy to prove that f(n) + g(n) ∈ Ω(h(n)), but I am having trouble with proving/disproving that f(n) + g(n) ∈ O(h(n)).
Someone suggested that [this question][1] answers mine, which it doesn't. As I've written above, proving that f(n) + g(n) ∈ Ω(h(n)) is easy. I am having trouble disproving that f(n) + g(n... |
I'm generating biomes for my game and I would like to store them in a single RGB image like the one below. A color hue can then be mapped to an ID through a table lookup. The problem I face is that I would like the transition areas between the biomes to give an exact percentage of each biome's representation in any par... |
How to calculate transition areas of biomes in an image |
|algorithms|mathematical-programming|colorings| |
null |
I learned years ago that $IP \subseteq PSPACE$ since you could simulate all sets of messages and then determine the probability of success. But lately I’ve been looking at [the standard proof of this][1] and I'm having trouble with it.
Basically, I don't understand how we can apply this proof to zero-knowledge setti... |
null |
I'm generating biomes for my game and I would like to store them in a single RGB image like the one below. A color hue can then be mapped to an ID through a table lookup. The problem I face is that I would like the transition areas between the biomes to give an exact percentage of each biome's representation in any par... |
## Case 1: Union of selected intervals might not be a single interval
First of all, sort the intervals in increasing order of $I_i.start$
Use the following Dynamic Programming solution:
$$
\mathrm dp(i, j, k) = max(
\text{extend_union} + dp(i + 1, j’, k - 1), dp(i + 1, j, k) )
$$
where
$$
\mathrm j... |
How does the standard proof that IP is in PSPACE apply to, say, the graph non-isomorphism problem? |
I'm getting to a problem while studying my computability and complexity exam.
If two languages A and B, such that A=B does that implies that coA=coB?
And in general if two language are describe by different TM such that they accept a certain input. One reject everything else, while the other doesn't define anything... |
Let A, B two languages such that A=B does that implies that coA=coB |
|computability|complexity-classes| |
I feel this is a basic question but have been stuck at this for days. Consider an undirected graph with positive weights on its edges. The goal is to find is to get the shortest path between any two nodes in the graph, but considering that if there are more than one shortest path we return the path with the least numbe... |
Finding the shortest path with Bellman-Ford |
|algorithms|graphs|shortest-path| |
I feel this is a basic question but have been stuck at this for days. Consider an undirected graph with positive weights on its edges. The goal is to find is to get the shortest path between any two nodes in the graph, but considering that if there are more than one shortest path we return the path with the least numbe... |
I don't know if a solution to this problem is too complicated to figure out, but I've been banging my head on it for a couple weeks, so I'm hoping for an outside point of view.
I have a list of 88 files today from different sources:
Alpha sent 9 files.
Beta sent 7 files.
Gamma sent 19 files.
Delta sent 1... |
null |
null |
{"OriginalQuestionIds":[24768],"Voters":[{"Id":755,"DisplayName":"D.W.","BindingReason":{"GoldTagBadge":"algorithms"}}]} |
This question is not answerable, as you have not defined the notation coA. Normally, we use the "co-" prefix with complexity classes (sets of languages) rather than languages (sets of strings). See the definition of the [complement](https://en.wikipedia.org/wiki/Complement_(set_theory)) of a set.
Regarding the res... |
If all of your subsets $\mathcal{S}=S_1,\dots,S_m$ have exactly two elements, then this family is effectively a graph $G$ with vertex set $N$ and edge set $\mathcal{S}$ (and $|\mathcal{S}|=m,|N|=n$). Now, you can prove that there exists a partition of $\mathcal{S}$ for which your objective function yields at least the ... |
null |
The operation I'm interested in is a slight twist on your standard search-and-replace operation, in that instead of a single pair of arguments (`replaceme` and `withme`), it takes a keyed set of `N` `[before, after]` pairs as an argument, and for each pair in the set, replaces all instances of `<before>` in the string ... |
Is there an elegant algorithm for applying multiple simultaneous search-and-replace operations to a string? |
|algorithms|strings|c++| |
null |
No, you don’t need to compute the Ackerman function to verify this at all.
The problem is trivial for x <= 3. And for x >= 4, if you can write down y, then the answer is “no”.
More serious, if you actually wrote down say y ≈ A(4), you can solve it easily in linear time in the size of y. If calculating A(4) take... |
null |
Thanks to [Yves Daoust][1] for providing the [answer][2]. We know nothing about the upper bound of f(n) + g(n) so we cannot prove f(n) + g(n) ∈ O(h(n)).
[1]: https://cs.stackexchange.com/users/16034/yves-daoust
[2]: https://cs.stackexchange.com/a/159137/159436 |
"We know nothing about the upper bound" is a good intuition but it is not a formal proof that you can't hope to show $f(n) + g(n) \in O(h(n))$ if your only assumptions are $f(n) \in O(h(n))$ and $g(n) \in \Omega(h(n))$.
Fortunately, a counterexample is easily obtained by considering, e.g., $f(n)=1$, $g(n)=n^2$, and ... |
Your “unique”, the way you wrote it using [], is an array. Lookup time grows linear with the size of the array when the element you are looking for is not there. That’s why the time will grow quadratic with the index of the first duplicated element.
The answer you got made “unique” a hash table by using {}. Lookup ... |
Modern CDCL SAT solvers often can return *partial* assignments where missing literals mean that the value of that variable is not important for the satisfaction of the formula (*i.e.* it is a *don't care*).
What I can't understand is which guarantee do I have that such don't cares are identified.
So, are state-of... |
CDCL SAT solvers and don't cares |
|sat-solvers| |
Let $V_i := \{ u \mid c_u = i \}$ to denote the color classes of a proper coloring $c$. Let $V_{\leq i} := \bigcup_{j \leq i} V_j$ to denote the union of the first $i$ color classes.
The coloring can be generated by a greedy coloring if and only if $V_{\leq i}$ is *maximal* for all $i$, meaning that there is no new ... |
State-of-the-art CDCL SAT solvers typically use sophisticated algorithms and techniques to identify and return partial assignments with don't cares. These solvers are designed to maximize their efficiency in identifying the don't care assignments to minimize the amount of time it takes to solve a problem. Depending on ... |
null |
If all arguments of $T$ are even, i.e. when $n$ is a power of $2$, the solution of the recurrence is $T(n)=\log_2(n)$. (Because $\log_2(2^k)=k=\log_2(2^{k-1})+1$.)
On the opposite, when all arguments of $T$ are odd, the solution is $T(n)=n$ (Because $2^k-1=2\dfrac{2^k-1}2$.)
|
If all arguments of $T$ are even, i.e. when $n$ is a power of $2$, the solution of the recurrence is $T(n)=\log_2(n)$. (Because $\log_2(2^k)=k=\log_2(2^{k-1})+1$.)
On the opposite, when all arguments of $T$ are odd, the solution is $T(n)=n+1$ (Because $2^k+1=2\left(\dfrac{2^k-1}2+1\right)$.)
|
null |
If all arguments of $T$ are even, i.e. when $n$ is a power of $2$, the solution of the recurrence is $T(n)=\log_2(n)$. (Because $\log_2(2^k)=k=\log_2(2^{k-1})+1$.)
On the opposite, when all arguments of $T$ are odd, the solution is $T(n)=\dfrac{n+1}2$ (Because $\dfrac{n+1}2=2\dfrac{\dfrac{n-1}2+1}2$.)
---------... |
If all arguments of $T$ are even, i.e. when $n$ is a power of $2$, the solution of the recurrence is $T(n)=\log_2(n)+1$. (Because $\log_2(2^k)+1=\log_2(2^{k-1})+1+1$.)
On the opposite, when all arguments of $T$ are odd, the solution is $T(n)=\dfrac{n+1}2$ (Because $\dfrac{n+1}2=2\dfrac{\dfrac{n-1}2+1}2$.)
-----... |
If all arguments of $T$ are even, i.e. when $n$ is a power of $2$, the solution of the recurrence is $T(n)=\log_2(n)+1$. (Because $\log_2(2^k)+1=\log_2(2^{k-1})+1+1$.)
On the opposite, when all arguments of $T$ are odd, the solution is $T(n)=\dfrac{n+1}2$ (Because $\dfrac{n+1}2=2\dfrac{\dfrac{n-1}2+1}2$.)
-----... |
We know that there does not exist an FPTAS for the bin packing problem because it is a strongly NP-HARD problem, as the 3-partitioning problem which is strongly np-hard, can be reduced to the bin packing problem. Moreover, by corollary 8.6 of Vazirani's approximation algorithms book, there is no FPTAS for strongly NP-h... |
Does there exist an FPTAS for bin packing problem? |
|optimization|np-complete|np-hard|approximation|polynomial-time-reductions| |
I don't know if a solution to this problem is too complicated to figure out, but I've been banging my head on it for a couple weeks, so I'm hoping for an outside point of view.
I have a list of 88 files today from different sources:
Alpha sent 9 files.
Beta sent 7 files.
Gamma sent 19 files.
Delta sent 1... |
null |
Your example shows two "parameters", but only one is the variable of interest ($n$, usually denoting the problem *size*).
Unfortunately, your example is not really suitable for an explanation, as only
$$a^n=\Theta(a^n)$$ can be shown to hold, and this is trivial. [$a^n=\Theta(\log n)$ is just wrong.]
For a les... |
null |
Store original: replacement in a map. Make an empty output string. Run through the string and word by word find new word using map and concatenate with output. return output. |
The title's a little provocative, sorry. In the [categorical abstract machines (CAMs)](https://en.wikipedia.org/wiki/Categorical_abstract_machine), technically there are no "right folds"; the only way to consume a list is from the "left" or "top" of the list. Less abstractly, a list like `[1;2;3]` (OCaml) or `(list 1 2... |
Can a CAM-style abstract machine fold a tree? What if it has a second stack? |
|computation-models|ocaml| |
You can build an [Aho-Corasick automata](https://en.wikipedia.org/wiki/Aho%E2%80%93Corasick_algorithm) for the before words you can run your string through it, and whenever you find a match go back in the string and replace it with the after value, and then reset the automata. This takes linear time (in the length of b... |
null |
You can build an [Aho-Corasick automata](https://en.wikipedia.org/wiki/Aho%E2%80%93Corasick_algorithm) for the before words, run your string through it, and whenever you find a match go back in the string and replace it with the after value, and then reset the automata. This takes linear time (in the length of both the... |
# Merge function proof of correctness
Let $A'[p \ldots r]$ be a copy of the array $A[p\ldots r]$ right after entering the Merge function.
### Precondition
$0 \leq p \leq q \lt r$
$\forall p\leq x\leq r: A'[x] \neq \infty$
$A'[p\ldots q]$ and $A'[q+1\ldots r]$ are sorted in ascending order.
### Postc... |
null |
Well yeah, the Trie algorithm is a well-known technique for effectively performing this task. This technique can efficiently conduct numerous search-and-replace operations in a single pass over the input text, avoiding the problems that occur when the operations are performed in succession.
The temporal complexity o... |
null |
null |
null |
null |
# Merge function proof of correctness
Let $A'[p \ldots r]$ be a copy of the array $A[p\ldots r]$ right after entering the Merge function.
### Precondition
$0 \leq p \leq q \lt r$
$\forall p\leq x\leq r: A'[x] \neq \infty$
$A'[p\ldots q]$ and $A'[q+1\ldots r]$ are sorted in ascending order.
### Postc... |
I'm interested in the theory of calculating the position of an element when the face of a cube is moved - like in a Rubik's Cup. That is, for example, I rotate the face of the cube - how can I mathematically write down:
- all the displacements of its neighbors relative to each other
- the entire cube as a whol... |
What can I read about permutations in 3D space? |
|permutations| |
null |
Firstly, I've tried assuming $L$ is regular and find a contradiction with help of the pumping lemma's 3 conditions, I was not able to get to a contradiction.
I've tried thinking of a word $z\in \{0,1\}^*$ to attach to $wv^i$ and $wv^j$ for some $i\neq j$, and to combine that with the pumping lemma's $xy^2z\in L, k\... |
Proving $\{wvw|w,v\in \{0,1\}^*\}$ is not regular using the myhill-nerode and pumping lemma |
|pumping-lemma| |
This language is regular. Denote $L = \{wvw\mid v,w\in\{0,1\}^*\}$.
I claim $L = \{0,1\}^*$. Indeed, the inclusion $\subseteq$ is clear. Conversely, let $u\in \{0,1\}^*$. Then $u = \varepsilon u\varepsilon \in L$. |
After some research, this problem seems more related to KNAPSACK rather than SUBSET-SUM. From Garey & Johnson (1979)[p.247], **KNAPSACK is defined as:**
Instance: Finite set $U$, for each $u \in U$, a size $s(u) \in \mathbb{Z^+}$ and a value $v(u) \in \mathbb{Z^+}$, and positive integers $B$ and $K$.
Question: Is... |
Firstly, I've tried assuming $L$ is regular and find a contradiction with help of the pumping lemma's 3 conditions, I was not able to get to a contradiction.
I've tried thinking of a word $z\in \{0,1\}^*$ to attach to $wv^i$ and $wv^j$ for some $i\neq j$, and to combine that with the pumping lemma's $xy^2z\in L, k\... |
I'm generating biomes for my game and I would like to store them in a single RGB image like the one below. A color hue can then be mapped to an ID through a table lookup. The problem I face is that I would like the transition areas between the biomes to give an exact percentage of each biome's representation at any par... |
After some research, this problem seems more related to KNAPSACK rather than SUBSET-SUM. From Garey & Johnson (1979)[p.247], **KNAPSACK is defined as:**
Instance: Finite set $U$, for each $u \in U$, a size $s(u) \in \mathbb{Z^+}$ and a value $v(u) \in \mathbb{Z^+}$, and positive integers $B$ and $K$.
Question: Is... |
Wikipedia states that the time complexity of the [General Number Field Sieve (GNFS)][1] is
$$\exp\left( \left(\sqrt[3]{\frac{64}{9}} + o(1)\right)(\log N)^{\frac{1}{3}}(\log \log N)^{\frac{2}{3}}\right),$$
where $N$ is the number to be factored.
The same site also mentions that [quasi-polynomial time][2] is
$$\mb... |
Firstly, I've tried assuming $L$ is regular and find a contradiction with help of the pumping lemma's 3 conditions, I was not able to get to a contradiction.
I've tried thinking of a word $z\in \{0,1\}^*$ to attach to $wv^i$ and $wv^j$ for some $i\neq j$, and to combine that with the pumping lemma's $xy^2z\in L, k\... |
After some research, this problem seems more related to KNAPSACK rather than SUBSET-SUM. From Garey & Johnson (1979)[p.247], **KNAPSACK is defined as:**
Instance: Finite set $U$, for each $u \in U$, a size $s(u) \in \mathbb{Z^+}$ and a value $v(u) \in \mathbb{Z^+}$, and positive integers $B$ and $K$.
Question: Is... |
Of course it is regular, because it contains the complete set {0,1}*. |
Proving $\{wvw|v\in \{0,1\}^*, w\in \{0,1\}^+\}$ is not regular using the myhill-nerode and pumping lemma |
Firstly, I've tried assuming $L$ is regular and find a contradiction with help of the pumping lemma's 3 conditions, I was not able to get to a contradiction.
I've tried thinking of a word $z\in \{0,1\}^*$ to attach to $wv^i$ and $wv^j$ for some $i\neq j$, and to combine that with the pumping lemma's $xy^2z\in L, k\... |
Proving $L=\{wvw|v\in \{0,1\}^*, w\in \{0,1\}^+\}$ is not regular using the myhill-nerode and pumping lemma |
In principle: Starting with position I=0, check if one of your original strings is stored at position I. If not, increase i by 1. If yes, replace the string and set I = I + length of replacement. Note that an empty string as original string cannot be allowed.
To optimise: Make a table with the starting characters,... |
I was experimenting with the concept of threading in java, we have a method setPriority, using which we can set thread priority. In official documentation it is given as below,
[![enter image description here][1]][1]
[1]: https://i.stack.imgur.com/bvD9K.png
But while seeing in actual execution, I observed so... |
Threads and its priority in Java |
|threads|java| |
null |
Let $L$ be a language over $\Sigma=$ {$a,b,c$}
We define $\forall w\in \Sigma ^{*}$ the function $T$ s.t. $T(w)$ is the word we recieve after removing all instances of $a$ in $w$.
Let $T(L)=${$ T(w) : w\in L$}, we need to show that if $L$ is regular, than so is $T(L)$.
I've came to mind of an approach, which c... |
Prove a language created by applying a function on a regular language is regular |
|regular-languages|finite-automata| |
Let $L$ be a language over $\Sigma=$ {$a,b,c$}
We define $\forall w\in \Sigma ^{*}$ the function $T$ s.t. $T(w)$ is the word we recieve after removing all instances of $a$ in $w$.
Let $T(L)=${$ T(w) : w\in L$}, we need to show that if $L$ is regular, than so is $T(L)$.
I've came to mind of an approach, which c... |
If $L$ is regular then it has a NFA $M_L$. I think you can answer your problem if you can answer the following:
* If for all $w \in L$, $w$ has no $a$, then what would can you say about the elements of $T(L)$?
* If for some $w \in L$, $w$ has an $a$ then there must be some transition in $M_L$ that consumes an $a$. No... |
No, you are not overdoing this. Formally all these steps need to be established. In practise the equivalence step might be skipped, when the constructed automaton "obviously" is doing what it is claimed to do.
On the other hand a formal proof is not that hard. The new automaton might be one where the letter $a$ is ... |
On Wikipedia the error rate for the minhash algorithm vs baseline jaccard similarity [is stated as `1/sqrt(1/hashes)`](https://en.wikipedia.org/wiki/MinHash#Algorithm).
But, how should one interpret this number in a practical scenario? It seems to me that this must mean `avg(abs(minhash_similarity - jaccard_similari... |
How should one interpret the minhash error rate? |
|algorithms|natural-language-processing|classification| |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.