instruction
stringlengths
0
29.8k
⌀
{"Voters":[{"Id":4249,"DisplayName":"Pål GD"}]}
I had an idea for a polynomial time algorithm, but here is a counter-example. $I = \{ [1,8], [2,3], [3,5], [5,6] \}$. The solution is $\{2,4,6,8\}$. Invalid solution ``` 1 2 3 4 5 6 7 8 [· ] [ ·] [ ·] [ ] ``` Valid solution ``` 1 2 3 4 ...
{"Voters":[{"Id":4249,"DisplayName":"Pål GD"}]}
I had an idea for a polynomial time algorithm, but here is a counter-example. I leave it visible for the sake of having an interesting input instance. I thought that the decisions didn't propagate too far, but that's clearly not true. $I = \{ [1,8], [2,3], [3,5], [5,6] \}$. The solution is $\{2,4,6,8\}$. Inval...
There is no unique answer, that can depend on code optimizations. If the data that you are considering is constant, it could be used in *immediate* mode, i.e. be inserted in the instruction flow where needed. E.g. Load R0, 5 Load R1, 2 Add R0, R1 ... The immediate value would have to be repe...
There is no unique answer, that can depend on code optimizations. If the data that you are considering is constant, it could be used in *immediate* mode, i.e. be inserted in the instruction flow where needed. E.g. Load R0, 5 Load R1, 2 Add R0, R1 ... The immediate value would have to be repe...
Only MergeSort has a guaranteed $O(n\log n)$ behavior. You may well consider Natural MergeSort, that has the extra property of adaptiveness. ---------- If you only care about swapping links, I guess that both StraightSelection and StraightInsertion achieve an optimal (certainly in the worst case, $O(n)$).
null
null
I'm looking for an algorithm that is closely related to the [2-dimensional nesting problem][1] (also known as lay planning, bin packing, and the cutting stock problem). The main differences between this and normal nesting are: * A fixed number of elements to be placed * The elements cannot rotate * The elements m...
I'm looking for an algorithm that is closely related to the [2-dimensional nesting problem][1] (also known as lay planning, bin packing, and the cutting stock problem). The main differences between this and normal nesting are: * A fixed number of elements to be placed * The elements cannot rotate * The elements m...
I'm looking for an algorithm that is closely related to the [2-dimensional nesting problem][1] (also known as lay planning, bin packing, and the cutting stock problem). The main differences between this and normal nesting are: * A fixed number of elements to be placed * The elements cannot rotate * The elements m...
An arithmetic circuit relates to calculating the value of a polynomial given some inputs. But is it still considered a circuit if the DAG corresponds to the evaluation of multiple polynomials that share nodes? Consider $f(x, y) = 3x^4 * y^3$ and $g(x, y) = 3x^4 * y^2 + x^2$. $f$ and $g$ share the node correspond...
Can an arithmetic circuit have multiple outputs?
|circuits|polynomials|
null
An arithmetic circuit relates to calculating the value of a polynomial given some inputs. But is it still considered a circuit if the DAG corresponds to the evaluation of multiple polynomials that share nodes? Consider $f(x, y) = 3x^4 * y^3$ and $g(x, y) = 3x^4 * y^2 + x^2$. $f$ and $g$ share the node correspond...
null
null
null
I am currently struggling with figuring out the following problem: Given decidable languages L1, L2, L3, L4, ... Is the infinite union of Languages L1, ...... decidable? I have an intution that it is not, but I cannot find an example against that thesis. Thank you in advance
Is the infinite union of decidable languages decidable?
|formal-languages|turing-machines|undecidability|decidability|recursively-enumerable|
null
Your intuition is right. Hint: for any $x$, the language $\{x\}$ is decidable. Think how we can use this fact to construct an undecidable language.
Normally, a circuit has one output: it computes a single function. Therefore, your question does not come up, because we cannot have a circuit that outputs both $f(x,y)$ and $g(x,y)$: that would be two outputs / two functions. If you had a circuit that outputs a single value, say $h(x,y) = f(x,y) * g(x,y)$, then ye...
null
Apologies if this question exists somewhere. I'm sure it's been asked, but I don't know how to search for it. This is not a homework question but rather a scientific problem I ran into. If this is a standard CS exercise, just mark it as duplicate and point me where I need to go. **Problem statement:** Consider an ...
Algorithm: Optimal selection of subset of nodes in undirected graph to minimize score
|algorithms|graphs|optimization|
Apologies if this question exists somewhere. I'm sure it's been asked, but I don't know how to search for it. This is not a homework question but rather a scientific problem I ran into. If this is a standard CS exercise, just mark it as duplicate and point me where I need to go. **Problem statement:** Consider an ...
The problem is unfortunately NP-hard. On bipartite graphs, it is at least as hard as the maximum edge biclique problem. Consider any bipartite graph. Put weight $0$ on every node and weight $-1$ on every edge. Then there is a maximum edge biclique with at least $k$ edges, iff the optimal solution to your problem ...
null
null
I'm working on understanding graphs and graph algorithms. The problem is from: https://courses.engr.illinois.edu/cs374/fa2020/labs/sol/lab_12_b_sol.pdf > Describe an efficient algorithm to update the minimum spanning tree $T$ of a weighted undirected graph G when the weight of one edge $e \notin T$ is decreased. ...
Proving why decreasing an edge in a graph may change it's MST by one edge
|algorithms|graphs|proof-techniques|graph-traversal|minimum-spanning-tree|
[My previous answer contained an incorrect claim about NP-hardness.] I don't know whether there is a polynomial-time algorithm. If you have to solve this in practice, one possible solution would be to use integer linear programming (ILP). Introduce zero-or-one integer variables $x_v$, where $x_v$ means that node...
Proving why decreasing an edge weight in a graph may change it's MST by one edge
I'm working on understanding graphs and graph algorithms. The problem is from: https://courses.engr.illinois.edu/cs374/fa2020/labs/sol/lab_12_b_sol.pdf (Q 1.D) > Describe an efficient algorithm to update the minimum spanning tree $T$ of a weighted undirected graph G when the weight of one edge $e \notin T$ is de...
null
Think of the vertices of $G$ to be partitioned into two sets : $V_1$ and $V_2$, where $V_1$ consists of the vertices in the cycle and $V_2$ are the remaining vertices. Now In the graph, $G\setminus V_1$, the MST is what you had before, nothing has changed since $G\setminus V_1$ has not changed. In $G\setminus V_2$, you...
null
I'm sure this question has been asked before, but I have no clue what I'm trying to achieve is called and couldn't find anything helpful. I'm trying to find the name of an algorithm that starts at a point and rotates around a "board" in either clockwise or anti-clockwise rotation. I'll draw some examples to shown...
What is the algorithm where you rotate around a board in a clockwise pattern?
|algorithms|
The problem is solvable in polynomial time. Let $G = (V, E)$ be any graph with positive positive weights $w: V \cup E \to \mathbb{N}$ on both edges and vertices. For a subset $S \subseteq V$ let $E(S)$ denote the set of edges in $G$ with both endpoints in $S$. For such a set $S$, let $$f(S) = \sum_{e \in E(S)} w(...
The problem is solvable in polynomial time. Let $G = (V, E)$ be any graph with positive weights $w: V \cup E \to \mathbb{N}$ on both edges and vertices. For a subset $S \subseteq V$ let $E(S)$ denote the set of edges in $G$ with both endpoints in $S$. For such a set $S$, let $$f(S) = \sum_{e \in E(S)} w(e) - \sum...
The problem is solvable in polynomial time. Let $G = (V, E)$ be any graph with positive weights $w: V \cup E \to \mathbb{N}$ on both edges and vertices. For a subset $S \subseteq V$ let $E(S)$ denote the set of edges in $G$ with both endpoints in $S$. For such a set $S$, let $$f(S) = \sum_{e \in E(S)} w(e) - \sum...
Consider L1 = Any language generated by a machine M1 L2 = Any language generated by a machine M2 Machine can be – FA, PDA, LBA, or TM Assuming Machine M2 is more powerful than M1 Let **L3 = L1 $\cap$ L2** Now can we **always** say that L3 can be generated by Machine M2 ? For **eg:** **L1** = Any...
Intersection of different languages
|automata|
Static recompilation is used, for example it is [central in Apple's Rosetta 2 emulator](https://dougallj.wordpress.com/2022/11/09/why-is-rosetta-2-fast/). But there are challenges that make it difficult to apply. Most importantly, all jump targets are not readily determined from the code. Compilers generate code usi...
Static recompilation from a binary is hard, because it is challenging to reconstruct the structure of the program. It is hard to statically figure out the location of all instructions that will be executed, the starting point of all functions, and the set of all jump targets. This information is needed for natural me...
Nope. For several examples, see https://en.wikipedia.org/wiki/Context-free_language#Nonclosure_under_intersection,_complement,_and_difference, https://cs.stackexchange.com/q/133831/755, https://cs.stackexchange.com/q/139260/755.
|automata|closure-properties|
in [here](https://arxiv.org/pdf/math/0504351.pdf) they claim: "there is an algorithm deciding almost all instances of [halting problem]" so I'm wonder whether there is a computable function $h':\mathbb{N}\to\{0,1\}$ such that the following turing machine is a halting decider (for TMs running on blank input) except f...
can you write a halting decider that is only wrong about itself by avoiding diagonalization?
|turing-machines|halting-problem|
I am trying to understand Circuit Complexity's relation to classical Time Complexity. Here is what wiki mentions: "If a certain language, ${\displaystyle A}$, belongs to the time-complexity class ${\displaystyle {\text{TIME}}(t(n))}$ for some function ${\displaystyle t:\mathbb {N} \to \mathbb {N} }$, then ${\display...
Relationship b/w Circuit and Time Complexity
|complexity-theory|time-complexity|
Is **CFL $\cap$ DCFL = CFL**, always true? CFL - Any Context Free Language DCFL - Any Deterministic Context Free Language
Intersection of CFL and DCFL
|context-free|pushdown-automata|
Even the intersection of two deterministic context-free languages may not be context-free. Consider $L_1 = \{a^nb^nc^m\mid n,m\geqslant 0\}$ and $L_2 = \{a^nb^mc^m\mid n,m\geqslant 0\}$. Both languages are DCFL, but their intersection is $\{a^nb^nc^n\mid n\geqslant 0\}$ which is not context-free.
This problem can be reduced to the maximum flow problem. That is, this problem is as an instance of the [closure problem](https://en.wikipedia.org/wiki/Closure_problem), where we have variables for vertices and edges of the original graph, and has constraints $x_e \implies x_u$ and $x_e \implies v$ for each edge $e =...
No, you can't. If you had a procedure $M$ that would correctly solve the Halting problem for all but finitely many instances $p_0,p_1,\ldots,p_k$, then there would exist a computable solution to the Halting problem as follows: Input $p$ if $p = p_0$, return $b_0$ elseif $p = p_1$, return $b_1$ ... elseif...
in [here](https://arxiv.org/pdf/math/0504351.pdf) they claim: "there is an algorithm deciding almost all instances of [halting problem]" so I'm wonder whether there is a computable function $h':\mathbb{N}\to\{0,1\}$ such that the following turing machine is a halting decider (for TMs running on blank input) except f...
From the starting point $(k,\frac{n-1}2)$, go up $k$ times, right $2k$ times, down $2k$ times and up $k-1$ times.
Circuit complexity refers to a family of circuits used to solve different inputs of the same problem. For a problem $A$, it is defined as a function $c : \mathbb{N}\to\mathbb{N}$ such that for any integer $n$, there exists a circuit of size $\leqslant c(n)$ that decides all instances of $A$ of length $n$. Given a fu...
Circuit complexity refers to a family of circuits used to solve different inputs of the same problem. For a problem $A$, it is defined as a function $c : \mathbb{N}\to\mathbb{N}$ such that for any integer $n$, there exists a circuit of size $\leqslant c(n)$ that decides all instances of $A$ of length $n$. Given a fu...
null
(^ + 0)1*((1+10)+(0011))* Regex: {0,1} :Every pair of adjacent zeros appears before any pair of adjacent ones.
This article from IBM ([link][1]) talks about Memory hierarchy in its actual hardware parts. > NUMA > > While operating systems present memory to the running applications as a unified space, modern large systems have memory organized in a hierarchy, by core, chip, module, socket, node, and chassis/central process...
null
This question is in the context of quicksort. Consider that a subarray of distinct elements of size $k$ is sampled from the input array of size $n$, and then we choose a pivot from the sampled subarray. We want to compute and bound the probabilty that the pivot lies in the middle third of the sampled array. This is ...
Quicksort sampling
|sorting|combinatorics|quicksort|
This question is in the context of quicksort. Consider that a subarray of distinct elements of size $k$ is sampled from the input array of size $n$, and then we choose a pivot from the sampled subarray. We want to compute and bound the probability that the element of rank $s$ in the original array lies in the middle th...
The `COIN-CHANGING` problem is NP-complete, but I am having difficulty finding a proof for its NP-hardness in the form of a reduction from another NP-complete problem to `COIN-CHANGE`. Apparently, a reduction from `SUBSET-SUM` to `COIN-CHANGING` is possible according to this (hopefully old enough) [algorithms assignmen...
Reduction from SUBSET SUM to COIN CHANGING
|algorithms|complexity-theory|np-complete|reductions|np-hard|
The `COIN-CHANGING` problem is NP-complete, but I am having difficulty finding a proof for its NP-hardness in the form of a reduction from another NP-complete problem to `COIN-CHANGING`. Apparently, a reduction from `SUBSET-SUM` to `COIN-CHANGING` is possible according to this (hopefully old enough) [algorithms assignm...
I will use the same notation as the assignment you linked: > $\texttt{SUBSET-SUM}$: > - Input: $n$ positive integers $w_1, …, w_n$ and an integer target $W$. > - Question: is there a set $I \subseteq \{1, …, n\}$ such that $\sum\limits_{i\in I}w_i = W$? > $\texttt{COIN-CHANGING}$: > - Input: $m$ positive integ...
{"Voters":[{"Id":79440,"DisplayName":"Nathaniel"}]}
I think that a reduction from exact cover by 3-sets (X3C) is easier: given a set of $X = \{x_1, \dots, x_{3n}\}$ of elements and a collection $S = \{S_1, \dots, S_n\}$ of subsets of $X$ each containing 3 elements, is there a subset $S'$ of $S$ such that each element in $X$ is contained in exactly one set in $S'$? Th...
{"Voters":[{"Id":79440,"DisplayName":"Nathaniel"}]}
I will use the same notation as the assignment you linked: > $\texttt{SUBSET-SUM}$: > - Input: $n$ positive integers $w_1, …, w_n$ and an integer target $W$. > - Question: is there a set $I \subseteq \{1, …, n\}$ such that $\sum\limits_{i\in I}w_i = W$? > $\texttt{COIN-CHANGING}$: > - Input: $m$ positive integ...
I will use the same notation as the assignment you linked: > $\texttt{SUBSET-SUM}$: > - Input: $n$ positive integers $w_1, …, w_n$ and an integer target $W$. > - Question: is there a set $I \subseteq \{1, …, n\}$ such that $\sum\limits_{i\in I}w_i = W$? > $\texttt{COIN-CHANGING}$: > - Input: $m$ positive integ...
I need to prove that $T(n)$ is $\mathcal O(n\log n)$ with the substitution method. $$ T(n)\leq 3\log n + n + \frac{6}{n}\sum^{2n/3}_{n/3}T(i).$$ This is my attempt: I assume $T(n) \leq c n \log n$ and then \begin{align*} T(n) &\leq 3 \log n + n + \frac{6c}{n}\int^{2n/3}_{n/3}x\log x dx\\ &\leq3 \log n + n + \fr...
Proving this recurrence is $n \log n$
|asymptotics|big-o-notation|upper-bound|
Just continue from there: $$\begin{align*} & \leqslant 3\log n + n + \frac{6c}n\left(\frac{2n^2}9\log\left(\frac{2n}3\right)-\frac{n^2}{18}\log\left(\frac{n}3\right)-\frac{n^2}{12}\right)\\ & = 3\log n + n + \frac{6c}n\left(\frac{2n^2}9\log n - \frac{n^2}{18}\log n + \frac{2n^2}9\log 2 - \frac{2n^2}9\log3 + \frac{...
In section 30.2 of CLRS (third edition), they given an algorithm for computing the fast Fourier transform of a vector represented as an $n$ dimensional array when $n$ is a multiple of $2$. They say that an algorithm for general $n$ is beyond the scope. Is generalizing the algorithm to any $n$ very tricky? Any reference...
FFT algorithm for arbitrary $n$
|algorithms|fast-fourier-transform|
Static recompilation from a binary is hard, because it is challenging to reconstruct the structure of the program. It is hard to statically figure out the location of all instructions that will be executed, the starting point of all functions, and the set of all jump targets. This information is needed for natural me...
(^ + 0)(1+10+101+10011)* +(0011) Regex: {0,1} :Every pair of adjacent zeros appears before any pair of adjacent ones('^'->null).
I need to prove that the following expression is $\mathcal O(n \log n)$ with the substitution method: $$ T(n) \leq 3\log n + n + \frac{6}{n}\sum^{n - \frac{\log n}{3}}_{i=\frac{\log n}{3}} T(i)$$ This is my attempt, assumming $T(n) \leq c n \log n$: \begin{align*} T(n) &\leq 3\log n + n + \frac{6c}{n}\int^{n - \fr...