instruction
stringlengths
0
29.8k
⌀
Minimal pairwise comparisons to combine multiple binary trees that are only relatively sorted?
|algorithms|sorting|binary-trees|
If you check more closely, the [Wikipedia link](https://en.wikipedia.org/wiki/Maximum_coverage_problem) points to the paper: [An analysis of approximations for maximizing submodular set functions](https://link.springer.com/article/10.1007/BF01588971). The paper proves that $(1-1/e)$ approximation holds in general fo...
If you check more closely, the [Wikipedia link](https://en.wikipedia.org/wiki/Maximum_coverage_problem) points to the paper: [An analysis of approximations for maximizing submodular set functions](https://link.springer.com/article/10.1007/BF01588971). The paper proves that $(1-1/e)$ approximation holds in general fo...
null
Say you have a segment defined by 2 points $a,b$ and a third point $p$. You want to know the distance from $p$ to the midpoint of the edge. This is very straightforward: $$d = \|\frac{a + b}{2} - p\|$$ I am wondering if it is possible to do this faster. Asymptotically you cannot do better than $O(n)$, where $n...
null
Assume that you are given a vector `0b1101001001011001` etc. And you are going to classify it. One can use Support Vector Machine, but is that method good for classifying data that are spare and binary?
Classifying vectors that only contains 1001110101 numbers - Is Support Vector Machine the solution?
|binary|classification|svm|sparse-matrices|
### Explanation by Analogy I have a gun. 6 bullets. I can only fire one after the other. ### Queuing Delay Bullet number 6 is at the end of the barrel. It has to wait until I fire all the bullets preceding it. The bullets are waiting in the chamber in the meantime. This time period is the queuing delay. ...
I have a problem as follows. Given a set of sets $U = \{S_1, S_2, … S_N\}$ where $S_i = \{s_1, s_2, ... s_m\}$. Each $s_j \in S_i$ contains a set of distinct elements. I need to pick one $s_j \in S_i$ to form $N$ sets in total such that $|\bigcup_{j=1}^N s_j|$ is **minimized**. Is there an efficient algorithm to sol...
Minimizing the number of distinct elements by picking each set from a set of sets
|complexity-theory|optimization|np-hard|
Minimizing the number of distinct elements by picking one set from each set of sets
Your problem is NP-hard by a reduction from the (decision version of the) hitting set problem. Given a set $X = \{x_1, \dots, x_n\}$ of elements, a collection $A_1, A_2, \dots, A_h$ of subsets of $X$, and an integer $k$, is there a subset $X'$ of at most $k$ elements from $X$ such that $A' \cap A_i \neq \emptyset$ for...
Your problem is NP-hard by a reduction from the (decision version of the) hitting set problem. Given a set $X = \{x_1, \dots, x_n\}$ of elements, a collection $A_1, A_2, \dots, A_h$ of subsets of $X$, and an integer $k$, is there a subset $X'$ of at most $k$ elements from $X$ such that $A' \cap A_i \neq \emptyset$ for...
Too long; did not read. The easy solution: Let $w' = w + 10^{12}$. Now, find a solution of cost less than $k \cdot 10^{12}$ --- The more involved solution, but which in fact solves a more general problem: From an input instance $G, s, t$ (assuming here the graph is directed, but it doesn't really matter). ...
The Soundex algorithm, or some variant of it tailored to the particular features of the Romanisation schemes, could be a good place to start. Certainly some algorithm that is informed by phonetics and so on, is likely to perform better than an arbitrary algorithm designed to compare strings generally.
Assume that you are given a vector `0b1101001001011001` etc. And you are going to classify it. One can use Support Vector Machine, but is that method good for classifying data that are spare and binary? Assume that you are given a real vector $x$ with dimension $N$. The vector contains only ones and zeros. $x = [0,...
null
No, we don't ignore the "sign" digit. Like positive numbers having an infinite number of leading zeros, negative numbers in ***r*** and ***r - 1*** format have an infinite number of leading ***(r - 1)***'s. That is why we sign extend when storing a signed number into a larger storage object.
> I see, so main thing is to disregard the overflown bit. No, we don't ignore the "sign" digit. Like positive numbers having an infinite number of leading zeros, negative numbers in ***r*** and ***r - 1*** format have an infinite number of leading ***(r - 1)***'s. That is why we sign extend when storing a signed nu...
Please first take a brief look at [my previous question][1]. Here I want to do something similar but for $T(n)=2T(\dfrac{n}{2})+\Theta(n\log{n})$. I know the answer is $T(n)=\Theta(n\log^2{n})$ and I want to prove it using induction. I reached this assuming for $m<n$, we have $T(m)\leq cm\log^2{m}$: $\begin{align*} ...
Prove $T(n)=2T(\dfrac{n}{2})+\Theta(n\log{n})=\Theta(n\log^2{n})$ using induction
|time-complexity|algorithm-analysis|recurrence-relation|recursion|induction|
Please first take a brief look at [my previous question][1]. Here I want to do something similar but for $T(n)=2T(\dfrac{n}{2})+\Theta(n\log{n})$. I know the answer is $T(n)=\Theta(n\log^2{n})$ and I want to prove it using induction. I reached this assuming for $m<n$, we have $T(m)\leq cm\log^2{m}$: $\begin{align*} ...
null
Given an undirected graph $G=(V,E)$ I would like to check whether it contains a cross/parallel (unrelated) edge pair. These are $2$ edges $\left(v_1, v_2\right)$ and $\left(v_3, v_4\right)$ such that for any $i<j$ (excluding $i=1,j=2$ and $i=3,j=4$) there is no edge $\left( v_i , v_j \right)$. In other words, the only ...
A sketch for finding 2 unrelated crossing edges
|graphs|runtime-analysis|graph-traversal|breadth-first-search|
Given an undirected graph $G=(V,E)$ I would like to check whether it contains a cross/parallel (unrelated) edge pair. These are $2$ edges $\left(v_1, v_2\right)$ and $\left(v_3, v_4\right)$ such that for any $i<j$ (excluding $i=1,j=2$ and $i=3,j=4$) there is no edge $\left( v_i , v_j \right)$. In other words, the only ...
While the question has been mostly answered by other people, I want to make a note that in the algorithm described, you have to keep track of the index you are at to iterate to the next array element. This index tracker, at last position, grows as input grows, so it is not quite O(1) in terms of space, but O(lg(n)) (si...
While the question has been mostly answered by other people, I want to make a note that in the algorithm described, you have to keep track of the index you are at to iterate to the next array element. This index tracker, at last position, grows as input grows, so it is not quite O(1) in terms of space, but O(lg(n)) (si...
In the context of adding sparse polynomials, you have two alternative approaches to combine the terms from two separate polynomials. One option is to use the line of code ```result += self.terms[i:] + other.terms[j:]```, which efficiently concatenates the remaining terms from both polynomials. The other option is to em...
Should I concatenate three lists together or use two separate while loops in Python? Which option offers a better runtime complexity?
|algorithms|data-structures|python|
Given an undirected graph $G=(V,E)$ I would like to check whether it contains a cross/parallel (unrelated) edge pair. These are $2$ edges $\left(v_1, v_2\right)$ and $\left(v_3, v_4\right)$ such that for any $i<j$ (excluding $i=1,j=2$ and $i=3,j=4$) there is no edge $\left( v_i , v_j \right)$. In other words, the only ...
Reminder ; when doing a BFS, you are keeping track of vertices you already visited. If you see a node that you already visited, you do not consider it and you "stop" there. This explains how the algorithm is not $N!$. Now as for the complexity given by the website, considering that BFS is $O(|V| + |E|)$, an "easier" ve...
First, measure. If you can’t measure the difference then it doesn’t matter. Second, you don’t know the time complexity of add_term. You need to find its implementation and analyse its behaviour. Reasonable implementations could lead to a runtime that is quadratic in the number of terms. Different reasonable impleme...
Define S(m) = T(2^n). Write down a recursive formula for S(m) and solve it. Use the result to solve T(n).
As a basic block, you take an eight bit adder producing a nine bit result. You need seven of these. Create eight 8-bit numbers Z0 to Z7. Zk is the AND of X AND bit k of Y, shifted left by k bit position, so the result is the sum of the Zk. Use the first adder to add Z0 and Z1. The lowest bit of Z0 is taken unchange...
With the halting problem, the class of programs whose halting you determine, and the class of programs that we use to solve the problem, are the same. If you examine programs with n states, you can’t in general find whether they are halting _using a program with n states_. We can find a program that determines if p...
The problem can be solved in the polynomial time for $k = 3$. There is this paper by [Chen *et al.*](https://dl.acm.org/doi/abs/10.1007/s10878-018-00372-z). The authors design an approximation algorithm for the *minimum $3$-path partition problem*. The *minimum $3$-path partition problem* is similar to your problem...
### Explanation by Analogy I'm using firearms analogy. Even if your culture has zero firearm education, you probably can still intuit from movies etc.: * I have a gun. * 6 bullets. * I can only fire one after the other. ### Queuing Delay Bullet number 6 is the last in the chamber. It has to wait until ...
null
To properly insert a data entry in my database, I have to reach the last box in this diagram. A box represents either a flag or a data structure that participates in determining a single entry. What is the name of this type of diagram? Alternatively, what do you call the procedure of making such a diagram? (cross...
This diagram serves to determine the components of a data entry in my database. What is the name of this type of diagram?
|database-theory|databases|
To properly insert a data entry in my database, I have to reach the last box in this diagram. A box represents either a flag or a data structure that participates in determining a single entry. What is the name of this type of diagram? Alternatively, what do you call the procedure of making such a diagram? (cross...
null
I have been scouting the internet for resource son how to properly implement Ruppert's algorithm and what I ahve found is always lacking in details. The best resources I have so far are these 2: * https://sites.google.com/site/samsoninfinite/multivariable-calculus/constrained-delaunay-triangulation * https://en...
How to actually implement ruppert's algorithm?
|algorithms|graphs|computational-geometry|discrete-mathematics|triangulation|
I have a concept binary search which doesn't split at the midpoint of a list, but at a ratio of 1:2. If we abstract the search function time complexity into $T(n)$ then the function can recurse into two options: - $T(n/3) + C(n)$ - $T(2n/3) + C(n)$ I am unable to understand how to properly find this time co...
Time complexity of an uneven binary search
|time-complexity|binary-search|
I am given a $N$ x $M$ sized grid and $K$ start points $S = (s_1, s_2, .. s_k)$ where each $s_k = (x_k,y_k)$ representing the position on the grid. I am also given a single endpoint $(x_{end}, y_{end})$. Some cells of the grid contain obstacles which are undesirable to pass through. Given that we have a routine `ge...
Greedy algorithm for minimising the number of encountered obstacles from multiple start points to single endpoint in a grid
|complexity-theory|decision-problem|greedy-algorithms|
We have $T(n) = \max(T(\frac n3), T(\frac {2n}3)) + C(n)$. If $C$ is non-decreasing (which is usually the case), we have $T(n) = T(\frac {2n}3) + C(n)$, so using the master theorem if $C(n) = \Theta(\log^k (n))$ (for $k \geq 0$) the solution is $T(n) = \Theta(\log^{k+1} (n))$. If $C(n) = \Omega(n^c)$ for some $c > 0$ a...
null
I *think* you can compute the index of the n^{th} ancestor of the node at index i using the formula: $\lfloor i / 2^n \rfloor$ where $n \in \mathbf{Z}^+$. Note that I am assuming that the parent node is at index 1 for this. Left child nodes have even indexes, and right child nodes have odd indexes. I know that you c...
Computing the index of the n^{th} ancestor of a node in a perfect binary tree / heap
|binary-trees|heaps|
I *think* you can compute the index of the n^{th} ancestor of the node at index i using the formula: $\lfloor i / 2^n \rfloor$ where $n \in \mathbf{Z}^+$. Note that I am assuming that the parent node is at index 1 for this. Left child nodes have even indexes, and right child nodes have odd indexes. Nodes are number fro...
I *think* you can compute the index of the n^{th} ancestor of the node at index i using the formula: $\lfloor i / 2^n \rfloor$ where $n \in \mathbf{Z}^+$. Note that I am assuming that the parent node is at index 1 for this. Left child nodes have even indexes, and right child nodes have odd indexes. Nodes are number fro...
I *think* you can compute the index of the n^{th} ancestor of the node at index i using the formula: $\lfloor i / 2^n \rfloor$ where $n \in \mathbf{Z}^+$. Note that I am assuming that the parent node is at index 1 for this. Left child nodes have even indexes, and right child nodes have odd indexes. Nodes are number fro...
For any node $i$, its children are $2i$ and $2i+1$. Using induction, you can prove that its $n^{th}$ level descendants are: $2^{n} \cdot i + j$ for $j \in \{0,\dotsc,2^n-1\}$. Equivalently, you can say that any descendant $d$ has its $n^{th}$ ancestor $\lfloor d/2^n \rfloor = i$
I found a paper published two years later. [Hashing modulo alpha-equivalence](https://dl.acm.org/doi/10.1145/3453483.3454088). This provides an asymptotically faster way to achieve the goal, improving from $O(n^2)$ to $O(n \log^2 n)$.
null
null
null
I am going through Justin Thaler's book - https://people.cs.georgetown.edu/jthaler/ProofsArgsAndZK.pdf - "Proofs, Arguments, and Zero-Knowledge" He is describing the Sumcheck Protocol. $H = \sum_{b_1 \in \lbrace 0,1 \rbrace} \space \sum_{b_2 \in \lbrace 0,1 \rbrace} \space ... \space \sum_{b_v \in \lbrace 0,1 \rb...
Sumcheck protocol - how are these 2 polynomials different?
|polynomials|zero-knowledge-proofs|
Let $L$ be a regular language. Is the language $L_2 = \{ ww | w \in L \}$ regular? Does it have a name?
Language of words concatenated with themselves
|formal-languages|regular-languages|
Let $L$ be a regular language. Is the language $L_2 = \{ ww | w \in L \}$ context-free? Does it have a name?
|formal-languages|regular-languages|context-free|
null
Say I have two integers,i and j, which for the sake of example will be 2 and 5, represented by $010_2$ and $101_2$ respectively. I have a third bit set to 0. If $j \geq i$, then this bit should change to 1. I am trying to understand how in principle this is done. My understanding is if you flip the bits in j, and then ...
Binary Comparison Between Two Integers
|arithmetic|binary|
I am a beginner in the computer science track. I have some problems with the following problems **Problem 1:** Assume that $NP \ne coNP$. If $L_1, L_2 \in NP$, is $\bar{L_1} \cap L_2$ necessarily in $coNP$. **My attempt:** I intend to choose $L_1, L_2$ such that $L_1= \emptyset $, $L_2$ is in $NP$ complete. The...
If $NP \ne coNP$, $L_1, L_2 \in NP$, then is it necessary for $\bar{L_1} \cap L_2 \in NP$ and checking the proof of $P \ne NP$
|complexity-theory|time-complexity|
Let $c$ be the constant for the $\Theta$ expression, and show that $T(n) \leq c n \log^2 n$. By induction, assume $n \geq 2$. $\begin{align} T(n) &= 2T(n/2) + cn \log n\\ &\leq 2(c \frac n 2 \log^2 \frac n 2)) + cn \log n \text{ (by I.H.)}\\ &= cn \log \frac n 2 \log \frac n 2 + c n \log n\\ &=...
I've read [this][1] scribe that provides a public coin interactive proof for graph non-isomorphism. In the proof, the verifier samples both a pairwise independent-hash function **and a target $y$**. In all calculations carried out in the scribe, I couldn't find a single instance that used the fact that $y$ is r...
GNI public coin interactive proof: why randomize y?
|complexity-theory|graphs|graph-isomorphism|interactive-proof-systems|
I've read [this][1] scribe that provides a public coin interactive proof for graph non-isomorphism. In the proof, the verifier samples both a pairwise-independent hash function **and a target $y$**. In all calculations carried out in the scribe, I couldn't find a single instance that used the fact that $y$ is r...
I have read a lot of times, that models that can parse Dyck-2 are of great importance. It appears that Dyck-2 is interchangeably used like Dyck-N. Afaik the Chomsky-Schützenberger representation theorem states that you can convert and context-free language into a Dyck-N language, using a homomorphism and a intersect...
Why is Dyck-2 so important for the Chomsky-Schützenberger theorem?
|formal-languages|formal-grammars|chomsky-hierarchy|algebra|
null
Whether 2-bracket Dyck is equivalent to $n$-bracket Dyck ($n\ge2$)? Short answer: that depends which operations one allows. The [Chomsky–Schützenberger Theorem][1] states that every context-free language $L\subseteq \Sigma^*$ can be written as $L=h(D_{T}\cap R)$, where $D_T$ is the Dyck language over the bracket p...
Your question is answered in the book itself, in the sentence you quote and the next few sentences thereafter. The Verifier doesn't get $s_1$. As the book says: > evaluating $s_1(r_1)$ is not an easy task for $\mathcal{V}$ [...] > > rather than evaluating $s_1(r_1)$ on her own, $\mathcal{V}$ instead *recursivel...
Given a fully connected undirected graph, is there a quick way for me to know if the graph will remain fully connected if I delete a given edge from the graph? Quick = O(lg V) or something like that. O(V) is not quick. Fully connected = every node is reachable from every other other node in the graph. i.e., given...