instruction stringlengths 0 29.8k ⌀ |
|---|
null |
Special case: computing a (single-valued) function
==================================================
In the special case where the relation $R$ corresponds to a (single-valued) function, call it $g$, then yes, there is an equivalence. Suppose the function problem is to compute the function $g$. Define the langua... |
null |
null |
null |
As you cannot decide which are the interesting paths until you know the shortest length, a two-pass method is possible: 1) find a shortest path using your favorite algorithm, 2) enumerate all paths from source to destination and report those of that length, for example using DFS. As a micro-optimization, you can leave ... |
null |
I know [this post](https://cs.stackexchange.com/questions/80913/bucket-sort-with-gaussian-distribution). But I still have no idea to adapt the bucket sort algorithm to handle input with a gaussian / normal distribution. Can someone provide me a Pseudocode / Python code for that? So far I tried the following, but sadly ... |
Bucket sort for gaussian / standard distribution |
|sorting|statistics| |
I know [this post](https://cs.stackexchange.com/questions/80913/bucket-sort-with-gaussian-distribution). But I still have no idea to adapt the bucket sort algorithm to handle input with a gaussian / normal distribution. Can someone provide me a Pseudocode / Python code for that? So far I tried the following, but sadly ... |
I want to learn more about parsing techniques, and to do that I'd like to start with the simplest algorithm, understand its limitations, and progress from there.
From what I've seen, the best candidate so far is LL(1). Is this correct? |
What is the simplest parsing algorithm? |
|algorithms|parsers| |
null |
Let $F$ denote the [cumulative distribution function](https://en.wikipedia.org/wiki/Cumulative_distribution_function) for your distribution. Suppose you want $N$ buckets. Then use the following buckets:
$$(F^{-1}(0),F^{-1}(1/N)],(F^{-1}(1/N),F^{-1}(2/N)],\dots,(F^{-1}((N-1)/N),F^{-1}(1)].$$
This ensures that ab... |
Find a Grammar G, so that L(G) = {a^i b^j c^k | k = i*j ;i, j ≥ 1}
Hello, I have difficulties solving this. I had a similar exercise, where the k was i+j, which was easier, because the solution was to just add a c for every a or b.
But I am having real trouble with this one. I am guessing Cfgs wouldnt be enough ... |
Find Grammar for L(G) ={a^i b^j c^k | k = i*j ;i, j ≥ 1} |
|formal-languages|context-free|formal-grammars|chomsky-hierarchy| |
I have a question about an "apparent" contradiction I found in my lesson notes on Application Order Reduction (AOR) and the Church-Rosser Theorem (CRT). I'd like to emphasize that I'm not suggesting there's a real contradiction, and it is most certainly just my lack of understanding of CRT at issue.
Ok here goes. T... |
null |
null |
null |
I have seen a proof by contradiction for the uncomputability of Kolmogorov complexity. The idea the basically the same as in the proof for halting problem (i.e., there are cases that lead to Berry paradox [example][1]). However, I would argue that since there are infinitely possible ways to interpret a given string, th... |
On proving the uncomputability of Kolmogorov complexity by contradiction |
|complexity-theory|kolmogorov-complexity| |
Kolmogorov complexity doesn't say anything about "interpret"ing a string or finding the equivalent shortest string for a given string, so your argument is not relevant. I don't know what it means to say that one can or cannot iterate through any string.
Kolmogorov complexity has a precise mathematical definition, a... |
null |
Given a string of characters (say `a`, `b`, ...) I want to wrap those characters by tags `<a>...</a>`, `<b>...</b>`, and so on, so that for each character the innermost tag wrapping the character should match with it.
For instance, considering a string `aabbaaca`, we may have
* `<a>aa</a><b>bb</b><a>aa</a><c>c</c... |
Optimizing the number of XML-like tags where only the innermost tag is respected |
|algorithms|strings| |
null |
I know [this post](https://cs.stackexchange.com/questions/80913/bucket-sort-with-gaussian-distribution). But I still have no idea to adapt the bucket sort algorithm to handle input with a gaussian / normal distribution. Can someone provide me a Pseudocode / Python code for that? So far I tried the following, but sadly ... |
I have read the series of papers about "the structure of claw-free graphs" (https://doi.org/10.1016/j.jctb.2008.03.002). Here the authors used the trigraph, that is the adjacency relation contains three types:\
1 strong adjacent,\
2 strong non-adjacent, and \
3 semi-adjacent.
If two vertices $u$ and $v$ are stron... |
Why do the authors use the 'trigraph' to characterize some class of graphs? |
|definitions| |
I have read the series of papers about "the structure of claw-free graphs" (https://doi.org/10.1016/j.jctb.2008.03.002). Here the authors used the trigraph, that is the adjacency relation contains three types:\
1 strong adjacent,\
2 strong non-adjacent, and \
3 semi-adjacent.
If two vertices $u$ and $v$ are stron... |
Is there anything known about the hardness of Vertex Cover on the subclass of comparability graphs? In particular, is it known whether the problem is still NP-hard?
Related Results: In "Modular decomposition and transitive orientation, McConnell & Spinrad, 1999" the authors show that the problem lies in P for co-com... |
Vertex Cover on Comparability Graphs |
|graphs|np-complete|vertex-cover| |
I have read the series of papers about "the structure of claw-free graphs" (https://doi.org/10.1016/j.jctb.2008.03.002). Here the authors used the trigraph, that is the adjacency relation contains **three** types:\
1 strong adjacent,\
2 strong non-adjacent, and \
3 semi-adjacent.
If two vertices $u$ and $v$ are s... |
I know [this post](https://cs.stackexchange.com/questions/80913/bucket-sort-with-gaussian-distribution). But I still have no idea to adapt the bucket sort algorithm to handle input with a gaussian / normal distribution. Can someone provide me a Pseudocode / Python code for that? So far I tried the following, but sadly ... |
So I finally understand, what is happening. The input is distributed with a normal distribution. This leads us to a normal probability distribution function PDF for the probability of the elements. We can describe the distribution using the mean µ and derivative $\sigma$:
$$
µ = \frac{\sum_{n \in N} n}{| N |} \qua... |
I have seen a proof by contradiction for the uncomputability of Kolmogorov complexity. The idea the basically the same as in the proof for halting problem (i.e., there are cases that lead to Berry paradox [example][1]). However, I would argue that since there are infinitely possible ways to interpret a given string, th... |
Kolmogorov complexity doesn't say anything about "interpret"ing a string or finding the equivalent shortest string for a given string, so your argument is not relevant. I don't know what it means to say that one can or cannot iterate through any string.
Kolmogorov complexity has a precise mathematical definition, a... |
Let $F$ denote the [cumulative distribution function](https://en.wikipedia.org/wiki/Cumulative_distribution_function) for your distribution. Suppose you want $N$ buckets. Then use the following buckets:
$$(F^{-1}(0),F^{-1}(1/N)],(F^{-1}(1/N),F^{-1}(2/N)],\dots,(F^{-1}((N-1)/N),F^{-1}(1)].$$
This ensures that ab... |
null |
> We are given an array of size $n$ (it is not specified if we have an integer array, a specific range or any other assumptions), which might be unsorted, and some
> constant $k<1$. We need to prove or disprove that it is possible to
> output the $\lfloor n^k \rfloor$ smallest elements of a in $O(n)$ worst case time
... |
Given an array of size n, return a sorted array of floor(n^k) elements for some k<1 |
|asymptotics|sorting|big-o-notation| |
null |
In [PRIMES IS IN P](https://www.cse.iitk.ac.in/users/manindra/algebra/primality_v6.pdf) paper, page 6 under Time Complexity section, authors have mentioned *"In these calculations we use the fact that addition, multiplication, and division operations between two m bits numbers can be performed in time O∼(m)"*.
What... |
Complexity of m bit multiplication & division |
|time-complexity|asymptotics| |
{"OriginalQuestionIds":[63264],"Voters":[{"Id":755,"DisplayName":"D.W."}]} |
for example:
```
foobar + bar -> foobar
foo + bar + rfo -> barfoo
```
I guess it's related to graphs, but don't know how to solve it.
|
How to find a shortest string includes all input strings |
|strings|substrings|string-matching| |
> We are given an array of size $n$ (it is not specified if we have an integer array, a specific range or any other assumptions), which might be unsorted, and a real number as a
> constant $k<1$. We need to prove or disprove that it is possible to
> output the $\lfloor n^k \rfloor$ smallest elements of a in $O(n)$ wo... |
> We are given an array of size $n$ (it is not specified if we have an integer array, a specific range or any other assumptions), which might be unsorted, and a real number as a
> constant $k<1$. We need to prove or disprove that it is possible to
> output the $\lfloor n^k \rfloor$ smallest elements of a in $O(n)$ wo... |
> We are given an array of size $n$ (it is not specified if we have an integer array, a specific range or any other assumptions), which might be unsorted, and a real number as a
> constant $k<1$. We need to prove or disprove that it is possible to
> output the $\lfloor n^k \rfloor$ smallest elements of a in $O(n)$ wo... |
A depth-first search algorithm would work. Here's an example in C#:
Random random = new Random();
void Main()
{
// define a 5x5 grid and start and end squares
int Rows = 5, Cols = 5, StartRow = 2, StartCol = 0, EndRow = 2, EndCol = 4;
// Grid starts with all zeros
... |
null |
> a constant $k<1$
The answer depends on the understanding of the word "constant".
------
Here is the prevailing interpretation and the interpretation that is beyond doubt.
You are ask to answer infinitely many questions. One of them is the following.
> We are given an array of size $n$. Is it possible t... |
> We are given an array of size $n$ (it is not specified if we have an integer array, a specific range or any other assumptions), which might be unsorted, and a real number as a
> constant $k<1$. We need to prove or disprove that it is possible to
> output the $\lfloor n^k \rfloor$ smallest elements of a in $O(n)$ wo... |
Given an array of size $n$, return a sorted array of floor($n^k$) elements for some $k<1$ |
I'm doing a review of sorting algorithms and trying to self-learn how to prove them as well. The foundation of the quicksort proof is intuitive enough if I'm assuming that the recursion holds - but you also need to assume that the partitioning algorithm works as well.
I'm having trouble approaching an inductive pro... |
Trouble understanding inductive proof of Lomuto's partitioning algorithm |
|sorting|correctness-proof|induction| |
> a constant $k<1$
The answer depends on the understanding of the word "constant".
### The meaning of "a constant $k$"
Here is the expected interpretation.
You are asked to answer infinitely many questions. One of them is the following.
> We are given an array of size $n$. Is it possible to output the ... |
> a constant $k<1$
The answer depends on the understanding of the word "constant".
### The meaning of "a constant $k$"
Here is the expected interpretation.
You are asked to answer infinitely many questions. One of them is the following.
> We are given an array of size $n$. Is it possible to output the ... |
{"Voters":[{"Id":755,"DisplayName":"D.W."}]} |
> a constant $k<1$
The answer depends on the understanding of the word "constant".
### The meaning of "a constant $k$"
Here is the expected interpretation.
You are asked to answer infinitely many questions. One of them is the following.
> We are given an array of size $n$. Is it possible to output the ... |
A depth-first search with backtracking algorithm would work. This algorithm tries all 4 directions and is capable of finding all possible paths.
In order to find a random path, you could traverse the 4 directions in a random order at each step, and stop the first time the path fills all the cells AND ends in the tar... |
So I finally understand, what is happening. The input is distributed with a normal distribution. This leads us to a normal probability distribution function PDF for the probability of the elements. We can describe the distribution using the mean µ and derivative $\sigma$:
$$
µ = \frac{\sum_{n \in N} n}{| N |} \qua... |
> We are given an array of size $n$ (it is not specified if we have an integer array, a specific range or any other assumptions), which might be unsorted, and a real number as a
> constant $k<1$. We need to prove or disprove that it is possible to
> output the $\lfloor n^k \rfloor$ smallest elements of a in $O(n)$ wo... |
The proof is wrong and the answer is positive.
Because there is no $k$ such that
$$\lfloor n^k\rfloor=n-1$$ for all $n$. (You may *not* assume that $k$ is a function of $n$.)
On the opposite, with $m=\lfloor n^k\rfloor$, getting the $m$ smallest elements with Heapsort will take time $O(n+m\log n)$ and for for... |
The proof is wrong, and the answer is positive.
Because there is no $k$ such that
$$\lfloor n^k\rfloor=n-1$$ for all $n$. (You may *not* assume that $k$ is a function of $n$; this would amount to saying "sort *any number* of smallest elements".)
On the opposite, with $m=\lfloor n^k\rfloor$, getting the $m$ sm... |
The proof is wrong, and the answer is positive.
Because there is no $k$ such that
$$\lfloor n^k\rfloor=n-1$$ for all $n$. You may *not* assume that $k$ is a function of $n$; this would amount to saying "sort *any number* of smallest elements".
On the opposite, with $m=\lfloor n^k\rfloor$, getting the $m$ smal... |
The proof is wrong, and the answer is positive.
Because there is no $k$ such that
$$\lfloor n^k\rfloor=n-1$$ for all $n$. You may *not* assume that $k$ is a function of $n$; this would amount to saying "sort *any number* of smallest elements".
On the opposite, with $m=\lfloor n^k\rfloor$, getting the $m$ smal... |
The "disproof" is wrong, and the answer is positive.
Because there is no $k$ such that
$$\lfloor n^k\rfloor=n-1$$ for all $n$. You may *not* assume that $k$ is a function of $n$; this would amount to saying "sort *any number* of smallest elements".
On the opposite, with $m=\lfloor n^k\rfloor$, getting the $m$... |
null |
Suppose 3 bits are used to encode a message (A, B and C).
- If you know A is 1, you have one bit of information.
- If you know A&B is 1, you have two bits of information.
- If you know A&B is 0, you have half a bit of information.
The variable A has one bit of information. But the variable X = A&B has 0.811 ... |
Why do simple Logical Gates have an Irrational amount of Bits? |
|complexity-theory|logic|information-theory|boolean-algebra|entropy| |
{"Voters":[{"Id":160757,"DisplayName":"G S"}],"DeleteType":1} |
{"Voters":[{"Id":160757,"DisplayName":"G S"}]} |
Suppose 3 bits are used to encode a message (A, B and C).
- If you know A is 1, you have one bit of information.
- If you know A&B is 1, you have two bits of information.
- If you know A&B is 0, you have 0.415 bits of information.
**When is this number ever useful?**
P.S.: The formula for calculating the ... |
Suppose 3 bits are used to encode a message (A, B and C).
- If you know A is 1, you have one bit of information.
- If you know A&B is 1, you have two bits of information.
- If you know A&B is 0, you have 0.415 bits of information.
**When is this number ever useful?**
P.S.: The formula for calculating the ... |
Suppose 2 bits are used to encode a message, A and B.
- If you know A is 1, you have one bit of information.
- If you know A&B is 1, you have two bits of information.
- If you know A&B is 0, you have 0.415 bits of information.
**When is this number ever useful?**
P.S.: The formula for calculating the info... |
Suppose 2 bits are used to encode a message, A and B.
- If you know A is 1, you have one bit of information.
- If you know A&B is 1, you have two bits of information.
- If you know A&B is 0, you have 0.415 bits of information.
**When is this number ever useful?**
P.S.: The formula for calculating the info... |
Suppose $2$ bits are used to encode a message, A and B.
- If you know $A$ is $1$, you have one bit of information.
- If you know $A\land B$ is $1$, you have two bits of information.
- If you know $A\land B$ is $0$, you have $0.415$ bits of information.
**When is this number ever useful?**
P.S: The formula... |
An amount of information does not need to be an integer, just like the weight of an object does not need to be an integer number of grams.
One might see as a source of confusion to give the same name to the unit of information and to a digit in the binary base. Of course this comes from the fact that a single equipr... |
An amount of information does not need to be an integer, just like the weight of an object does not need to be an integer number of grams.
One might see as a source of confusion to give the same name to the unit of information and to a digit in the binary base. Of course this comes from the fact that a single equipr... |
Use a partitioned Bloom filter for testing set intersection. It has lower FPR than unpartitioned (standard) Bloom filters.
To intersect two partitioned Bloom filters:
1) AND the bit vectors for all the partitions.
2) Compare the range of bits for each partition to all zeroes in turn.
3) If ANY partition is all ... |
The "disproof" is wrong, and the answer is positive.
Because there is no $k$ such that
$$\lfloor n^k\rfloor=n-1$$ for all $n$. You may *not* assume that $k$ is a function of $n$; this would amount to saying "sort *any number* of smallest elements".
On the opposite, with $m=\lfloor n^k\rfloor$, getting the $m$... |
The "disproof" is wrong, and the answer is positive.
Because there is no $k$ such that
$$\lfloor n^k\rfloor=n-1$$ for all $n$. You may *not* assume that $k$ is a function of $n$, this would amount to saying "sort *any number* of smallest elements".
On the opposite, with $m=\lfloor n^k\rfloor$, getting the $m$... |
null |
I'm trying to create a game but I am having some difficulties in coming up with a suitable algorithm for my problem.
I have elements from 1 to n and I am trying to cover all of the elements using the minimum amount of elements as possible.
Each element can cover an amount of elements to the left (x direction) and an... |
How to cover elements with minimum amount of elements |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.