instruction stringlengths 0 29.8k ⌀ |
|---|
null |
null |
null |
Both greedy and dynamic programming are algorithm design techniques, typically used to solve optimization problems. The same problem can be solved in multiple ways using various techniques, including plain old brute-force. The real question to ask is whether using one technique over the other can lead to a more efficie... |
Here is a [master's thesis](https://dspace.cvut.cz/bitstream/handle/10467/82705/F8-DP-2019-Doupal-Jakub-thesis.pdf) and an [arXiv paper](https://doi.org/10.48550/arXiv.1501.07686) on the topic, which contains some examples. |
We are given $L_1, L_2$ that belong to $RE$, hence there are TMs $M_1, M_2$ that _recognize_ the languages (not decide). To check for $x \in L_1 - L_2$ we need to recognize $x \in L_1$ and $x \notin L_2$. But due to the nature of $RE$ languages, the machine to recognize $x \notin L_2$ may run forever.
Looking at you... |
I heard hypervisors try to make this undetectable to the client .A good hypervisor will have zero latency and be transparent.
*Can a program detect whether it's running in a virtual machine by trying to create a VM underneath it (and failing)?*
Or is a VM more like a subroutine call, where the context is passed ... |
A program detecting whether it's running in a virtual machine |
|operating-systems| |
Linear programming is the very common problem of computing
$$\min_{Ax\leq b}c^\top x,$$
where $A\in\mathbb{R}^{n\times m}$, $b\in\mathbb{R}^n$, and $c\in\mathbb{R}^m$. This is an optimization problem, but it can be turned into a decision problem with an additional parameter $s$, by asking: Does a vector $x$ exist suc... |
Decision-Version of Linear Programming not in P? |
|complexity-theory|linear-programming| |
null |
I'm looking for algorithms for stacking gage blocks.
For those unaware, gage blocks are used in machine shops for measuring with high precision and come in sets something like this...
[Mitutoyo's 56 block metric set][1]
1 0.5mm block
9 blocks from 1.001mm to 1.009mm in steps of 0.001mm
9 bl... |
Algorithms for stacking gage blocks |
|algorithms|complexity-theory|dynamic-programming|graph-traversal| |
I'm looking for algorithms for stacking gage blocks.
For those unaware, gage blocks are used in machine shops for measuring with high precision and come in sets something like this...
[Mitutoyo's 56 block metric set][1]
1 0.5mm block
9 blocks from 1.001mm to 1.009mm in steps of 0.001mm
9 bl... |
From [Wikipedia](https://en.wikipedia.org/wiki/Linear_programming#History):
> The linear programming problem was first shown to be solvable in polynomial time by Leonid Khachiyan in 1979, but a larger theoretical and practical breakthrough in the field came in 1984 when Narendra Karmarkar introduced a new interior-poi... |
If you are looking for the sum of the blocks to be below the target size, you are talking about the [0/1 Knapsack problem](https://en.wikipedia.org/wiki/Knapsack_problem#0-1_knapsack_problem). In your case, it seems that all profits are unit values.
Alternatively, if you are looking for the sum of the blocks to exac... |
I believe that I have a misunderstanding in the P=NP problem while I was thinking of how can it be proved in a non-constructive manner.
We know that we can build an infinitely large text file with solutions for each of the solutions for every possible combination for that problem (in a similar manner of building a ... |
Why can't we say that P=NP if we have an infinite text file with solution for every possible SAT combination? |
|complexity-theory|p-vs-np|propositional-logic|learning-theory| |
null |
I'm currently studying the 3x3x3 rubik-cube-solving algorithms developed by Kociemba, Korf, and Thistlethwaite and I'm interested in understanding their computational complexities.
Could someone please explain or provide the Big O notation for the time complexity of these algorithms? |
I encountered this problem here: https://theory.stanford.edu/~trevisan/cs172/ps05.pdf
Consider the language
$$PFTM := \{\langle M \rangle : \text{$M$ is a Turing machine and $L(M)$ is prefix free} \}$$
where L(M) is the set of strings accepted by M.
(a) Prove that PFTM is undecidable.
(b) Is PFTM recognizabl... |
Recognizability of Prefix Free TM |
|computability|turing-recognizable| |
Recognizability of PFTM |
|formal-languages|computability|turing-recognizable| |
Consider two binary strings of two alphabets of length $l$, to find the hamming distance each corresponding bit needs to be compared. The runtime will be $O(l)$ or simply $l$ many comparisons are required. The goal is to reduce the number of comparisons with error less than $t$.
My idea is to divide input strings i... |
Fastest algorithm for approximate matching |
|algorithms|hamming-distance| |
I am going through the fourth edition of Algorithms by Sedgewick & Wayne. On page 190 there is a discussion of lower bounds for the 2-sum problem, where the 2-sum problem is stated as: *find all pairs of integers in an input array that sum to zero where each integer is distinct*.
In the lower bounds discussion it sa... |
Linear time Algorithm 2-sum (Sedgewick Textbook) |
|algorithms| |
Fastest algorithm for approximate hamming distance |
null |
To add to what Tassle said, I just tried training the AI against another copy of itself, and this produced slightly better results. I tried Increasing the number of beads taken from the matchbox on a loss (and making sure the total wouldn't fall below zero), which also helped make sure the computer wouldn't get "stuck"... |
I can't import datasets on RStudio on either my computer or Posit Cloud. I think it's because my laptop is too old to install packages necessary to import datasets on it, and not sure for Posit Cloud. Someone else imported it for me in a lab so I know it's possible, but when I try myself it seems like it only let me im... |
Can't import dataset on RStudio |
|statistics| |
The thing i'm looking for is a proof similar to this:
`A^B = (!A)B + A(!B)
= !!((!A)B) + !!(A(!B))
= !(!!A + !B) + !(!A + !!B)
= !(A + !B) + !(!A + B)
= !((A + !B)(!A + B))
= !(A(!A) + AB + (!A)(!B) + B(!B))
= !(AB + (!A)(!B))
= !(AB)(!(!A)(!B))
= !(AB)(!!A + !!B)
= !(AB... |
Can someone explain me how to build a xor gate using 5 nor gates? |
|boolean-algebra| |
The thing i'm looking for is a proof similar to this:
`A^B = (!A)B + A(!B)
= !!((!A)B) + !!(A(!B))
= !(!!A + !B) + !(!A + !!B)
= !(A + !B) + !(!A + B)
= !((A + !B)(!A + B))
= !(A(!A) + AB + (!A)(!B) + B(!B))
= !(AB + (!A)(!B))
= !(AB)(!(!A)(!B))
= !(AB)(!!A + ... |
The point is that using the PI to save a dictionary per compression source, right? Why not use a well-defined sequence of bytes as a common dictionary instead of PI and try that? I think that if this special sequence is well thought out ((by a genetic algorithm covering frequent sequences?) and is not just a permutatio... |
null |
null |
Reduction from Hamiltonian Cycle (which is just a special case of TSP anyway):
Take an unweighted graph $G$ and make into a complete weighted graph $G'$ by adding a heavy edge (say, $\ell(e) = 2n$) for every $e\not\in E(G)$, and keeping $\ell(e)=1$ for $e\in E(G)$.
For any vector $\mathbf{x}$ that is a solution t... |
That proof in fact had an error. Knuth published an erratum about it the following year [1]. See also [2] for a tutorial with a different, correct proof.
[1] [Knuth, D.E. Optimum binary search trees. Acta Informatica 1, 270 (1972)](https://doi.org/10.1007/BF00288690).
[2] https://doi.org/10.1016/S0304-3975(96)00... |
null |
I've started learning automata recently, and am struggling to figure out how to find a finite automata that satisfies the following:
Given DFA $A_1 = (Q, \Sigma, \delta, q_0, F)$, find a finite automata $A_2$ such that $L(A_2)$ = {$s | (s\cdot s) \in L(A_1)$}
Where $s\cdot s$ is the concatenation of $s$ onto itse... |
Finite Automata Based on DFA |
|automata|finite-automata| |
By extending the λ-calculus to allow for infinite λ-terms and infinite reductions. Then you may assert that both $Y f$ and $Θ f$ have $f(f(f(⋯)))$ as their normal form and, thus, that
$$Y = λf·Yf = λf·f(f(f(⋯))) = λf·Θf = Θ.$$
Going further, in fact, defining $U = λxλy·y(xy)$, we also have
$$UY = λf·UYf = λf·f(Yf) =... |
By extending the λ-calculus to allow for infinite λ-terms and infinite reductions. Then you may assert that both $Y f$ and $Θ f$ have $f(f(f(⋯)))$ as their normal form and, thus, that
$$Y = λf·Yf = λf·f(f(f(⋯))) = λf·Θf = Θ.$$
Going further, in fact, defining $U = λxλy·y(xy)$, we also have
$$UY = λf·UYf = λf·f(Yf) =... |
$U = λxλy·y(xy)$ is the fixed point of $Y$ and $Y$ is the fixed point of $U$.
How, and in what sense, I describe here:
[Equality Of (Infinitary) Lambda Terms](https://cs.stackexchange.com/questions/138768/equality-of-lambda-terms-which-do-not-have-normal-form/167344#167344). |
The standard approach is to expand the [Curry-Howard Correspondence](https://en.wikipedia.org/wiki/Curry%E2%80%93Howard_correspondence) to cover disjunctions by providing cover for the tautologies:
$$
O: (a ⊃ c) ⊃ (b ⊃ c) ⊃ a ∨ b ⊃ c,\quad : a ⊃ a ∨ b,\quad : b ⊃ a ∨ b,$$
and define $[f,g] = Ofg$, where $f: a ⊃ c$ a... |
null |
Many (but not all!) programming language implementations compile your human-readable source to some intermediate code.
The standard Java Virtual Machine (JVM), the Common Language Runtime (CLR), and many other runtimes / virtual machines require every operation in that intermediate code be be a zero-operand operand ... |
Linear programming is the very common problem of computing
$$\min_{Ax\leq b}c^\top x,$$
where $A\in\mathbb{R}^{n\times m}$, $b\in\mathbb{R}^n$, and $c\in\mathbb{R}^m$. This is an optimization problem, but it can be turned into a decision problem with an additional parameter $s$, by asking: Does a vector $x$ exist suc... |
There are many varieties of "dual-port RAM".
Even though "two-port RAM" literally means the same thing,
any one particular "dual-port RAM" may have big differences from some other "dual-port RAM".
Perhaps the most famous type is [dual-ported video RAM](https://en.wikipedia.org/wiki/Dual-ported_video_RAM), popula... |
null |
Given a composite number $P$ and two integers $x$ and $y$ such that: $x^2 = y^2 \pmod P$ we can factor $P$ using factor = $\mathrm{gcd}(P, x-y)$ or $\mathrm{gcd}(P, x+y)$.
Now are there a similar relation where we are given multiple $(x_i, y_i)$ pairs such that:
1. $(x_i^2 - y_i^2) \pmod P = r_i$ (where $r_i \neq 0... |
A query regarding factoring using difference of squares |
|algorithms| |
Given two regular languages L1 and L2 over alphabet Σ, we define the operator RQ(L1, L2) = {w | there exists a word v in L2 such that wv is in L1}. The task is to determine the smallest language class among Regular, LL, CFG, and DCFG that certainly contains RQ(L1, L2).
So, I started with the most restricted of the l... |
Finding the Smallest Language Class containing a given language definition |
|regular-languages|finite-automata|context-free|regular-expressions|parsers| |
I've started learning automata recently, and am struggling to figure out how to find a finite automaton that satisfies the following:
Given DFA $A_1 = (Q, \Sigma, \delta, q_0, F)$, find a finite automaton $A_2$ such that $$L(A_2) = \{s \mid (s\cdot s) \in L(A_1)\}$$
Where $s\cdot s$ is the concatenation of $s$ onto... |
DFA for $\{s\mid ss\in L(A)\}$ |
null |
That proof in fact had an error, in exactly the step in the induction that [your answer](https://cs.stackexchange.com/a/128455/4678) asks about. Knuth published an erratum about it the following year.
See Item 2 in [1] (copied below). See also [2] for a tutorial with a different, correct proof.
[1] [Knuth, D.E. Op... |
The question mathematically has been answered here: https://math.stackexchange.com/questions/4886084/guaranteed-graph-labyrinth-solving-sequence/4887473#4887473
To summarize, in an unknown strongly connected, directed graph in which all vertices have out-degree 2 (so from a vertex, we either go $a$ or $b$), we are p... |
Coding the labyrinth solver |
|algorithms|graphs|shortest-path|python| |
null |
Factoring using Extended difference of squares |
The question mathematically has been answered here: https://math.stackexchange.com/questions/4886084/guaranteed-graph-labyrinth-solving-sequence/4887473#4887473
To summarize, in an unknown strongly connected, directed graph in which all vertices have out-degree 2 (so from a vertex, we either go $a$ or $b$), we are p... |
null |
{"OriginalQuestionIds":[41281],"Voters":[{"Id":79440,"DisplayName":"Nathaniel"},{"Id":4287,"DisplayName":"Hendrik Jan"},{"Id":-1,"DisplayName":"Community","BindingReason":{"DuplicateApprovedByAsker":""}}]} |
Let A and B be NP-complete problems. Suppose I have established reductions from problem A to problem B and vice versa. Now, considering a specific instance (or set of instances) of problem A that can be solved efficiently in polynomial time, does this imply that the instances reduced to problem B can also be solved in ... |
Polynomial-Time Solvability Through NP-Completeness Reductions |
|algorithms|complexity-theory|np-complete|reductions| |
null |
>Starting from a vertex of an unknown, finite, strongly connected directed graph, we want to 'get out' (reach the vertex of the labyrinth called 'end'). Each vertex has two exits (edge which goes from vertex in question to an other one), one exit is labeled 'a', the other exit is labeled 'b'.
>We have limitless '... |
>Starting from a vertex of an unknown, finite, strongly connected directed graph, we want to 'get out' (reach the vertex of the labyrinth called 'end'). Each vertex has two exits (edge which goes from vertex in question to an other one), one exit is labeled 'a', the other exit is labeled 'b'.
>We have limitless '... |
I am going through various virtualization concepts, and am trying to understand their benefits.
Based on what I have read, Amazon EC2 is an example of server/hardware virtualization, and it helps us achieve high utlization of hardware. In the absence of hypervisor, we would have low utlization rate of hardware. Also... |
What benefits OS virtualization offer as opposed server virtualization? |
|operating-systems| |
The question is about closure properties of regular languages. In your question it is asked what is the family tho which the quotient $RQ(L_1, L_2) = \{ w \mid wv \in L_1 \text{ for some } v \in L_2\}$ belongs. The questions we linked to in the comments give the constructions needed for this specific case.
But let m... |
|regular-languages|finite-automata|context-free|regular-expressions| |
null |
null |
Given :
- Profit[n]: a n item array indicating the profit on a day (may be positive or negative)
- Cost[n]: a n item array indicating the cost of holding a stock on a day (always positive)
Task:
Find $1 \leq i \leq j \leq n$ that maximize Total Profit divided by Total Cost from day $i$ to day $j$.
Extensions... |
Algorithm question (Similar to Knapsack but with an order, or Stock Buy Sell with a cost parameter) |
|algorithms|knapsack-problems| |
Given :
- Profit[n]: a n item array indicating the profit on a day (may be positive or negative)
- Cost[n]: a n item array indicating the cost of holding a stock on a day (always positive)
Task:
Find $1 \leq i \leq j \leq n$ that maximize Total Profit divided by $\sqrt{\text{Total Cost}}$ from day $i$ to day $j... |
When extending the simply typed $\lambda$-calculus with products, we extend $\beta$-reduction with the rules $\pi_i \langle M_1, M_2 \rangle \to_\beta M_i$, which makes sense (cf. Sørensen, Urzyczyn, *Lectures on the Curry-Howard Isomorphism*, p. 87). But in some cases we also have the equation $\langle \pi_1 M, \pi_2 ... |
What is the significance of the equation $\langle \pi_1 M, \pi_2 M \rangle = M$ in $\lambda$-calculus? |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.