instruction
stringlengths
0
29.8k
⌀
null
Call your matrix $A$ and define $S(r,c) := \sum_{1\leq i\leq r}A_{i,c}$. Now call $D(r,c)$ the optimal value for the submatrix consisting of the first $c$ columns of $A$, for a path which ends at row $r$. For convenience, define $D(r,0):=0$ for all $1\leq r \leq n$ and $D(0,c):=DC(n+1,c)=\infty$ for all $1\leq c \l...
null
null
> Let $B$ and $C$ be two languages on $A = {a,b}$: > > $B = \{ w \vert w \text{ has the same number as }a\text{ and }b\}$ > $C = \{ a^n b^m \vert n,m \ge 0\}$ > > (i) $\text{abba} \in B$ ? > > (ii) Describe $B \cap C$ and determine whether $B$ is regular or not using ONLY the closure property of regular lan...
null
> Let $B$ and $C$ be two languages on $A = \{a,b\}$: > > $B = \{ w \mid w \text{ has the same number as }a\text{ and }b\}$ > $C = \{ a^n b^m \mid n,m \ge 0\}$ > > Describe $B \cap C$ and determine whether $B$ is regular or not using *only* the closure property of regular languages. I reasoned like this: ...
A vertex $v$ such that $G-v$ is acyclic is called a feedback vertex, so your problem is equivalent to deciding whether there exists at least one feedback vertex in $G$. The paper ["A linear-time algorithm for finding all feedback vertices" by Garey and Tarjan](https://www.sciencedirect.com/science/article/abs/pii/00...
Deciding whether a Turing machine decides a language $L$ in at most $n^2$ steps
|turing-machines|undecidability|rice-theorem|
null
Let us say I have an empty graph `G` and a list of nodes `N` to add to the graph one-by-one. Let us say that I will have a node `X` that I do not yet know, but will know after I construct my graph `G`. My ultimate goal is to find the shortest distance from each node `N` to `X`, in the weighted graph `G` (For some conte...
Distance to specific node incremental addition
|graphs|shortest-path|weighted-graphs|
My 1st question ever on stackexchange, please be nice to me if it's too naive :) I read the [map reduce paper][1] and i discover distributed system is expensive. As an example in the paper, roughly speaking, approx. 1700 machines with 30000 mb/s throughput compares to non distributed single machine with 500mb/s...
Strategy of gradually integrating more complex distributed system into start up company
|distributed-systems|
The main reason to use a distributed system is because we have to. If you can meet the business need using a single server, typically that is more cost-effective. Distributed systems bring their own headaches and pain, so generally, we only enter into that if we have to. So the typical reason to use a distributed sy...
> Let $B$ and $C$ be two languages on $A = \{a,b\}$: > > $B = \{ w \mid w \text{ has the same number of }a\text{ and }b\text{ symbols}\}$ > $C = \{ a^n b^m \mid n,m \ge 0\}$ > > Describe $B \cap C$ and determine whether $B$ is regular or not using *only* the closure property of regular languages. I reasoned ...
You are part of the way there. You are expected to use the closure properties to show whether $B \cap C$ is regular depending on whether $B$ and $C$ are regular. You're not doing that. Also, your proof will depend on whether $C$ is regular so you will need to determine that, too.
You are part of the way there. You are expected to use the closure properties to show whether $B \cap C$ is regular depending on whether $B$ and $C$ are regular. You're not doing that. Closure properties are properties such as: 1. If $A$ is regular, then $\bar A$ (= $\Sigma^* - A$) is regular. 2. If $A$ and $B...
null
Assuming that $P \neq NP$. From Cook & Levin's theorem we know that all Problems in NP are polynomially reducible to SAT: $ \forall_{L\in NP}: L \leq_{p}SAT$. Is the opposite also true? That is if we know that a problem L is reducible to SAT in polynomial time, can it be also stated that it must be in NP? $L ...
If all problems in NP are polynomially reducible to SAT (Cook & Levin) can one also assume that all to SAT polynomially reducible problems are in NP?
|complexity-theory|computability|
Let us say I have an empty graph `G` and a list of nodes `N` to add to the graph one-by-one. Let us say that I will have a node `X` that I do not yet know, but will know after I construct my graph `G`. My ultimate goal is to find the shortest distance from each node `N` to `X`, in the weighted graph `G` (For some conte...
From Cook & Levin's theorem we know that all Problems in NP are polynomially reducible to SAT: $ \forall_{L\in NP}: L \leq_{p}SAT$. Is the opposite also true? That is if we know that a problem L is reducible to SAT in polynomial time, can it be also stated that it must be in NP? $L \leq_{p}SAT \Rightarrow L \in ...
From Cook & Levin's theorem we know that all Problems in NP are polynomially reducible to SAT: $ \forall_{L\in NP}: L \leq_{p}SAT$. Is the opposite also true? That is if we know that a language L is reducible to SAT in polynomial time, can it be also stated that it must be in NP? $L \leq_{p}SAT \Rightarrow L \in...
Similar to the classic 2D strip packing problem, we want to put N blocks into a 2d strip and minimize the height of the strip. Each block has to be put at the **fixed x-coordinate**. **The width and height of all blocks are integer**. Below is an example of 4 blocks: <img src="https://i.stack.imgur.com/VLIeJ.png"...
strip packing problem with fixed x-coordinate
|optimization|packing|memory-allocation|
null
Following this blog post about the [Arc Consistency algorithms](https://www.boristhebrave.com/2021/08/30/arc-consistency-explained/). Namely, the explanation on AC4. Consider the following example: [![enter image description here][1]][1] If I understand AC problems correctly. Then: * We have two known variabl...
Understanding Arc Consistency 4 in the context of Wave Function Collapse
|graphs|constraint-satisfaction|constraint-programming|
Yes, this is true. More generally, if $A \le_p B$ and $B \in \mathbf{NP}$, then $A \in \mathbf{NP}$. (Most intro theory textbooks include a proof of this result.) In fact, one way of defining what the class $\mathbf{NP}$ is is as “the class of all decision problems that polynomial-time reduce to $SAT$.”
Given a pointer to a node in a double linked list, getting a pointer to the previous node is constant time. That’s the whole purpose of double linked lists. “Answers on the web” claiming O(n) will be answering some other question. Like the same question for a single linked list. Or finding a node.
Yes, it is true, and to get a feeling for why it is so, we can appreciate the fact that a reduction is just an algorithm (in this case, a poly-time algorithm) that transforms instances of one problem into instances of another. So, given a string $x$, one way to check if $x \in L$ is to run the reduction to SAT (in p...
This is solvable in polynomial time. Here is a polynomial-time (but not necessarily very efficient) algorithm that solves it. We will solve the following related problem: given a threshold $t$, is there an assignment of 2 items per person such that every person gets total value at least $t$? By binary searching for ...
{"Voters":[{"Id":20294,"DisplayName":"jschnei"}],"DeleteType":1}
I think this is the same as the [register allocation](https://en.wikipedia.org/wiki/Register_allocation) problem, so I would guess that you might be able to use the same techniques.
The case of 2 items per person is also NP-hard, also by reduction from the 3-partition problem. Consider the case where each person $i \in [n]$ has a "value score" $v_i$, each item $j$ has a "value score" $w_j \in [2n]$, and the value person $i$ has for items $j$ is $v_i/2 + w_j$. In particular, the total value per...
{"Voters":[{"Id":20294,"DisplayName":"jschnei"}]}
I am currently reading 'Designing Data Intensive Applications' by Kleppman. In the SSTables and LSM Trees section, it is mentioned that one of the advantage of SSTables is: "Since read requests need to scan over several key-value pairs in the requested range anyway, it is possible to group those records into a block...
In SSTables, why is it possible to group records and compress them?
|data-structures|distributed-systems|databases|storage|information-retrieval|
Given an Oracle Turing machine ($OTM$) that solves Problem π in max. 2n space, so $O(n)$ space and $O(n^2)$ time. Is there a DTM that can solve $π$ in $O(n)$ space if time doesn't matter? (The length of an instance $I$ of $π$ is n) I would say the answer is yes. Construction: We already have a DTM M', which can v...
Transform OTM for Problem π to DTM ∈ DSPACE(n)
|turing-machines|decision-problem|space-complexity|oracle-machines|proof-assistants|
Given an Oracle Turing machine ($OTM$) that solves Problem π in max. 2n space, so $O(n)$ space and $O(n^2)$ time. Is there a DTM that can solve $π$ in $O(n)$ space if time doesn't matter? (The length of an instance $I$ of $π$ is n) I would say the answer is yes. Construction: We already have a DTM M', which can v...
First, some observations: - Setting all literals in a reason set to true leads to a conflict through unit propagation. - One can replace a non-decision literal from a reason set with its in-neighbors in the implication graph without disturbing the above property. - The falsified clause $l_1 \lor \ldots \lor l_n$ tha...
It depends on the oracle. If $\pi$ is solved by the OTM using an oracle for a non-computable problem (non-decidable language), then there might not be a DTM that can solve $\pi$ without an oracle. There is no guarantee that you can verify the response from the oracle.
Suppose we have a finite set of programs, say, something like every Turing machine with 2 states and 7 symbols. After running all of them for a very long time, we've narrowed it down to a small subset thereof. Of those remaining, let's suppose that at least one will run forever and at least one will eventually halt, an...
How far out can one determine a program is halting?
|turing-machines|halting-problem|heuristics|busy-beaver|
In other words: If $A \leq_{p} B$ and $A \in NP \Rightarrow B \in NP$
If a problem A in NP is reducible in polyomial time to a problem B, can one say that B must also be in NP?
|complexity-theory|computability|
I believe I learned (and later forgot) a term for two (or more) objects/dictionaries, with the same property schema. Googling has not helped. For example, these objects are TERMs because they have all the same properties.
Term for two objects with the same properties or keys
|object-oriented|
In other words: If $A \leq_{p} B$ and $A \in NP \Rightarrow B \in NP$ From my deduction this is has to be false. We know that if $A$ is NP Complete $\Rightarrow A$ NP-Hard and $A \in NP$, then $B$ is NP-Hard but the following statement doesn't necessarily hold true: $B \in NP$. I struggle to understand why t...
In other words: If $A \leq_{p} B$ and $A \in NP \Rightarrow B \in NP$ From my deduction this is has to be false. We know that if $A$ is NP Complete $\Rightarrow A$ NP-Hard and $A \in NP$, then $B$ is NP-Hard but we can't say for sure that $B \in NP$. I struggle to understand why though.
What you are describing is indistinguishable from: 1) making a (free) copy of the Turing machine (in its current state) 2) running it for $n$ steps 3) seeing if it halted. I fail to see how this gives you any new capabilities. An analogy to your logic would be: "I can determine, what's gonna happen 10 min...
null
One rough intuition that can help you is: if $A \leq_p B$, then $A$ is "simpler than or equal to" $B$. The fact that there exists a (polynomial) reduction $A \mapsto B$ tells you that $A$ is either the same problem as $B$ or a special case of it. In this sense, $A \leq_p B$ does not tell you anything about $B$ in g...
Any $B$ such that $B$ is NP-hard but not NP-complete suffices as a counterexample. By definition, any $A\in\text{NP}$ can be reduced to such a $B$ in polynomial time. One choice for $B$ would be the Halting-Problem $H$. Clearly $H\not\in\text{NP}$, though $H$ is NP-hard.
Any $B$ such that $B$ is $\text{NP}$-hard but not $\text{NP}$-complete suffices as a counterexample. By definition, any $A\in\text{NP}$ can be reduced to such a $B$ in polynomial time. One choice for $B$ would be the Halting-Problem $H$. Clearly $H\not\in\text{NP}$, though $H$ is $\text{NP}$-hard.
Just to give you some kind of image you can use to build your intuition: Think of the problems and the complexity classes, as boxes and shipping containers of different shapes and sizes. Translate $A \leq_p B$ to "box $A$ fits into box $B$", and translate $A \in \mathrm{NP}$ to "box $A$ fits into shipping container ...
null
If you can reduce A in polynomial time to B then B might be much more difficult than A, including being much harder. It may be possible that the instances of B that you create by reducing instances of A are all in NP, but that might not be helpful.
null
If you can reduce A in polynomial time to B then B might be much more difficult than A, including being much harder. “Polynomial reduction” means if you can solve the B instance then you get a solution for the A instance, so the harder B is, the easier it will be to reduce A to B. It may be possible that the instan...
This is equivalent to the problem of finding the [chromatic number][1] of an [interval graph][2]. This can be done by a greedy algorithm (for each block, put it on the lowest level where there is room for it). [1]: https://en.m.wikipedia.org/wiki/Graph_coloring [2]: https://en.m.wikipedia.org/wiki/Interval_gr...
This is equivalent to the problem of finding the [chromatic number][1] of an [interval graph][2]. This can be done by a greedy algorithm: sort the blocks in ascending order (after left endpoint) and, for each block, put it on the lowest level where there is room for it. [1]: https://en.m.wikipedia.org/wiki/Graph...
This is a more general algorithm that computes the distance that uses at most one negative edge for all vertices. LikeBellmanFord (s) dpos[s] = 0 dneg[s] = ∞ for every vertex v≠s dpos[v] = ∞ dneg[v] = ∞ for i = 1 to |V|- 1 for every edge (x,y) if w(x,y) > 0: dpos[y] = min{...
This is a more general algorithm that computes the distance that uses at most one negative edge for all vertices. [![enter image description here][1]][1] [1]: https://i.stack.imgur.com/Unvnz.png
null
8. What will be the time complexity of the following code? ``` for(int i=0;i<n;i++){ i*=k; } ``` The answer is Log base k times n: O(Log_k * n) The underscore _ means base. The answer is read as Big O of Log base k times n The problem is from https://www.geeksforgeeks.org/practice-questions-time-complex...
Can you proof that the following code for (int i=0; i<n; i++){ i*=k; } is Big O of Log base k times n by hand/tracing the program
|time-complexity|
null
From [Natual Proofs][1] > Specifically, natural proofs prove lower bounds on the circuit complexity of boolean functions. A natural proof shows, either directly or indirectly, that a boolean function has a certain ***natural combinatorial property***. [1]: https://en.wikipedia.org/wiki/Natural_proof I haven'...
Natural combinatorial property in Natural Proofs
|complexity-theory|p-vs-np|
null
From the paper [[1][1]]: > We start by defining what we mean by a "natural combinatorial property"; natural proofs will be those that use a natural combinatorial property. > > Formally, by a combinatorial property of Boolean functions we will mean a set of Boolean functions $\{ C_n \subseteq F_n | n\in \omega\}$....
null
## General Situation Since computers use a binary system to represent data, a heavy use of powers of 2 results in easier optimizations in general. The key reason for this is that when you multiply by 2 (`0b10`[1] in binary), all you need to do is shift the bits in the number. For example, `3` is `0b011` and `6` i...
This is a more general algorithm that computes the distance that uses at most one negative edge for all vertices. ```python def LikeBellmanFord(s): dpos[s] = 0 dneg[s] = float('inf') for v in vertices: if v != s: dpos[v] = float('inf') dneg[v] = float('inf') ...
I am asking this in the context of the following question: > Let *N* be a non-deterministic Turing Machine. We say that N faces a dilemma if at some point in its working, it encounters a situation where the finite control is in the state *p*, the head scans the tape *a*, and $\delta (p, a)$ offers multiple (two or m...
Is explicitly explaining the case where the Turing Machine loops forever essential to proving reducibility?
|turing-machines|undecidability|turing-recognizable|
null
null
null
Consider our alphabet set is $\Sigma$. Suppose $L\subseteq\Sigma^*$. I want to show $L \cap L\Sigma^+=\emptyset$ as one of the bellow options: 1. $x,xy\in L\implies y=\lambda$ 2. $x,xy^2\in L\implies y=\lambda$ I think the first is true but I have no idea to show that the second is false.
Alternative to show intersection of two languages is empty
|formal-languages|
Take $\Sigma = \{a\}$ and $L = \{\lambda, a\}$. Then $L$ satisfies (2) but not (1).