instruction
stringlengths
0
29.8k
⌀
In parameterized complexity, the class XP contains all problems that can be solved in time $O(n^{f(k)})$ where $k$ is the size of the parameter, and $f$ is some computable function. Note that ${n \choose k} = O(n^k)$, so any algorithm that tries to find a solution of size $k$ in a set of $n$ elements have a similar ...
According to Exponential Time Hypothesis there does not exist a deterministic algorithm to solve SAT over $V$ variables in time $o(2^V)$. However, let's say the number of literals $n = \omega(poly(V))$. The real input size in the worst case is $\Theta(n)$, therefore for an asymptotic analysis one can assume $n$ to be t...
Exponential Time Hypothesis and the input size vs number of variables
|complexity-theory|time-complexity|satisfiability|
While waiting for your updated post that includes your solution, I have posted mine: ### Solution ### A substring is **deletable** if all its characters will be deleted based on your requirement. This substring may have several groups of repeated characters. For example, if the string is "accccbbbdddacccde" then ...
This problem is related to the hitting set problem. You can represent this problem in terms of sets. Let $V$ be the ground set and we define the family $\mathcal{F} = \{V_u = N_G(u)\colon u \in U\}$ Solutions to your problem have a one to one correspondence with hitting sets $\hat V \subseteq V$ whose intersections ...
While waiting for your updated post that includes your solution, I have posted mine: ### Solution ### A substring is **deletable** if all its characters will be deleted based on your requirement. This substring may have several groups of repeated characters. For example, if the string is "accccbbbdddacccde" then ...
If you make the elements stored in the list already contain the next/prev pointers (called an intrinsic linked list) than the list doesn't need to do allocations and risk fragmenting memory further just to store 3-pointer sized structs or an array of pointer that needs reshuffling every time you pull out an element. ...
While waiting for your updated post that includes your solution, I have posted mine: ### Solution ### A substring is **deletable** if all its characters will be deleted based on your requirement. This substring may have several groups of repeated characters. For example, if the string is "accccbbbdddacccde" then ...
Now, **$\color{blue}{\text{Exponentiation}}$** is defined as >Exponentiation is a mathematical operation, written as $b^n$, involving two numbers, the base $b$ and the exponent or power $n$, and pronounced as "$b$ raised to the power of $n$". > $$b^n = \underbrace{b\times b\times\cdot \cdots \times b}_{n\text{ ti...
While waiting for your updated post that includes your solution, I have posted mine: ### Solution ### A substring is **deletable** if all its characters will be deleted based on your requirement. This substring may have several groups of repeated characters. For example, if the string is "accccbbbdddacccde" then ...
Have a write index. Then go through the array, identify and measure each streak of equal characters. Streaks shorter than 3 get written. At the end, write zeros at the remaining indices. Python implementation: ``` from itertools import groupby array = list("aacccbbddde") expect = list("aabbe000000") write ...
I have been struggling for a few hours in terms of finding the right solution for the following problem: Suppose we have a file that contains integers where each represents a user of a service. By reading that file we want to find how many times the service was accessed and by how many different users. My code shou...
Is $m\cdot log^2(n)$ complexity too much?
|algorithms|time-complexity|algorithm-analysis|
ETH says that, for $s_k = \inf \alpha$ such that k-sat can be solved in $2^{\alpha n}$, it holds that $s_3 > 0$. The strong exponential time hypothesis (SETH) says that $\lim\limits_{k \rightarrow \infty}s_k = 1$. I think you mean the latter in your description. Answering your question: The conjecture presents a...
ETH says that, for $s_k = \inf \alpha$ such that k-sat can be solved in $2^{\alpha n}$, it holds that $s_3 > 0$. The strong exponential time hypothesis (SETH) says that $\lim\limits_{k \rightarrow \infty}s_k = 1$. I think you mean the latter in your description. Answering your question: The conjecture presents a...
ETH says that, for $s_k = \inf \alpha$ such that k-sat can be solved in $2^{\alpha n}$, it holds that $s_3 > 0$. The strong exponential time hypothesis (SETH) says that $\lim\limits_{k \rightarrow \infty}s_k = 1$. I think you mean the latter in your description. Answering your question: The conjecture presents a...
null
While waiting for your updated post that includes your solution, I have posted mine: ### Solution ### A substring is **deletable** if all its characters will be deleted based on your requirement. This substring may have several groups of repeated characters. For example, if the string is "accccbbbdddagggde" then ...
While waiting for your updated post that includes your solution, I have posted mine: ### Solution ### A substring is **deletable** if all its characters will be deleted based on your requirement. This substring may have several groups of repeated characters. For example, if the string is "accccbbbdddagggde" then ...
No, the pairs of such $D$ and $M$ are not recursively enumerable. ------ Let $Z=\{0^{n}\mid n\ge0\}$. Call a Turing machine (TM) an $Z$-TM if it accepts words in $Z$. **Claim**. $Z$-TMs are not recursively enumerable. **Proof** (by diagonalization): Towards a contradiction suppose TM $A$ enumerates all $Z$-...
I have two set of points in the plane or space, which could be for instance radar contacts over two successive scans. I'd like to pair them so that the sum of squared distances is minimal. One difficult case, if for instance there is a serie of aligned and equidistant points in the first set, can be found in the sec...
Pair points between to sets minimizing the global distance
|optimization|sets|
|turing-machines|computability|finite-automata|reductions|recursively-enumerable|
While waiting for your updated post that includes your solution, I have posted mine: ### Solution ### A substring is **deletable** if all its characters will be deleted based on your requirement. This substring may have several groups of repeated characters. For example, if the string is "accccbbbdddagggde" then ...
null
null
If you're looking for an algorithm to pair the points in a way that minimizes the sum of squared distances, this is an instance of the [bipartite matching problem](https://en.wikipedia.org/wiki/Matching_(graph_theory)#Algorithms_and_computational_complexity) (or [assignment problem](https://en.wikipedia.org/wiki/Assign...
Short answer - no. Any denominator used to compare computing work spent on two different functions would be subjective to those functions. Therefore it cannot be source of consensus spreading over many functions. It'd like comparing apples to oranges.
Problem ------- [You][1] are given two integer arrays `nums` and `multipliers` of size `n` and `m` respectively, where `n≥m`. The arrays are **1-indexed.** You begin with a score of `0`. You want to perform **exactly** `m` operations. On the `iᵗʰ` operation **(1-indexed)**, you will: - Choose one integer `x` from...
Formal Proof on why Greedy isn't working on one Particular Algorithm
|algorithms|dynamic-programming|proof-techniques|greedy-algorithms|correctness-proof|
<!-- https://consensys.net/knowledge-base/a-blockchain-glossary-for-beginners/ --> If I am a Bitcoin node, I can evaluate two blockchains in terms of each one consisting of more Terahashes than the other and thus deduct which one is the "correct" one. There is impartial source of consensus - hashes done. But wha...
Is there a way to compare computing work spent in two blockchains when every one of them is using different mathematical function as a Proof-of-Work?
|computation-models|blockchain|
A linked list is _appropriate_ for many use cases (independent of performance considerations). For example, a given object (an instance) can be in more than one linked list (internally linked as well as externally linked) but can only be in one array (it can be pointed to by multiple arrays, but that's not the same, f...
A linked list is _appropriate_ for many use cases _independent of performance considerations_. In addition to examples given by other answers here, consider that a given object (an instance) can be in more than one linked list (internally linked as well as externally linked) but can only be in one array (it can be poin...
null
Is there any formal method to prove that one problem belongs to Complexity Class $\mathbb{P}$? >For example, when proving that the problem of finding $n^k$ belongs to Class $\mathbb{P}$, we can use the fact that *each multiplication can be done in unit time!* If you present an algorithm that can solve this pr...
|algorithms|complexity-theory|time-complexity|asymptotics|complexity-classes|
null
Is there any formal method to prove that one problem belongs to Complexity Class $\mathbb{P}$? For example, how can we prove that the problem of finding $n^k$ belongs to Class $\mathbb{P}$? We can use the fact that each multiplication can be done in unit time. If you present an algorithm that can solve this pro...
Repeatedly perform the following simplification procedures: - If a variable appears only once, we can satisfy the unique clause containing it by setting the variable accordingly. Therefore we can remove the clause. - If a variable appears twice but with the same polarity, we can satisfy both clauses containing it b...
Formal Proof on why Greedy isn't working on one Particular Problem
|algorithms|dynamic-programming|greedy-algorithms|correctness-proof|
Consider the following problem: > - Input: A Turing Machine M and a DFA D. > - Question: Is $L(D) \subseteq L(M)$? Of course, this problem is not decidable. Because it is known that judging whether a word belong to a Turing Machine is not decidable. If this problem is decidable, then we can write the word as reg...
Is the problem of "DFA-TM-INCLUSION" recursively enumerable?
null
null
An important consideration missing from the other answers: It's easier and more performant to use immutable linked lists than immutable arrays, which is especially important in functional programming languages. For example, to add an element to an array in an immutable language, you actually create a new array with ...
I have a metric space $(V,d)$ described by a tree $T$. And I have $k$ pair of vertices $\{s_i,t_i\}$ ($i \in [k]$) s.t. each of the vertices $s_i$ and $t_i$ are leaves of $T$. There is a car at one of the leaf $s$ of $T$. The car has to deliver a package from $s_i$ to $t_i$ (for each $i$). But at any time the car can ...
Special case of single vehicle routing
|algorithms|graphs|trees|approximation|heuristics|
Donald Knuth’s [“dancing links”](https://en.wikipedia.org/wiki/Dancing_Links) algorithm is a well-known one that uses the constant-time insertion and deletion of items in a linked list for performance. [You can hear him discuss it, twenty-four years later, here.](https://www.youtube.com/watch?v=_cR9zDlvP88) An impo...
null
I just want to say first that I'm not an expert, but I find this question interesting. I will focus on integer exponentiation. Like the OP says, intuitively, exponentiation of integers should cost $O(n)$, since each multiplication should add a constant number of bits to the result. For example, $8 \cdot 8$ in bina...
I just want to say first that I'm not an expert, but I find this question interesting. I will focus on integer exponentiation. Like the OP says, intuitively, exponentiation of integers should cost $O(n)$, since each multiplication should add a constant number of bits to the result. For example, $8 \cdot 8$ in bina...
I am a bit confused in the following definition: [![enter image description here][1]][1] [1]: https://i.stack.imgur.com/sgOLq.png what does comma mean. I know I(X;Y) is the mutual information between X and Y but I am not sure how to interpret the I(X_1,X_2;Y)).
Chain rule for mutual information
|information-theory|
null
> Is that something we can't accomplish with some other representation? Edge list and adjacency list represent the same thing so if you can do something with one, you can do it with the other. In the worst case, you will have to convert one to the other. ## Storage When it comes to space, storing edge lists take...
> Is that something we can't accomplish with some other representation? Edge list and adjacency list represent the same thing so if you can do something with one, you can do it with the other. In the worst case, you will have to convert one to the other. ## Storage When it comes to space, storing edge lists take...
null
Bentley, J.L. [1977]: Solution to Klee's rectangle problems, unpublished manuscript, Dept. of Computer Science, Carnegie-Mellon University, 1977. Is it classified or not archived at all?
Where to find this unpublished Bentley's research paper?
|computational-geometry|
$I(X_1,X_2;Y)$ is $I(X,Y)$, where $X = (X_1,X_2)$.
TOTAL is the problem of deciding whether a given Turing machine halts on all inputs. This problem is [$\Sigma_2$-complete](https://en.wikipedia.org/wiki/Arithmetical_hierarchy), and in particular, it is neither r.e. nor co-r.e. Your problem is also $\Sigma_2$-complete. The preceding paragraph gives a reduction from ...
$I(X_1,X_2;Y)$ is $I(X;Y)$, where $X = (X_1,X_2)$. For example, suppose that $X_1,Y$ are two independent uniformly random bits, and $X_2 = X_1 \oplus Y$. Then $I(X_1;Y) = 0$ while $I(X_1,X_2;Y) = 1$.
Krystal’s algorithm for constructing minimum spanning trees first sorts an array of edges in increasing order of weight, so that edges with the smallest weight can be considered first for selection.
If $b$ bits of storage are allocated to an integer variable $i$ that represents an index variable in your program, then the number of different values that $i$ can take is $2^b$. For example, if $8$ bits of storage space are allocated to a variable, then the variable can take values $0,1,2,\ldots,255$. Note that $\lflo...
Suppose there are $m$ elements in a sequence containing $n$ distinct elements, and the distinct elements are stored in an AVL tree. Then, each of the $m$ Lookups will take $O(\log n)$ time. Each of the $n$ inserts will take $O(\log n)$ time, for a total cost of $O(m \log n + n \log n) = O(m \log n)$. However, sin...
If you mean fixed arrays (whose lengths are fixed in advance) versus linked lists, then linked lists have the advantage that they use up memory only on an as needed basis - a new cell is allocated each time a new insert operation is done. Whereas, arrays would require you to specify the maximum length of the list in a...
To prove that the greedy algorithm is not optimal, it suffices to give only one counterexample, which you have done. If you want to understand why the greedy algorithm is not optimal, it helps to find the smallest possible counterexamples. Suppose $nums=[5,4]$ and $mult=[1,2]$. Then, the greedy algorithm would c...
To prove that the greedy algorithm is not optimal, it suffices to give one counterexample, i.e. one problem instance $nums$ and $mult$ such that it is possible to obtain a value that is larger than the output computed by the greedy algorithm. You have already shown this. In fact, you showed more than that - you comput...
Intuitive reason why the language of halting machines is Turing reducible but not many-one reducible to its complement
I am following this algorithm example: https://en.wikipedia.org/wiki/Christofides_algorithm#example The graph: [![enter image description here][1]][1] Calculate minimum spanning tree T: [![enter image description here][2]][2] Calculate the set of vertices O with odd degree in T Same as "the min...
I am following this algorithm example: https://en.wikipedia.org/wiki/Christofides_algorithm#example The graph: [![enter image description here][1]][1] Calculate minimum spanning tree T: [![enter image description here][2]][2] Calculate the set of vertices O with odd degree in T. They are the same as ...
Run Christofides algorithm by hand with wrong result
I have been struggling for a few hours in terms of finding the right solution for the following problem: > Suppose we have a file that contains integers where each represents a user of a service. By reading that file we want to find how many times the service was accessed and by how many different users. My code sh...
Is $m \log^2 n$ complexity too much?
If $P = NP$ it's easy to show by induction that the $PH$ collapses to $P$. But would that have any other implications for the relation between $PSPACE$ and $PH$? We already know that $PH \subseteq PSPACE$ and this continues to hold true in the case of the $PH$ collapsing, but would $P = NP$ imply anything else for the ...
What would $P = NP$ tell us about how the polynomial hierarchy relates to $PSPACE$
|complexity-theory|
Let $QBF_k$ be the problem of determining the satisfiability of a formula of the form $Φ = Q_1x_1Q_2x_2 . . . Q_kx_k φ(x_1, . . . , x_n)$. where each $Q_i$ is one of the quantifiers $∀$ or $∃$. So, $Φ$ contains $k$ quantified variables $x_1, . . . , x_k$ and free variables $x_{k+1}, . . . , x_n$. The problem $QBF_k...
Why can't $QBF$ be reduced to $SAT$
|reductions|satisfiability|
The problem is the resulting formula does not have a length that is polynomial in the original formula since you are double the size of the formula every time you remove a quantifier. Even though $QBF_k \le QBF_{k-1}$, you cannot compose the reductions the way you are doing and still get a polynomial reduction, beca...
The problem is the resulting formula does not have a length that is polynomial in the original formula since you are doubling the size of the formula every time you remove a quantifier. Even though $QBF_k \le QBF_{k-1}$, you cannot compose the reductions the way you are doing and still get a polynomial reduction, be...
Given the algorithm ``` MYSTERY-ALG(n >= 0) 1 if n < 3 then 2 return 1 3 else 4 return MYSTERY-ALG(n/2) + MYSTERY-ALG((n/2) + 1) ``` I defined a recurrence $ T(n) = \begin{cases} 1 & 0 \leq n < 3 \\ T(\frac{n}{2}) + T(\frac{n}{2} + 1) & \text{otherwise} \end{cases} ...
Find an upper bound for T(n) = T(n/2) + T(n/2 + 1) using the Substitution Method base case fails
|complexity-theory|asymptotics|runtime-analysis|recurrence-relation|
i'm doing university work about the 2-sat problem and it is asked why 2-sat is p-hard. We discussed that 3-sat is np-hard and proved this by reduction from cnf-sat to 3cnf-sat. for my work the following is asked: "...what you can do is to look at the proof of NP-hardness for CNF-SAT(and ultimately 3-SAT) and see if the...
Proof that 2-sat is P-hard?
|np-hard|3-sat|2-sat|
Prove $T(n)\le n-1$ for $n\ge3$.
Your second idea is good, there is no need to start at $n = 1$: You already proved that for $n\geqslant 3$, $T(n) \leqslant n - 1$. You can now say that since $n-1 \leqslant n$ and since $T(1)\leqslant 1$ and $T(2)\leqslant 2$, then for all $n$, $T(n) \leqslant n$.