instruction
stringlengths
0
29.8k
⌀
|algorithms|reference-request|computational-geometry|
null
null
this code aims to determine whether there exists a contiguous subarray starting from index 0 in the given array A whose elements sum up to the target value S. can we apply Master theorem to find out its complexity public static boolean subsumFun(int[] A, int S, int i, int j) { if (i >= j) ...
Correctness of recursive function using induction
|algorithms|complexity-theory|recursion|master-theorem|
Complexity of recursive function using Master theorem
null
Amortized analysis is a technique for showing how to distribute the total cost of a worst case sequence of operations among all the operations in the sequence to get an average cost. So, even if there are operations that are expensive, as long as there are enough cheap operations the average cost will be cheap. In your...
Assume that the runtime $n$ is measured in the number of elements between `i` and `j`. In your method there are two recursive steps ```java ... int mid = (i + j) / 2; if (subsumFun(A, S, i, mid)) return true; ... ``` and ```java ... return subsumFun(A, S - s1, mid, j); ...
Assume that the runtime $n$ is measured in the number of elements between `i` and `j`. In your method there are two recursive calls ```java ... int mid = (i + j) / 2; if (subsumFun(A, S, i, mid)) return true; ... ``` and ```java ... return subsumFun(A, S - s1, mid, j); ...
I am reading *C++ Concurrency in Action* and it says that always locking mutexes in a certain order prevents deadlocks. However, this is not a computer science book and no proof is given for this claim. I would like to develop some (more) intuition for why this is, with ideally a proof to convince me.
Why does a lock ordering prevent deadlocks?
|deadlocks|
null
null
Notice, that all machines $M$ that don't halt on any input accept the same language, $\emptyset$. Thus if $M$ doesn't halt on any input then also $\langle M \rangle \notin L$. Now define the TM $M'$ for some TM $M$ such that on input $x$ - $M'$ runs $M$ on $x$ - $M'$ rejects if $M$ halts accepting - $M'$ accep...
The [four necessity conditions for deadlock](https://en.m.wikipedia.org/wiki/Deadlock#Individually_necessary_and_jointly_sufficient_conditions_for_deadlock) are: 1. Mutual exclusion 2. Hold and Wait 3. No preemption 4. Circular Wait Let there be two processes/threads - P1 and P2 and two resources - R1 and ...
The [four necessity conditions for deadlock](https://en.m.wikipedia.org/wiki/Deadlock#Individually_necessary_and_jointly_sufficient_conditions_for_deadlock) are: 1. Mutual exclusion 2. Hold and Wait 3. No preemption 4. Circular Wait Let there be two processes/threads - P1 and P2 and two resources - R1 and ...
null
I am studying the greedy algorithm for maximal weighted matching in arbitrary graphs. I have proven that this algorithm has approximation factor $\frac{1}{2}$. Assume now that the weights in the graph are such that if $W = ⟨w_1, w_2, \ldots , w_{|E|}⟩$ is the weights sorted in increasing order, then $w_i \leq cw_{i...
How does additional assumptions increase approximation factor?
|graphs|greedy-algorithms|matching|
Recently, when I self-learnt Discrete Mathematics and Its Applications 8th by Kenneth Rosen, it says in 12.4 Minimization of Circuits which uses the Karnaugh Map or the Quine-McCluskey method: > Minimizing a Boolean function makes it possible to construct a circuit for this function that uses the *fewest gates* and ...
Does the Quine-McCluskey method always generate the circuit with the minimum inputs and minimum gates?
|logic|boolean-algebra|digital-circuits|karnaugh-map|
The source code of this function is [here](https://github.com/numpy/numpy/blob/v1.26.0/numpy/linalg/linalg.py#L492-L562), which is a wrapper for a C++ function [here](https://github.com/numpy/numpy/blob/v1.26.0/numpy/linalg/umath_linalg.cpp#L1811), which is calling some BLAS/LAPACK library functions. Specifically, in o...
|algorithms|matrices|linear-algebra|python|
Recently, when I self-learnt Discrete Mathematics and Its Applications 8th by Kenneth Rosen, it says in 12.4 Minimization of Circuits which uses the Karnaugh Map or the Quine-McCluskey method: > Minimizing a Boolean function makes it possible to construct a circuit for this function that uses the *fewest gates* and ...
Does the Quine-McCluskey method generate the circuit with the minimum inputs and minimum gates?
### Here is where you misunderstand the Two Generals Problem: > I will resend the time of attack after time `t` if I did not get a confirmation. The Two Generals problem does not allow for retries. That isn't specified as being part of how the system works. You even said it yourself: > It does not solve the...
null
Recently, when I self-learnt Discrete Mathematics and Its Applications 8th by Kenneth Rosen, it says in 12.4 Minimization of Circuits which uses the Karnaugh Map or the Quine-McCluskey method: > Minimizing a Boolean function makes it possible to construct a circuit for this function that uses the *fewest gates* and ...
The enemy puts a few dozen highly trained snipers around the generals camp. Anyone leaving looking like a messaged or entering looking like a messenger will be instantly shot. Sorry, your general will be in the dark.
Let - $I$ be a set of items; - $C \subseteq \mathcal{P}(I)$ be a set of subsets of $I$, where $\mathcal{P}(I)$ stands for the power set of $I$; And - $C(i) = \{ c \in C : i \in I \}$ be the set of sets, in $C$, containing item $i \in I$. We state the following definitions. **Definition 1**: We say that $\mat...
Cardinalities in set coverings
|sets|polynomial-time-reductions|backtracking|
Study the gates as functions over the field GF(2), where XOR is addition and AND is multiplication. All of the bits of the CNOT gate are linear functions of the input. The Toffoli gate has an output bit with the non-linear term $xy$. Since all combinations of linear functions are themselves linear, you can con...
null
How you get a deadlock: Thread 1 waits for lock A and grabs it. Thread 2 waits for lock B and grabs it. Then thread 1 waits for lock B which is already locked and thread 2 waits for lock A which is already locked. Now both threads are waiting and will not ever release the lock they are already holding, so both threads ...
null
When performing a polynomial-time reduction of $L \in \text{PSPACE}$, we claim that the language can be decided by a TM $M$ that takes at most $O(n^k)$ space for some constant $k > 0$. Does the reduction require the value of this constant? From what I understand, the reduction takes a description of a TM and then pr...
Reduction mechanism of PSPACE problems to SPACE-TMSAT
|complexity-theory|reductions|
To show $\text{PSPACE-completeness}$ of $\text{SPACE-TMSAT}$, we perform a polynomial-time reduction of $\forall L \in \text{PSPACE}$ to $\text{SPACE-TMSAT}$. The language $L$ can be decided by a TM $M$ that takes at most $O(n^k)$ space for some constant $k > 0$. Does the reduction require the value of this constant $k...
I posted the question on StackOverflow, but since I haven't received any answers, I moved it to CS instead. I have a weighted undirected graph `G=(V,E,W)`, I want to find an independent set `S` of `V`, such that if we sort the vertices of `S` in increasing order of their weights, the cumulative sum of the weights is...
Find an independent set in which the cumulative sum of weights is maximized
|algorithms|graphs|weighted-graphs|independent-sets|
null
null
I posted the question on StackOverflow, but since I haven't received any answers, I moved it to CS instead. I have a weighted undirected graph `G=(V,E,W)`, I want to find an independent set `S` of `V`, such that if we sort the vertices of `S` in increasing order of their weights, the cumulative sum of the weights is...
I am reading some heavy hitter (HT) papers when I run into the following reduction theorem. The theorem attempts to reduce a HT problem with a very small tail frequency $\epsilon$ to multiple HT instances with higher tail frequencies. More precisely, the reduction utilizes a random hash function $h$ that throw...
Chernoff bound on the maximum of multinomial distribution
|streaming-algorithm|chernoff-bounds|
null
null
I am reading some heavy hitter (HH) papers when I run into the following reduction theorem. The theorem attempts to reduce an HH problem with a very small tail frequency $\epsilon$ to multiple HH instances with higher tail frequencies. More precisely, the reduction utilizes a random hash function $h$ that thro...
null
{"Voters":[{"Id":755,"DisplayName":"D.W."}],"SiteSpecificCloseReasonIds":[]}
null
Prove or disprove that the Quine-McCluskey method generates the circuit with the minimum inputs and minimum gates?
null
In the Question [here][1] it is said that > $|xy^2z|<2^{p+1}$ Considering that $|x| = 0$ and $|z| = 0$, y consists of $2^{p}$. It's probably trivial, but how do I see, that $|xy^2z| < 2^{p+1}$? [1]: https://cs.stackexchange.com/questions/18058/proving-l-a2n-n-ge-0-is-not-regular-by-use-of-pumping-lem
How is $xy^{2}z < 2^{p+1}$
|regular-languages|regular-expressions|pumping-lemma|
How is $|xy^{2}z| < 2^{p+1}$
I have this proof trying to show L={0}^* {1}^* is not a regular language, I know that L is regular but I don't know what in this proof is wrong. If y contains a 0 and 1 and is pumped wouldn't that make the any word not be in the proper form like going from 000111 to 0000101111? Let p≥0 . We construct w=0⌈p/2⌉1⌈p/2...
Pumping Lemma Contrapositive, why is this proof wrong?
|automata|pumping-lemma|
How is $|xy^{2}z| < 2^{p+1}$ (Pumping Lemma application)
null
In the question you've linked, we have $|xy| = |x| + |y| \leq p$ (property b) so $|y| \leq p$ since $|x|, |y| \geq 0$. Therefore $$|xy^2z| = |xyz| + |y| = 2^p + |y| \leq 2^p + p < 2^{p + 1}.$$
In the question you've linked, we have $|xy| = |x| + |y| \leq p$ (property b) so $|y| \leq p$ since $|x| \geq 0$. Therefore $$|xy^2z| = |xyz| + |y| = 2^p + |y| \leq 2^p + p < 2^{p + 1}.$$
You're not allowed to assume that $y$ contains both 0s and 1s. Take for example $x = \varepsilon$, $y = 0$ and $z = 0^{\lceil \frac{p}{2} \rceil - 1}1^{\lceil \frac{p}{2} \rceil}$ with $w = xyz$, then for $p \geq 1$ 1. $|y| = 1 > 0$ 2. $|xy| = 1 \leq p$ 3. $xy^nz = 0^{\lceil \frac{p}{2} \rceil + n - 1}1^{\lcei...
I need to find a way to split an AVL tree based on the amount of nodes in the tree, lets assume you get a number $k$ and if the number of nodes in the tree is multiplication of $k$ you need to find the maximum of each tree in the $k$ trees. for example: for $k=3$ 3 / \ 2 9 ...
Sub-Grouping AVL tree based on nodes amount in O(log(n))
|binary-trees|search-trees|avl-trees|
Let $P=u_1,u_2,\ldots$ a solution to the STSP with cost $l$, we associate to it the vector $x_P$ such that $(x_P)_e = \frac{1}{2}\#\{i; \{u_i,u_{i+1}\}=e\}$ (each time the tour takes an edge, we add $\frac{1}{2}$ to $x_P$). It is a solution to $\frac{1}{2}$-Spanning Tree: let $W$ be a cut, the tour has to leave it and ...
I have large cnf with thousands of variables, but with known compact [backdoor set](https://www.cse.unsw.edu.au/~tw/kstwaaai05.pdf). I think this set can be used by CDCL solvers to choose assignment variables to simplify formula much faster, but I failed to find solver with such feature. Kissat and cadical (top per...
When we write $A\leq_p B$, we mean that there exists a polynomial-time reduction from $A$ to $B$, and we don't care whether you have a description of such reduction in hand. If $k$ is a constant, then there exists machine that encodes this constant, and therefore one can use that machine to conclude the existence of a ...
When we write $A\leq_p B$, we mean that there exists a polynomial-time reduction from $A$ to $B$, and we don't care whether you have a description of such reduction in hand. So we're trying to prove the **existence** of a reduction. If $k$ is a constant, then there exists machine that encodes this constant, and therefo...
I need to find a way to split an AVL tree based on the amount of nodes in the tree, lets assume you get a number $k$ and if the number of nodes in the tree is multiplication of $k$ you need to find the maximum of each tree in the $k$ trees. for example: for $k=3$ 3 / \ 2 9 ...
I would like to find a target point in a 3-dimensional space. I do not know the exact location of the target, but I can measure to it from some of the points in the space with a metric that roughly approximates distance to the target (smaller metric values are closer to the target). The metric is noisy and it's safe to...
null
```cpp public static void sort(int[] A, int i, int j) { if (i >= j) return; int m = (i + j) / 2; sort(A, i, m); sort(A, m + 1, j); if (A[m] > A[j]) { // swap A[j] and A[m] int temp = A[j]; A[j] = A[m]; A[m] = temp...
What is the Time Complexity of this Slow Sorting Algorithm?
null
Your problem seems like a Nearest Neighbor Search but with an approximate distance. There are many indexing methods to solve it approximately. - IVF Index: divides space into regions and assigns a centroid point to each region. Then it searches first the centroids and then it focus only on the regions assigned to t...
# New answer After thinking some more and searching around for a bit I believe both of your approaches are already implemented in TCP, as can be seen [here](https://en.wikipedia.org/wiki/Transmission_Control_Protocol#Data_transfer): > [...] Acknowledgements (ACKs) are sent with a sequence number by the receiver of ...
null
Using the Pumping-Lemma for $L = {a^nb^n | n element of \N $.
Can we say $|xy^2z| = a^{p+|y|}b^p$?
|regular-languages|regular-expressions|pumping-lemma|
Using the Pumping-Lemma for $L = a^nb^n | n element of \N $.
Using the Pumping-Lemma for $L = a^nb^n | n element of \mathds{N} $.
Using the Pumping-Lemma for $L = a^nb^n | n \in \mathbb{N} $.
Using the Pumping-Lemma for $ \{L = a^nb^n | n \in \mathbb{N}\} $.
Can we say $|xy^iz| = a^{p+i|y|}b^p$?
I cannot help but wonder: how to compute an inverse of a suffix array, preferably in linear time?
How to compute an inverse suffix array $ISA$ from a suffix array $SA$ efficiently?