instruction
stringlengths
0
29.8k
⌀
SMT solver gives up on seemingly trivial problem
|smt-solvers|
I have problems to imagine a non-deterministic Turingmachine. Let's make an example: There is the problem of a Vertexcover. Let $G=(V,E)$ be an undirected graph and $k\geq 0$. The question is whether there is a vertexcover $C$ of size $|C|\leq k$. My book says that this problem is in $NP$, because a Turingmachine coul...
Does a non-deterministic Turingmachine reach every possible result?
|turing-machines|nondeterminism|
null
Given two (unordered) partitions of the same string over a finite alphabet into substrings, how hard is it to reconstruct the original string? If multiple solutions exist, any one will suffice. I'm interested in the regime when the original string has length $n$ and the substrings have length $O(\log n)$. What w...
Reconstructing a string from two its partitions
|algorithms|time-complexity|strings|substrings|
There’s a union if double and 64 bit int in a file that’s not shown, which lets you extract the sign, biased exponent, and mantissa without leading zero bit. For numbers from 1 to 2 the square root would be from 1 to 1.414. For numbers from 2 to 4 the square root would be from 1.414 to 2. If you look at the ieee f...
There’s a union if double and 64 bit int in a file that’s not shown, which lets you extract the sign, biased exponent, and mantissa without leading zero bit. For numbers from 1 to 2 the square root would be from 1 to 1.414. For numbers from 2 to 4 the square root would be from 1.414 to 2. If you look at the ieee f...
null
Given two (unordered) partitions of the same string over a finite alphabet into substrings, how hard is it to reconstruct the original string? If multiple solutions exist, any one will suffice. I'm interested in the regime when the original string has length $n$ and the substrings have varying lengths within $O(\lo...
A non-deterministic machine finds the solution "by magic": whenever there is a decision to be taken, it immediately takes the right one so that the search for a solution essentially amounts to the verification of the solution. There is no randomness involved and the machine is run once on the given problem.
null
Given is a multiset $S$, a finite set $T = \{t_1, t_2, t_3\}$, and an integer $k \in \mathbb{N}$. Let $v(t_j)$ be a set of discrete values $\in \mathbb{R^+}$ of length $\|T\|$ that can be assigned to $s_i$, and $c(t_j)$ be the cost of assigning $v(t_j)$ to $s_i$. Since $S$ is a multiset, assigning $v(t_j)$ to $s_i$...
Possible reduction from SUBSET-SUM to assignment problem
|complexity-theory|np-complete|reductions|np-hard|subset-sum|
If you know that a is within an interval of width $2 \cdot 10^{-k}$ then you would pick b in the middle of the interval. There are $10^k / 2$ intervals, 500 if k=3. You split 500 intervals into 250+250, 250 into 135+125, 125 into 63+62 etc. until one interval is left. This minimises the number of guesses, and gives...
Given is a multiset $S$, a finite set $T = \{t_1, t_2, t_3\}$, and an integer $k \in \mathbb{N}$. Let $v(t_j)$ be a set of values $\in \mathbb{R^+}$ of length $\|T\|$ that can be assigned to $s_i$, and $c(t_j)$ be the cost of assigning $v(t_j)$ to $s_i$. Since $S$ is a multiset, assigning $v(t_j)$ to $s_i$ will aff...
null
"There are k cities on a highway with coordinates x1 , . . . , xn and we aim to build K < n gas stations to cover these cities. Each gas station has to be built in one of the cities, and we hope to minimize the average distance from each city to the closest gas station. Please give an algorithm to compute the optima...
Placing K gas stations among n cities to minimize distance
|algorithms|dynamic-programming|big-o-notation|
"There are k cities on a highway with coordinates x1 , . . . , xn and we aim to build K < n gas stations to cover these cities. Each gas station has to be built in one of the cities, and we hope to minimize the average distance from each city to the closest gas station. Please give an algorithm to compute the optima...
"There are k cities on a highway with coordinates x1 , . . . , xn and we aim to build K < n gas stations to cover these cities. Each gas station has to be built in one of the cities, and we hope to minimize the average distance from each city to the closest gas station. Please give an algorithm to compute the optima...
"There are k cities on a highway with coordinates x1 , . . . , xn and we aim to build K < n gas stations to cover these cities. Each gas station has to be built in one of the cities, and we hope to minimize the average distance from each city to the closest gas station. Please give an algorithm to compute the optima...
"There are k cities on a highway with coordinates x1 , . . . , xn and we aim to build K < n gas stations to cover these cities. Each gas station has to be built in one of the cities, and we hope to minimize the average distance from each city to the closest gas station. Please give an algorithm to compute the optima...
"There are k cities on a highway with coordinates x1 , . . . , xn and we aim to build K < n gas stations to cover these cities. Each gas station has to be built in one of the cities, and we hope to minimize the average distance from each city to the closest gas station. Please give an algorithm to compute the optima...
Possible reduction from SUBSET-SUM
According to the wikipedia page on [Kleene Algebra][1], we can use two properties: - $(a^*)^*= a^*$ - $(a+b)^* = a^*(b(a^*))^*$ If you allow those it is quite straightforward: $(1^∗+01^∗0)^∗ = (1^∗)^*\cdot (01^∗0(1^*)^* )^∗ = 1^∗(01^∗01^* )^∗$. There is probably not a single set of rules for equivalence of...
null
Yes, it's possible, but there is no magic formula. Each polynomial requires a unique set of operations, and the number of operations required can vary highly. A solid grasp of CRC math is also necessary to craft these solutions. Unfortunately I only have a cursory understanding, so my explanation may be limited. T...
I found a highly optimized [CRC-16](https://en.wikipedia.org/wiki/Cyclic_redundancy_check) implementation originally intended for microcontrollers. It is noticeably faster than the traditional method, but is hard-coded to model the specific unreflected polynomial `0x1021`, or x^12 + x^5 + x^0. I was then able to det...
null
Given two unordered partitions of the same string over a finite alphabet into substrings, how hard is it to reconstruct the original string? If multiple solutions exist, any one will suffice. Under an *unordered partition* of a string I understand a multiset composed of the parts of any partition of this string int...
Reconstructing a string from two its partitions into substrings of varying size
null
I have been studying the [Ackermann function][1], specifically the two-argument Ackermann–Péter version. With the Ackermann function, I developed a problem I call the "Ackermann Decision Problem" > Given non-negative integers, x and y, does A(x,x) = y? The naive solution to verify the Ackermann Decision Proble...
Ackermann Decision Problem
|algorithms|complexity-theory|decision-problem|
null
No, you don’t need to compute the Ackerman function to verify this at all. The problem is trivial for x <= 3. And for x >= 4, if you can write down y, then the answer is “no”.
The table covers two consecutive binades, so is indexed by the least significant bit of the stored exponent and the most significant seven bits of the significand of the function argument, which is an IEEE-754 `binary64` number. In essence, $x \in [1,2)$ is mapped to indexes $128 \ldots 255$, and $x \in [2, 4)$ is mapp...
null
There’s a union if double and 64 bit int in a file that’s not shown, which lets you extract the sign, biased exponent, and mantissa without leading zero bit. For numbers from 1 to 2 the square root would be from 1 to 1.414. For numbers from 2 to 4 the square root would be from 1.414 to 2. If you look at the ieee f...
null
> There are $n$ cities on a highway with coordinates $x_1$ , . . . , $x_n$ and we aim to build $K < n$ gas stations to cover these cities. Each gas station has to be built in one of the cities, and we hope to minimize the average distance from each city to the closest gas station. Please give an algorithm to compute...
|algorithms|optimization|dynamic-programming|big-o-notation|
It looks that the recurrence relation is not implemented correctly in the code given in the question. ------ Here is a correct implementation. ```python # `cities` is a list of increasing integers that gives the # locations of all cities such as follows cities = [1, 5, 20, 22, 40, 100, 110] k = 2 def ...
The table covers two consecutive binades, so is indexed by the least significant bit of the stored exponent and the most significant seven bits of the significand of the function argument, which is an IEEE-754 `binary64` number. In essence, $x \in [1,2)$ is mapped to indexes $128 \ldots 255$, and $x \in [2, 4)$ is mapp...
null
The table covers two consecutive binades, so is indexed by the least significant bit of the stored exponent and the most significant seven bits of the significand of the function argument, which is an IEEE-754 `binary64` number. In essence, $x \in [1,2)$ is mapped to indexes $128 \ldots 255$, and $x \in [2, 4)$ is mapp...
The table covers two consecutive binades, so is indexed by the least significant bit of the stored exponent and the most significant seven bits of the significand of the function argument, which is an IEEE-754 `binary64` number. In essence, $x \in [1,2)$ is mapped to indexes $128 \ldots 255$, and $x \in [2, 4)$ is mapp...
The table covers two consecutive binades, so is indexed by the least significant bit of the stored exponent and the most significant seven bits of the stored significand of the function argument, which is an IEEE-754 `binary64` number. In essence, $x \in [1,2)$ is mapped to indexes $128 \ldots 255$, and $x \in [2, 4)$ ...
It looks that the recurrence relation is not implemented correctly in the code given in the question. ------ Here is a correct implementation. ```python # `cities` is a list of increasing integers that gives the # locations of all cities such as follows cities = [1, 5, 20, 22, 40, 100, 110] K = 2 def ...
[![enter image description here][1]][1] [1]: https://i.stack.imgur.com/j7BmD.png I found this from this PDF (https://web.stanford.edu/class/archive/cs/cs161/cs161.1168/lecture9.pdf)
How is a direct address table different from an array?
|algorithms|
The **direct access table** can be implemented as an **array**, which means that all operations you are to do to the array must be limited to the what is expected for a direct access table, which in turn is an implementation of a **dictionary**. In a direct access table, the index of the array is treated as the int...
|algorithms|data-structures|arrays|
[![enter image description here][1]][1] I have several lines that are shown in different colours, do not know which are connected to each other in advance. I want to do path planning only using these lines, i.e., route planning. If I am able to construct a graph using these line segments, I can use graph search te...
As shown in the figure, the pairs key/data are decoupled from the array of links, and this is clearly different from a pure array. Also note that it allows to represent *empty* slots. But this data structure is essentially introduced to prepare the next topic: hashing with chaining. It is not really useful in itself...
null
I have a pretty complex problem and I am using a rather complex ILP to solve it. In a special case of the problem the ILP is reduced to the following "simple" ILP. Additionally, I know that for this special case there exist polynomial time algorithms. We have two sets of variables $V$ and $E$. $E$ can be split into...
Are there any Indicators that this specific Integer Linear Program is solvable in polynomial time
|polynomial-time|integer-programming|
null
I have a pretty complex problem and I am using a rather complex ILP to solve it. In a special case of the problem the ILP is reduced to the following "simple" ILP. Additionally, I know that for this special case there exist polynomial time algorithms. We have two sets of variables $V$ and $E$. $E$ can be split into...
An array can be a very simple data structure - although you can have more complex structures for example if you want adding/deleting items at the start or end, or at arbitrary places, fast. These guys implement a sparse array in a reasonable way. The size requirement is number of possible indices times size of a po...
Given is a multiset $S$, a finite set $T = \{t_1, t_2, t_3\}$, and an integer $k \in \mathbb{N}$. Let $v(t_j)$ be a set of values $\in \mathbb{R^+}$ of length $|T|$ that can be assigned to $s_i$, and $c(t_j)$ be the cost of assigning $v(t_j)$ to $s_i$. Since $S$ is a multiset, assigning $v(t_j)$ to $s_i$ will affec...
Given is a multiset $S$, a finite set $T = \{t_1, t_2, t_3\}$, and an integer $k \in \mathbb{N}$. Let $v(t_j)$ be a set of values $\in \mathbb{R^+}$ of length $|T|$ that can be assigned to $s_i$, and $c(t_j)$ be the cost of assigning $v(t_j)$ to $s_i$. Since $S$ is a multiset, assigning $v(t_j)$ to $s_i$ will affec...
null
No, you don’t need to compute the Ackerman function to verify this at all. The problem is trivial for x <= 3. And for x >= 4, if you can write down y, then the answer is “no”. More serious, if you actually wrote down say y ≈ A(4), you can solve it easily in linear time in the size of y. If calculating A(4) take...
null
My problem is this: I have a list of $n$ items $N$ (think of them as the natural numbers $1,\dots,n$) and $m$ subsets of $N$ $S_1,\dots,S_m$ which may overlap. The objective is to find a partition of the $m$ subsets $(P_1,\dots,P_k)$ for any $1\leq k\leq m$ maximising the following quantity $$ \sum_{i=1}^k\left|\bigc...
Partition a family of sets to maximize cumulative overlap and cardinality
|np-hard|polynomial-time-reductions|
I have a pretty complex problem and I am using a rather complex ILP to solve it. In a special case of the problem the ILP is reduced to the following "simple" ILP. Additionally, I know that for this special case there exist polynomial time algorithms. We have two sets of variables $V$ and $E$. $E$ can be split into...
It is quite easy to prove that f(n) + g(n) ∈ Ω(h(n)), but I am having trouble with proving/disproving that f(n) + g(n) ∈ O(h(n)). Thanks for any help.
If we have f(n) ∈ O(h(n)) and g(n) ∈ Ω(h(n)), does that mean that f(n) + g(n) ∈ Θ(h(n))?
|asymptotics|big-o-notation|
I am looking for a map-like data structure with the following properties: - it uses subsets of some set S as keys. The size of S is potentially unbounded, but does not change during the runtime - the size of the subsets, used as keys, can vary between keys, i.e. one key can be a 3 element subset, while another migh...
Map-like data structure with subsets as keys
|data-structures|sets|partial-order|
Consider the following family of linear programs with $n$ variables, parametrized by an integer $k\in\{0,\ldots,n\}$ (where $A, b, c$ are fixed and given): $$ (L_k) \\ \text{maximize} ~~~ c\cdot x \\ \text{subject to} ~~~ A x \leq b \\ x \geq 0 \\ x_1,\ldots,x_k \in \mathbb{R} \\ x_{k+1},\ldots,x_n \in \m...
Does a problem remain computationally easy If a single discrete variable becomes continuous?
|complexity-theory|linear-programming|
Does a problem remain tractable If a single discrete variable becomes continuous?
null
## Case 1: Union of selected intervals might not be a single interval First of all, sort the intervals in increasing order based on left endpoint Use the following Dynamic Programming solution: $dp(i, j, k) = max( dp(i + 1, j’, k - 1) + extend\_union, dp(i + 1, j, k) )$ where $$ \mathrm j' = \begin{case...
## Case 1: Union of selected intervals might not be a single interval First of all, sort the intervals in increasing order based on left endpoint Use the following Dynamic Programming solution: $dp(i, j, k) = max( dp(i + 1, j’, k - 1) + extend\_union, dp(i + 1, j, k) )$ where $$ \mathrm j' = \begin{case...
## Case 1: Union of selected intervals might not be a single interval First of all, sort the intervals in increasing order based on left endpoint Use the following Dynamic Programming solution: $dp(i, j, k) = max( dp(i + 1, j’, k - 1) + extend\_union, dp(i + 1, j, k) )$ where $$ \mathrm j' = \begin{case...
## Case 1: Union of selected intervals might not be a single interval First of all, sort the intervals in increasing order of $I_i.start$ Use the following Dynamic Programming solution: $dp(i, j, k) = max( dp(i + 1, j’, k - 1) + \text{extend_union}, dp(i + 1, j, k) )$ where $$ \mathrm j' = \begin{cases}...
## Case 1: Union of selected intervals might not be a single interval First of all, sort the intervals in increasing order of $I_i.start$ Use the following Dynamic Programming solution: $$ \mathrm dp(i, j, k) = max( dp(i + 1, j’, k - 1) + \text{extend_union}, dp(i + 1, j, k) ) $$ where $$ \mathrm j'...
## Case 1: Union of selected intervals might not be a single interval First of all, sort the intervals in increasing order of $I_i.start$ Use the following Dynamic Programming solution: $$ \mathrm dp(i, j, k) = max( \text{extend_union} + dp(i + 1, j’, k - 1), dp(i + 1, j, k) ) $$ where $$ \mathrm j...
My goal is to turn a strict total order of labeled elements into its strict partial order representation, given a concurrency oracle, that tells me, which pairs of labels are concurrent. Auto-concurrency is not allowed, i.e. two elements with the same label are always ordered. I have implemented a naive solution to...
Creating a partial order from a total order with a concurrency oracle
|algorithms|partial-order|
null