instruction stringlengths 0 29.8k ⌀ |
|---|
Alternative representations of this algorithm use variables `victim` rather then `turn` and `level` rather than `flag`.
This algorithm ensures mutual exclusion because it employs the Peterson's principles inductively, that is, there is a competition on some level $j$ and at most one process is stopped from accessing t... |
[Alternative representations ][1] of this algorithm use variables `victim` rather then `turn` and `level` rather than `flag`.
This algorithm ensures mutual exclusion because it employs the Peterson's principles inductively, that is, there is a competition on some level $j$ and at most one process is stopped from acces... |
null |
I'm trying to understand reaching definitions and I'm having hard problem wrapping it around my head with the following definition (taken from the the following [paper][1] page 114):
* $B_i\;\text{be a basic block}$
* $ReachIn(B_i)\;\text{be the set of registers that reach the entrance to}\;B_i$
* $ReachOut(B_i)\;... |
null |
null |
null |
>You are given a rooted tree $T=(V,E)$ with $n$ nodes and the root $r$. Each node $u\in V$ has an integer label $l(u)$. Suppose $S⊆V$ then $S$ is well-formed if for every $u,v\in S$ if $u$ is an ancestor or the parent of $v$ then $l(u)\le l(v)$. Let $wf(T)$ be the maximum size of any well-formed set in $T$. How can we ... |
Dynamic Program to find well formed set in a rooted tree |
|graphs|algorithm-analysis|dynamic-programming|trees| |
Both matrices relate corresponding points in two images. The difference is that in the case of the Fundamental matrix, the points are in pixel coordinates, while in the case of the Essential matrix, the points are in "normalized image coordinates". Normalized image coordinates have the origin at the optical center of t... |
null |
null |
I've been asked to prove that the language $A_{TM} = \{ \langle M,w\rangle \mid M$ is a TM that accepts $w\}$ is mapping reducible to the language $LOOP-ONE = \{\langle M \rangle \mid M$ is a Turing machine that doesn't halt on **exactly one** input$\}$.
I came up with the following idea :
> F = "On input <M,w>... |
Proving $A_{TM}$ is mapping reducible to certain language |
|turing-machines|reductions|mapreduce| |
null |
>You are given a rooted tree $T=(V,E)$ with $n$ nodes and the root $r$. Each node $u\in V$ has an integer label $l(u)$. Suppose $S⊆V$ then $S$ is well-formed if for every $u,v\in S$ if $u$ is an ancestor or the parent of $v$ then $l(u)\le l(v)$. Let $wf(T)$ be the maximum size of any well-formed set in $T$. How can we ... |
>You are given a rooted tree $T=(V,E)$ with $n$ nodes and the root $r$. Each node $u\in V$ has an integer label $l(u)$. Suppose $S⊆V$ then $S$ is well-formed if for every $u,v\in S$ if $u$ is an ancestor or the parent of $v$ then $l(u)\le l(v)$. Let $wf(T)$ be the maximum size of any well-formed set in $T$. How can we ... |
null |
|algorithms|computational-geometry| |
Now, I have assumed the unary number to be 1.
and my doubts are
1. Do you design this machine similar to normal unary multiplication assuming that the constant 2 (11) is always present in the input tape?
Or
2. Is there only one unary number present in the tape?
This confusion may be because of my poor understa... |
Now, I have assumed the unary number to be 1.
and my doubts are
1. Do you design this machine similar to normal unary multiplication assuming that the constant 2 (11) is always present in the input tape?
Or
2. Is there only one unary number present in the tape?
This confusion may be because of my poor understa... |
null |
null |
The Fermi Paradox asks why we have not yet encountered other intelligent life given the high chance of intelligent life emerging.
I recently had the following thought:
Evolution shapes the behaviour of an organism so that the organism behaves in ways that maximise the organism's chance of survival.
When evol... |
Does the Halting Problem Explain the Fermi Paradox? |
|halting-problem| |
The Fermi Paradox asks why we have not yet encountered other intelligent life given the high chance of intelligent life emerging.
I recently had the following thought:
Evolution shapes the behaviour of an organism so that the organism behaves in ways that increase the organism's chance of survival.
When evol... |
null |
Git [uses SHA hashing](https://stackoverflow.com/a/28792805/2547229) as a content address key. This relies on their being a vanishingly small probability that two different pieces of content will ever hash to the same key.
For content `c` with length `l(c)`, `SHA(c)` can be computed in time `O(l(c))` and uses consta... |
Are there associative cryptographic / collision resistant hashes? |
|algorithms|hash| |
I don't find this argument persuasive, but it sounds like a matter of opinion. I'm not sure this is a matter of computer science -- it sounds speculative and a matter of opinion to me.
I have a problem with the way the word "unpredictable" is used. The halting problem tells us that there is no algorithm that can a... |
null |
Git [uses SHA hashing](https://stackoverflow.com/a/28792805/2547229) as a content address key. This relies on their being a vanishingly small probability that two different pieces of content will ever hash to the same key.
For content `c` with length `l(c)`, `SHA(c)` can be computed in time `O(l(c))` and uses consta... |
So this is the Rice's theorem we were provided:
Definition: $TM$-$FUNC(S)$
Input: Turing machine $M$
Question: Is $f_M \in S$
Let $S$ be a set of computable partial functions with $\emptyset \neq S \neq R$, where $R$ is the set of all functions computable by a Turing machine. Then $TM$-$FUNC(S)$ is undeci... |
How do you use Rice's theorem and why does it make sense? (Use provided Rice's theorem) |
|rice-theorem| |
So this is the Rice's theorem we were provided:
Definition: $TM$-$FUNC(S)$
Input: Turing machine $M$
Question: Is $f_M \in S$
Let $S$ be a set of computable partial functions with $\emptyset \neq S \neq R$, where $R$ is the set of all functions computable by a Turing machine. Then $TM$-$FUNC(S)$ is undeci... |
There is a plausible construction of such a hash. At design time, randomly choose two $2\times 2$ matrices with entries in $\mathbb{F}_{2^n}$ that have determinant 1, fix them, and call them $h(0),h(1)$. Then, for any string $x \in \{0,1\}^*$, define
$$h(x_1 \cdots x_k) = h(x_1) \times \cdots \times h(x_k),$$
w... |
There is a plausible construction of such a hash. At design time, randomly choose two $2\times 2$ matrices with entries in $\mathbb{F}_{2^n}$ that have determinant 1, fix them, and call them $h(0),h(1)$. Then, for any string $x \in \{0,1\}^*$, define
$$h(x_1 \cdots x_k) = h(x_1) \times \cdots \times h(x_k),$$
w... |
null |
$\mathsf{RP}$ can be deterministically defined as:
> A language $L\in\mathsf{RP}$ iff there exists a polynomial $p$ and deterministic Turing machine $M$, such that:
> - $M$ runs for polynomial time $p$ on all inputs,
> - $\forall x \in L$, the fraction of strings $y$ of length $p(\vert x\vert)$ which satisfy $M(x,... |
How is $\mathsf{RP\cap UP}$ not an empty class? |
|complexity-theory|turing-machines|complexity-classes| |
$\mathsf{RP}$ can be deterministically defined as:
> A language $L\in\mathsf{RP}$ iff there exists a polynomial $p$ and deterministic Turing machine $M$, such that:
> - $M$ runs for polynomial time $p$ on all inputs,
> - $\forall x \in L$, the fraction of strings $y$ of length $p(\vert x\vert)$ which satisfy $M(x,... |
How is $\mathsf{RP\cap UP}$ not a class containing only unsatisfying languages? |
$\mathsf{RP}$ can be deterministically defined as:
> A language $L\in\mathsf{RP}$ iff there exists a polynomial $p$ and deterministic Turing machine $M$, such that:
> - $M$ runs for polynomial time $p$ on all inputs,
> - $\forall x \in L$, the fraction of strings $y$ of length $p(\vert x\vert)$ which satisfy $M(x,... |
null |
The $\mathsf{RP}$ machine and the $\mathsf{UP}$ machine don't have to be the same.
That is, there might be one machine which shows that $L \in \mathsf{RP}$, and another one which shows that $L \in \mathsf{UP}$.
As an example, every language in $\mathsf{P}$ lies in $\mathsf{RP} \cap \mathsf{UP}$. The easiest way to ... |
[where i got it from](https://youtu.be/c1ph0MgYQ-0). This was weird so I wanted to try it myself because they way he did it seemed wrong. So this is my attempt is it correct?
I did not add the basic parts of the pumping lemma proof but just did the hard part, is it correct?
$L=\{a^ib^j \mid j = i^2\}$, ab, aabbbb... |
CFG PL for L=\{a^ib^j \mid j = i^2\} |
|context-free|pumping-lemma| |
I have come across a c program like this .
int main()
{
int a,i=4;
int z=5;
a=--i+ --i+ --z;
printf("%d %d",a,i);
return 0;
}
What will be the output? I need some explanation. |
Guess the output of a c program |
|programming-languages| |
If we were to discover a deterministic algorithm capable of deciding, in polynomial time, whether a given graph contains a Hamiltonian path, would that imply that the problem SUBSETSUM belongs to P?
In this scenario, the existence of a deterministic polynomial-time algorithm for the Hamiltonian Path problem could le... |
HAMILTONIAN PATH AND SUBSETSUM |
|polynomial-time|polynomial-time-reductions|subset-sum|hamiltonian-path| |
C++ code:
```
int main()
{
short int arr[4][4];
for (int i = 0; i < 8; i++)
{
for (int j = 0; j < 8; j++)
{
arr[i][j] = i+j;
}
}
return 0;
}
```
Is there going to be a difference in hit time if it is loading data from arrays or storing data into array. For example for ```arr[i][j] = i+j; ```a... |
What is the hit rate of the cache when executing this code? |
|memory-management|mips|caching| |
C++ code:
```
int main()
{
short int arr[4][4];
for (int i = 0; i < 8; i++)
{
for (int j = 0; j < 8; j++)
{
arr[i][j] = i+j;
}
}
return 0;
}
```
Is there going to be a difference in hit time if it is loading data from arrays or storing data into array. For example for ```arr[i][j] = i+j; ```a... |
Just to make it tidy.
int main() {
int a, i = 4;
int z = 5;
a = --i + --i + --z;
printf("%d %d", a, i);
return 0;
}
As gnasher729 said, it is undefined (by the standard)
This means it is entirely compiler-dependent.
But, you said to take a guess... |
Your program will most likely crash because you access non-existing array elements.
|
null |
I know that, in general, the Shortest Hamiltonian Path Problem in a general graph is in NP. I am wondering, however, if the restriction to a complete graph emits an algorithm in P. Being in a complete graph does give the knowledge that a Hamiltonian path exists in the first place.
My guess is that if such an algorit... |
Shortest Hamiltonian Path in a Complete Graph |
|shortest-path|weighted-graphs|hamiltonian-path| |
{"Voters":[{"Id":755,"DisplayName":"D.W."}],"SiteSpecificCloseReasonIds":[4]} |
It is NP-hard. It is as hard as the standard Hamiltonian path problem (testing the existence of a Hamiltonian path in an arbitrary graph).
Here is the reduction. Suppose you have an arbitrary graph $G$, with no edge weights/lengths, and we want to know whether it has a Hamiltonian path or not. Treat every edge of... |
---
**Type Definitions:**
- `C = Pair<int, int>`: Card represented as a suit and value pair.
- `CL = List<C>`: Card list.
- `S = MultiSet<CL>`: A collection of card lists.
**Problem Statement:**
You are given two collections `s0`, `s1`, and one card list `h`.
Find a minimum number of "move" operations need... |
Find Minimum Transformation Between Multisets of Lists of Cards |
|algorithms|data-structures|optimization|combinatorics|board-games| |
**Type Definitions:**
- `C = Pair<int, int>`: Card represented as a suit and value pair.
- `CL = List<C>`: Card list.
- `S = MultiSet<CL>`: A collection of card lists.
**Problem Statement:**
You are given two collections `s0`, `s1`, and one card list `h`.
Find a minimum number of "move" operations needed to... |
null |
**Brief:** I have two configurations, `a` and `b`, of the same set of Rummikub tiles (`a` may not be a valid Rummikub config) and want to find the fewest number of pickup->place tile operations to transform `a` into `b`.
**Type Definitions:**
- `C = Pair<int, int>`: Card represented as a suit and value pair.
- `CL... |
I think the variant with sets can be solved using bipartite matching.
Build a complete bipartite graph, with one left vertex per set in s0 and one right vertex per set in s1. The edge between a left vertex and a right vertex corresponding to sets $L,R$ is assigned the weight $-|L \bigtriangleup R|$, where $L \bigtr... |
I think the variant with sets can be solved using bipartite matching.
Build a complete bipartite graph, with one left vertex per set in s0 and one right vertex per set in s1. Also, if there are fewer sets in s0 than in s1, add additional left vertices, corresponding to empty sets, until both sides have the same num... |
Update (or possible correction) to the answer of [D.W.](https://cs.stackexchange.com/a/163262/107966)
Since we are given the move operations and not the swap operations, we can compute $\pi$ in polynomial time. The problem is known as the [permutation edit distance problem](https://davidbader.net/publication/2016-ba... |
Update (or possible correction) to [the answer of D.W.](https://cs.stackexchange.com/a/163262/107966).
Since we are given the move operations and not the swap operations, we can compute $\pi$ in polynomial time. The problem is known as the [permutation edit distance problem](https://davidbader.net/publication/2016-b... |
null |
I think the variant with sets can be solved using bipartite matching.
Build a complete bipartite graph, with one left vertex per set in s0 and one right vertex per set in s1. Also, if there are fewer sets in s0 than in s1, add additional left vertices, corresponding to empty sets, until both sides have the same num... |
I know that, in general, the Shortest Hamiltonian Path Problem in a general weighted graph is in NP. I am wondering, however, if the restriction to a complete weighted graph emits an algorithm in P. Being in a complete graph does give the knowledge that a Hamiltonian path exists in the first place.
My guess is that ... |
At the moment of my answer, the only other answer incompletely and incorrectly describes the base case values.
Supposing the form
\begin{align}
\max~&
\sum_{i=0}^n c_i x_i \\
\text{s.t.}~
& \sum_{i=0}^n a_i x_i \le b,
x_i \in \{0, 1\}, i=
\right\}
\end{equation}
In the dynamic programming approach to ... |
{"Voters":[{"Id":164804,"DisplayName":"brentertainer"}],"DeleteType":1} |
{"Voters":[{"Id":164804,"DisplayName":"brentertainer"}]} |
At the moment of my answer, the only other answer incompletely and incorrectly describes the base case values.
Let's suppose the 0-1 knapsack problem takes the following form:
\begin{align}
\max~
& \sum_{i=0}^n c_i x_i \\
\text{s.t.}~
& \sum_{i=0}^n a_i x_i \le b, \\
& x_i \in \{0, 1\}, \quad i=0,\... |
Let's suppose the 0-1 knapsack problem takes the following form:
\begin{align}
\max~
& \sum_{i=0}^n c_i x_i \\
\text{s.t.}~
& \sum_{i=0}^n a_i x_i \le b, \\
& x_i \in \{0, 1\}, \quad i=0,\ldots,n.
\end{align}
Then the value functions for the dynamic programming approach may be defined as follows:
\... |
null |
{"Voters":[{"Id":164804,"DisplayName":"brentertainer"}],"DeleteType":1} |
{"Voters":[{"Id":164804,"DisplayName":"brentertainer"}]} |
null |
Now, I have assumed the unary number to be 1.
and my doubts are
1. Do you design this machine similar to normal unary multiplication assuming that the constant 2 (11) is always present in the input tape?
Or
2. Is there only one unary number present in the tape?
This confusion may be because of my poor understa... |
null |
_Note: At the time of my writing, the only other answer to this question seems incorrect. I do not agree that $DP_\text{e}(0,j) = -\infty$ for all $j > 0$. Whether the backpack is full ($j = 0$) or has space remaining ($j > 0$) after all items are considered is inconsequential. Provided the total number of items in the... |
Git [uses SHA hashing](https://stackoverflow.com/a/28792805/2547229) as a content address key. This relies on their being a vanishingly small probability that two different pieces of content will ever hash to the same key.
For content `c` with length `l(c)`, `SHA(c)` can be computed in time `O(l(c))` and uses consta... |
I have a question related with the response time of Deadline Monotonic scheduling...let's assume that there are 4 tasks, and the processor only allows to have 3 task priorities, thus there will be 2 of 4 tasks that will have same priorities. Tasks with same priorities will be processed in FIFO order. Do you know the fo... |
Deadline Monotonic formula with same priority |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.