instruction
stringlengths
0
29.8k
⌀
I need to show that the problem is NP-complete
|complexity-theory|np-complete|satisfiability|3-sat|
The innermost loop runs $\lg(j)$ times. The middle loop executes it for all $j$ from $1$ to $s$, hence $\displaystyle\sum_{j=1}^{s}\lg(j)=\lg(s!)$. The outer loop executes the latter for all perfect squares from $1$ to $n$, hence $\displaystyle\sum_{k=1}^{\sqrt n}\lg((k^2)!)$. Using Stirling, we can approximat...
The innermost loop runs $\lg(j)$ times. The middle loop executes it for all $j$ from $1$ to $s$, hence $\displaystyle\sum_{j=1}^{s}\lg(j)=\lg(s!)$. The outer loop executes the latter for all perfect squares from $1$ to $n$, hence $\displaystyle\sum_{k=1}^{\sqrt n}\lg((k^2)!)$. Using Stirling, we can approximat...
Suppose that the minimum VCP size is s. If $|Y|=s$ then the optimal solution (without solving any problem) is $Y=1$ and $X=0$. Else, we can solve $min$ $W_uX_u+W_vY_v$ s.t. {$x_u+y_v\ge 1$, $0\le x_u,y_v \le 1$}; i.e. the original VCP relaxation model, where $W_u=1$ and $W_v=1-\epsilon$. Based on Nemhauser a...
i, sq ← 1, 1 while sq < n for j ← 1 to sq k ← 1 while k ≤ j k ← 2 ∗ k i ← i + 1 sq ← i ∗ i I have expressed the running time of the "for" loop as a sum in this way : $$\sum_{j=1}^{i^2} \log(j)$$ In a similar way, how can I express ...
Estimate the running time of a while-for-while loop
|algorithms|time-complexity|summation|
Adding to the discussion, you can also detect negative or zero-length cycles using Floyd-Warshall in $O(n^3)$ by setting the initial value of the minimum distance of each node to itself as infinity. Also, there is this [problem](https://oj.uz/problem/view/APIO17_merchant) (APIO 2017 Travelling Merchant) that is slig...
So I've boiled a certain problem I have down to the point where I have two images of (approximately) the same scale. One which contains a closed curve, and one which is a partial curve. I want to determine what rotation and translation (and possibly scale, though for now that is not required) will best map the partia...
Algorithm to find best alignment of one curve onto another
|image-processing|pattern-recognition|
Creating a Deterministic Push Down Automaton
One plausible approach would be to adapt a [graph drawing algorithm](https://en.wikipedia.org/wiki/Graph_drawing) algorithm to your situation. Some of them use optimization (e.g., force-based layout algorithms); it should be easy to adapt them by treating the $y$-coordinate of each point as a fixed constant and only o...
One definition for $P$ is the set of all languages that have a deterministic turing machine $M$ s.t. if $x\in A$ the machine accepts in polynomial time and otherwise it rejects, also in polynomial time. There is no loops, so $P\subseteq R$. One definition for $NP$ is having a witness and a deterministic turing machi...
Exact formulation of definition of $NP$, in relation to $R$
|complexity-theory|turing-machines|polynomial-time|nondeterminism|recursively-enumerable|
One definition for $P$ is the set of all languages that have a deterministic turing machine $M$ s.t. if $x\in A$ the machine accepts in polynomial time and otherwise it rejects, also in polynomial time. There is no loops, so $P\subseteq R$. One definition for $NP$ is having a witness and a deterministic turing machi...
I am working in a finite prime field $\mathbb{F}_p$ that does not have primitive $n$-th roots of unity for any large smooth integer $n$, which makes FFTs a bit difficult. If I need to compute a product of linear polynomials $\prod\limits_{i=0}^n (X+a_i)$, can I do so in runtime $O(n\cdot \log^2(n))$? How bad is...
Polynomial multiplication in finite field without smooth-order roots of unity
|runtime-analysis|polynomials|fast-fourier-transform|
I have a problem in proving of nonregularity of EQ_n = {u = v2v : |v| = n}. I just dont know how to start. Can you help me?
How to prove non-regularity with Myhill-Nerode theorem?
|regular-languages|
I'm interested in a question that probably lies close to the very concept of recursion. I have no idea whether my statement is true or false, neither I have tools to check it, so I'll just ask the question. Short and simple, if there exists a recurrent formula for some process, can it be either proven or disproven (...
Does a closed formula exist for each recurrent formula?
|recurrence-relation|recursion|
If the alphabet is only $\{2\}$, then the language is regular. Otherwise, there's at least one other letter, let's say $a$. Then the infinitely many words $a^i2$ are all pairwise non-equivalent.
One definition for $P$ is the set of all languages that have a deterministic turing machine $M$ s.t. if $x\in A$ the machine accepts in polynomial time and otherwise it rejects, also in polynomial time. There is no loops, so $P\subseteq R$. One definition for $NP$ is having a certificate and a deterministic turing m...
null
I've noticed that the certificate/verification version of the definition of the class NP is much more popular online than the Turing machine version. In particular, the Wikipedia page has the certificate version listed first, and Google's featured result (via Britannica) lists this version. This seems to be especially ...
Why is the certificate version of NP so ubiquitous?
|complexity-theory|knowledge-representation|
null
I've noticed that the certificate/verification version of the definition of the class NP is much more popular online than the Turing machine version. In particular, the [Wikipedia page][1] has the certificate version stating > NP is the set of decision problems for which the problem instances, where the answer is "y...
null
null
0 < a,b,c,d < M are all positive integers (uint64). we have assembler (integer only) operations available (e.g. division only yields integers). we want to approximate: (a/b)^(c/d) how to do this in the simplest way? thx
Approximate (a/b)^(c/d) using integer arithmetic only (assembler)
|approximation|arithmetic|integers|assembly|
0 < a,b,c,d < M are all positive integers (uint64). also, a<b if that helps. we have assembler (integer only) operations available (e.g. division only yields integers). we want to approximate: (a/b)^(c/d) how to do this in the simplest way? thx
It's likely due to the simplicity, because if you use the TM definition, which I assume is the non-deterministic TM solving in poly time, now you have to explain what a non-deterministic TM is, how it works, and why it would work to solve such a problem. Understanding that an NP problem is so because we can check i...
As a general rule, $x_{n+1}=f(x_n)$ does not have a closed form. But I don't know of a general proof. (This seems to be at the same level of difficulty as the antiderivative or closed-form zeroes problems.)
As a general rule, $x_{n+1}=f(x_n)$ does not have a closed form. But I don't know of a general proof. (This seems to be at the same level of difficulty as the antiderivative or closed-form zeroes problems.) ---------- **An interesting case:** Let us consider the following iteration: $$x_{n+1}=\frac{x_n^2+a^...
null
Definition of $\mathsf{NP}$: A decision problem $prob$ (i.e., a set of input strings) is in $\mathsf{NP}$ iff there is a deterministic Turing machine (DTM) $D$ such that for each yes-instance $x$ of $prob$, there is a certificate $(x,y)$ that is accepted by $D$ in polynomial time of $|x|$. It is notable, as describe...
In the scheduling problem, the input is a sequence $T_1,T_2,...,T_n$ which are the times of $n$ jobs to be executed in m identical machines. A schedule is an assignment of the jobs to machines. The load of each machine is the sum of the times of the jobs assigned to it. The objective is to find a schedule with minimu...
Proving that the greedy algorithm for job scheduling has a 2 - (1/m) approximation ratio
|approximation|greedy-algorithms|
#### A definition of $\mathsf{NP}$ Definition of $\mathsf{NP}$: A decision problem $prob$ (i.e., a set of input strings) is in $\mathsf{NP}$ iff there is a deterministic Turing machine (DTM) $D$ such that for each yes-instance $x$ of $prob$, there is a certificate $(x,y)$ that is accepted by $D$ in polynomial time of ...
null
Suppose machine $A$ ends up with the maximum load $M$ . Let $i$ be the last job scheduled on machine $A$. Right before $i$ was scheduled, machine $A$ had the smallest load, which was at most the average load at that time. We have, $$\begin{aligned} M &= (M − T_i ) + T_i\\ &\le\frac 1m(\sum_{1\le k\le n}T_k\,-T_i) +...
Let us call a red-black tree strict when every black node has at most one red child. Show that a strict red-black full tree has at most (n − 1)/4 red nodes; a tree is full when every node has zero or two children. The hint for this problem says to use a charging argument but I can't seem to figure one out. M...
Proving that a red black tree where every black node has at most 1 red child has at most (n-1)/4 red nodes
|data-structures|red-black-trees|
Let's say building blocks are X, Y, XX, YY, XY and YX. Each building block has an associated count ($c_X, c_Y, c_{XX}, \ldots$). Given a string $s$ and building block counts, figure out if it can be constructed from the building blocks that are used exactly the amount of times allowed by counts. My approach was ...
Determine if string can be constructed from given building blocks
|algorithms|strings|
Let's say building blocks are X, Y, XX, YY, XY and YX. Each building block has an associated count ($c_X, c_Y, c_{XX}, \ldots$). Given a string $s$ and building block counts, figure out if it can be constructed from the building blocks that are used exactly the amount of times allowed by counts. Example: XXYXY, ...
Let's say building blocks are X, Y, XX, YY, XY and YX. Each building block has an associated count ($c_X, c_Y, c_{XX}, \ldots$, $c_i$ can be 0). Given a string $s$ and building block counts, figure out if it can be constructed from the building blocks that are used exactly the amount of times allowed by counts. ...
0 < x,a,b,c,d < M are all positive integers (uint64). also, a<b if that helps. we have assembler (integer only) operations available (e.g. division only yields integers). we want to approximate: x*(a/b)^(c/d) how to do this in the simplest way? thx edit: added x
Approximate x*(a/b)^(c/d) using integer arithmetic only (assembler)
Deposit 3 dollars on each red nodes initially. For each black node, if it is a sibling or a child of a red node, move one dollar on that red node onto the black node. Claim 1: there is at most one dollar on each black node. There is no dollar on the root of the tree. Claim 2: there is no dollar on red nodes. ...
Let us call a red-black tree strict when every black node has at most one red child. Show that a strict red-black full tree has at most $(n − 1)/4$ red nodes; a binary tree is full when every node has zero or two children. The hint for this problem says to use a charging argument but I can't seem to figure one o...
A red-black full tree where every black node has at most 1 red child has at most (n-1)/4 red nodes
null
For every prefix of the string, determine how it can be produced. We always prefer two letter blocks to two single letter blocks. Let s = eps: Create s by using no blocks. Let s = A where A is a single letter X or Y. s cannot be created if $c_A = 0$, otherwise it is created by using the single-letter block A. ...
In my experience, the duality of Petri nets is a great strength. It forces us to specify the potential events or actions in a system (the transitions), as they may happen to individual items (the tokens), together with their preconditions and postconditions (the places). This forces us to think through what a step r...
In my experience, the duality of Petri nets is a great strength. It forces us to specify the potential events or actions in a system (the transitions), as they may happen to individual items (the tokens), together with their preconditions and postconditions (the places). This forces us to think through what a step r...
I am trying to implement this article https://arxiv.org/pdf/1905.04897.pdf (the article is there only for information, no need to read it to answer my question) At some point they say when talking about a 1 dimensional cutting stock problem $I_R$: First, we obtain a solution $S$ of the instance $I_R$. For instanc...
Cutting stock problem upper bound with gilmore and gomory
|optimization|linear-programming|upper-bound|
>For a regular language $A$ with an alphabet $\Sigma$, define an equivalence relation for strings $x,y \in \Sigma^*$ by $x\equiv_A y\Leftrightarrow \,\forall w\in \Sigma^*, xw, yw\in A$ or $xw, yw\not\in A$. Let $[x] := \{ y\in \Sigma^* : y\equiv_A x\}$ be the equivalence class of $x$ with respect to $A$ for any $x\in ...
determining the relationship between two regular languages using the myhill nerode theorem
|regular-languages|automata|
No, the statement is not true. The language defines the equivalence classes, but not the other way around. Each class can be totally within or totally outside the language. So with several classes we have some room to choose which classes are in and which classes are out the language. We have to be careful though, some...
I'm writing an AI based on reinforcement learning to play Connect 4. That's my second bot and attempt to RNN and AI (first was copy a code of snake RNN AI from youtube) and I'm looking for some advices and also I have a question. In [mentioned video][1] there are to functions `train_short_memory` and `train_long_mem...
Long and short memory in reinforcement learning Connect 4 AI
|neural-networks|game-theory|reinforcement-learning|board-games|
null
The standard way to implement exponentiation is using logarithm and exponentiation. In particular, $$u^v = e^{v \log u}.$$ So, you need algorithms for multiplication, division, exponentiation, and logarithm. Multiplication and division are documented well in many standard places. Some algorithms for division c...
null
|neural-networks|python|game-theory|reinforcement-learning|board-games|
null
null
If the tastings are reliable (i.e. always returning the same results for the same samples and forming a true total order relation - A better than B and B better than C implies A better than C), what you are after is a "minimum comparison sorting" procedure. The number of comparisons for N elements is very close to N...
If the tastings are reliable (i.e. always returning the same results for the same samples and forming a true total order relation - A better than B and B better than C implies A better than C), what you are after is a "minimum comparison sorting" procedure. The number of comparisons for N elements is very close to N...
If the tastings are reliable (i.e. always returning the same results for the same samples and forming a true total order relation - A better than B and B better than C implies A better than C), what you are after is a "minimum comparison sorting" procedure. The number of comparisons for N elements is very close to N...
null
Consider a string with repeats of a letter, for example `BANANA`. The forward transform will create this block: ABANAN ANABAN ANANAB BANANA NABANA NANABA Now imagine we label every occurrence of `A` with `1`, `2` or `3` depending on which `A` in the original word it is. Observe tha...
I'm supposed to find an algorithm that, given a bunch of points on the Euclidean plane, I have to return the tightest (smallest) origin centered upright equilateral triangle that fits all the given points inside of it, in a way that if I input some random new point, the algorithm will return $+$ if the point is inside ...
Finding smallest triangle to fit all points
|computational-geometry|data-sets|euclidean-distance|
If the triangle is centered at the origin, in general only one point touches it. You find this point as the one furthest in the three directions normal to the triangle sides (by taking the dot product with the normal vectors). As there are three distances, you take the largest. Beware that the relevant distance is n...
null
Jörg W Mittag gives an excellent answer. But I think it does miss the heart of the question. The quote says "For the sake of this discussion, let's call the bottom type a type that has no members." So while Jorg is right that the "the defining feature of a bottom type is not that it has no members" and that "it is p...
I have the two following questions: 1) I know SAT -> MAX-SAT but how can I show that if MAX-SAT is solved in polynomial time then SAT is solved in polynomial time as well?(I guess using approximation algorithms) 2) I have this simple randomized algorithm for approximating the MAX-SAT problem: ***The algorithm ...
MAX-SAT 2-Approximation algorithm
|approximation|sat-solvers|maxsat|
A $1/2$-approximation algorithm and a $2$-approximation algorithm are exactly the same thing. Here are two definitions of a $\rho$-approximation algorithm for a maximization problem: 1. On an instance whose optimal value is $O$, the algorithm is guaranteed to output a solution whose values is at least $\rho \cdot...