instruction stringlengths 35 29.1k |
|---|
In the world of mutable/ephemeral data structures and imperative programming languages, one of the classic ways to implement a stack or queue is to use array doubling: use mutation to fill up or empty an array, doubling or halving to expand/contract. Such stacks/queues have several nice properties:
They use at most tw... |
Problem statement Suppose I have a boolean function $f: \mathbb{F}_2^n \times \mathbb{F}_2^m \to \mathbb{F}_2$ where $\mathbb{F}_2 = \{0,1\}$.
I define two boolean functions $h: \mathbb{F}_2^n \to \mathbb{F}_2$ and $g: \mathbb{F}_2^m \to \mathbb{F}_2$ to be xor separable upper bound of $f$ if
$$f(\vec{x}, \vec{y}) \leq... |
Euclidean geometry is complete, so the problem of determining whether a statement $A$ is provable is computable. Do we know its time complexity?
|
I was reading Turing's paper on computable numbers and the Entscheidungsproblem. There is this part of Section 9, Part II that I cannot quite seem to understand. He says:
It is pretty straight forward until the part where he introduces $\mathfrak{U}$. So $\mathfrak{U}$, he says, includes the Peano axioms; but what els... |
Are there any two primes that are NOT a factor of $M$ that multiply up to $M$?
Fact: Any two primes that multiply up to $M$. Must be factors of $M$!
Thus because of the fact above an $O(1)$ algorithm exists. It always outputs $NO$
Complement
Are there any two primes that are a factor of $M$ that multiply up to $M$?
Fac... |
I was reading this article. The author talks about "The Blub Paradox". He says programming languages vary in power. That makes sense to me. For example, Python is more powerful than C/C++. But its performance is not as good as that of C/C++.
Is it always true that more powerful languages must necessarily have lesser po... |
Given language $L$, why is it not necessarily true that the number of equivalence classes of $L$ is equal to the number of equivalence classes of $L^R$?
And for the private case that $L$ is regular, is that true?
|
I was going the text Introduction to Algorithms by Cormen et. al. Where I came across a step in the analysis of the time complexity of the $BUILD-MAX-HEAP$ procedure.
The procedure is as follows:
BUILD-MAX-HEAP(A)
1 heap-size[A] <- length[A]
2 for i <- ⌊length[A]/2⌋ downto 1
3 MAX-HEAPIFY(A,i)
Now the author... |
I am currently reading this paper which shows how to calculate CRC using the instruction PCLMULQDQ. I don't quite understand the equations in it yet.
Starting with this one for the definition of crc32:
CRC (M (x)) = xdeg(P(x)) • M(x) mod P(x)
Before reading this paper, I had only ever seen CRC (M (x)) = M(x) mod P (x... |
I have a sequence of 1s and 0s. For example: $bits = [1, 0, 1, 1, 1, 0]$. I also have an array of positive integers. For example $arr = [12, 23, 4, 6, 8, 0, 24, 72]$. I need to find the index, $i$, in $arr$ of the leftmost element of $bits$ such that
$$\sum_{j = i}^{i + \textrm{length of bits}}{bits[j - i] * arr[j]}$$
... |
I am very new to the whole concept of context-free grammars to represent the syntax tree of formal languages (i.e., programming languages). It seems that the Backus–Naur form (BNF) is the oldest of all possible notations and the most prevalent one. Though it looks like to be an ancient piece of art. Now I'm wondering t... |
I am trying to find an DFA for the regular language given by the expression $L\left( aa^{\ast }\left( a+b\right) \right)$.
First simplifying $L\left( aa^{\ast }\left( a+b\right) \right)$ we get
$L\left( aa^{\ast }\left( a+b\right) \right)$ $= L\left( a\right) L\left( a^{\ast }\right) L\left( a+b\right) $
Then I constru... |
I am trying to understand average no of exchanges in Quicksort.
Here is the code to partition the array -
private static int partition(double[] a, int lo, int hi) {
int i = lo;
int j = hi + 1;
double v = a[lo];
while (true) {
// find item on lo to swap
while (l... |
I'm trying to piece together a general picture of the state of formal software verification, and I'm having a good bit of trouble. For context, I come from mostly a math background. I'm quite familiar with the state of automated theorem provers and proof assistants with respect to their use to prove well formed mathema... |
I'm a math Ph.D. having done research in Algebraic Geometry and Algebraic Topology in grad school for my thesis and I've studied a fair amount of category theory in the process (e.g. having worked through most of "Categories for the Working Mathematician" as well as more specialized topics in Homological Algebra). Is t... |
Given $S$ of positive integers $>$ $1$ is there some combination with even $SUM$ > $2$ that is NOT the sum of two primes?
$SUM$ = 10
$S$ = $[4,6]$
$No$,
Sum of Two Primes
$5 + 5 = 10$.
Combination $4+6=10$
It has an $O(1)$ algorithm if Goldbach is True (always output $NO$). Otherwise, it would seem to be NP-complete be... |
I was going through the text Introduction to Algorithms by Cormen et. al. and I came across their analysis of the worst case of the quicksort algorithm. I could not quite understand a few specific statements used by them.
I try to bring up the excerpts from the text with the portions where I face difficulty and the por... |
I was going through the text Introduction to Algorithm by Cormen et. al. where I came across an excerpt which I felt required a bit of clarification.
Now as far as I have learned that that while the Best Case and Worst Case time complexities of an algorithm arise for a certain physical input to the algorithm (say an in... |
How can i perform binary subtraction of two numbers that are already in 2's complement?
I have to subtract 01010011 from 10100110,both numbers are in 2's complement.
I know that 10100110 is -90,and 01010011 is 83,so the result should be -173.
So if i use 8 bits that means that there's overflow.
But i don't get how can ... |
This problem is not decidable (reducible to halting problem) but is semi-decidable and therefor verifiable (as those two definitions are equivalent: How to prove semi-decidable = verifiable?).
However, is this problem poly-time verifiable?
A decision problem $P$ is poly time verifiable iff there is an algorithm called... |
For some enumeration of the complexity class P (such as this as an example: How does an enumerator for machines for languages work?), for each string in the enumeration, does there exist some other string (certificate) that allows you to verify is a member of the enumeration in poly time? I believe that it might be ... |
I am intrigued: In many languages there are both normal control flow and exceptions.
But I never saw "an exception from an exception" or "an exception from an exception from an exception". Why?
Why there are just two variants?
My guess is that an "exception from an exception" would be just another class of exceptions, ... |
$L=\{\langle M,k\rangle \mid\exists w\in L(M) \text{ such that $M$ passes at least
$k>2$ distinct states before accepting $w$}\}$
I try to think of reduction to prove that this language is neither RE nor coRE.
How to approach this problem? Is there a hint, or intuition?
I usually check whether Rice can be used, but t... |
I read the question in Exercise 4.1-4 in Introduction To Algorithms:
Suppose we change the definition of the maximum-subarray problem to allow the result to be an empty subarray, where the sum of the values of an empty subarray is 0. How would you change any of the algorithms that do not allow empty subarrays to permi... |
Suppose $G$ is a $CFG$ with $m$ variables, in which the right-hand side of all production rules has length at most $\ell$. Show that if $A\Rightarrow^*_G\varepsilon$, then there is a derivation of no more than $\frac{\ell^m-1}{\ell-1}$ steps by which $A$ derives $\varepsilon$. How close to this bound can you actually c... |
Given the alphabet $\Sigma = \{1,2,\dots, n \}$ and a parameter $k$ how can we find all words of length $k$ over $\Sigma$ in lexicographic order?
I thought of doing this recursively, but although the task is basic it seems pretty hard to come up with a general algorithm, even when using the last word as a parameter usi... |
I'm faced with the following problem:
Given
Directed and unweighted graph, where each edge E has two attributes
Goal
Find every path through the 3 (or more) given edges in a specific order
Questions
Is it NP-hard?
Is there already an algorithm for this?
I was thinking about placing a node in every edge and than ru... |
I'm having a small issue with wikipedia's proof that $RP \subseteq NP$:
An alternative characterization of RP that is sometimes easier to use is the set of problems recognizable by nondeterministic Turing machines where the machine accepts if and only if at least some constant fraction of the computation paths, indepe... |
I tend to see a lot of ML/AI/DL courses everywhere. Having no background in either of these, I am confused about what to do and where to begin. I was suggested to have a look into the Stanford Andrew Ng ML course. That seems pretty outdated now. I see Python libraries being used always everywhere.
The following two cou... |
Suggest a way to augment an AVL tree to support a $O(\log n)$ implementation of the function
calculateSum(key), which receives a key of a node and returns the sum of its subtree.
I implemented it this way:
sumSubtree(node):
if node != null:
return sumSubtree(node.left) + sumSubtree(node.right) + node.key
... |
Assume for the regular knapsack problem we have additional information - maximal weight of every item - lets denote it as P. Using this information, I want to solve the problem using dynamic programming in $O(n^2P)$.
Anyone have an idea how to solve it?
|
I'm confused about where the probability from the hiring problem comes from.
For background:
We interview one person everyday who has a quality characteristic, x, from 0 to 1(distributed uniformly). We interview for n days. If on the $i^{th}$ day, person i is more qualified then all the previous candidates, then we hi... |
Given an arbitrary binary tree on $n$ nodes, choose an assignment $A$ from each parent to one of its children (the "favored child" as it were). We define the skew height of the tree as $H_A(\mathsf{nil})=0$ and $H_A(\mathsf{node}\;a\;b)=\max(H_A(a), H_A(b)+1)$ if $A(\mathsf{node}\;a\;b)=a$ is the favored child and symm... |
If $T$ is a Turing Machine that accept a language $L$, I want to define a Turing Machine $T'$ such that accepts the language $L^*$.
An approach:
$T'$ is a nondeterministic Turing Machine which has many tapes.
$T'$ 'copies' in a nondeterministic way a prefix from the original string to another tape and then it is appli... |
I was going through the text Introduction to Algorithms by Cormen et. al. where there was a discussion regarding the fact that finding the minimum of a set of $n$ (distinct) elements with $n-1$ comparisons is optimal as we cannot do better than it, which means that we need to show that running time of algorithm which f... |
I was going through the text Introduction to Algorithms by Cormen et. al. where I came across the recurrence relation for analyzing the time complexity of the linear SELECT algorithm and I felt that few things probably mismatch with respect to the range of $n$, the input size for which $T(n)$ is assumes $O(1)$ and $cn$... |
Most standard works on random graphs focus on $G_{n,p}$ and random regular graphs. However, such models are far from a good abstraction to describe the types of networks that one typically encounters in the real world.
There are several simple models that mimic the behavior of real-world graphs, sometimes called Comple... |
Regular expressions in the sense as equivalent to regular (Chomsky type 3) languages know concatenation xy, alternation (x|y), and the Kleenee star x*.
"Real-life" regular expressions as used in programming usually have a lot more operations available; amongst others, quantification x{n}, negation [^x], positive and ne... |
I would like to prove in Haskell, whether in vanilla Haskell or using some libraries / tools, some simple theorems such as:
and [n*(n+1)/2 == sum [0..n] | n <- [0..]]
Is there a simple enough (ie. fully automated) way to prove such theorems involving integers in Haskell? I am not really interested in the proof itself,... |
I have calculated the boolean functions for $r$ and $f$:
$f = \overline{s_1} \cdot s_0 + s_1 \cdot \overline{s_0}$.
$r = \overline{s_0 \cdot s_1 \cdot s_2 \cdot s_3}$.
Do you have an idea what an application for this circuit can be? I don't know where we would use it.
|
I'm trying to solve the contiguous subarray problem on CodeSignal & I came up with the following solution which is based off of Kadane's Algorithm. My implementation passed the given test data set however upon submission, it failed. There's no reason given on CodeSignal & I can't look at it since I just started doing i... |
I am referring to the definition of the minimum vertex cover problem from the book Approximation Algorithms by Vijay V. Vazirani (page 23):
Is the size of the minimum vertex cover in $G$ at most $k$?
and right after this definition, the author states that this problem is in NP.
My question: What would be a yes certif... |
I'm trying to find an algorithm that can find the lengths of simple cycles in an undirected graph in parallel that benefits strongly enough from it's parallelization to be practically more efficient than what I'm currently using to find simple cycles in an undirected graph.
Basically if a graph has n nodes, I need to k... |
While going through the official documentation SHA algorithms from NIST here.
There is a choice and Majority function used.
Maj(,,)=(∧)⊕(∧)⊕(∧)
Ch(,,)=(∧)⊕(¬∧)
Can I use Ch (or Maj) function in a simplified version?
eg:
(x^y)⊕(¬∧)
=(x^y)^ ¬(¬∧) + ¬(x^y)^ (¬∧)
=(x^y)^(x + ¬z) + (¬x + ¬y)^ (¬∧)
can be further simplified ... |
While reading the classic text Introduction to Algorithms by Cormen et. al. I came across the following claim:
Sets are as fundamental to computer science as they are to mathematics. Whereas mathematical sets are unchanging, the sets manipulated by algorithms can grow, shrink, or otherwise change over time. We call su... |
Suppose I have a matrix with entries either $x$ or $y$, where the number of rows = number of columns = $n$. If I want to select/circle $n$ entries such that for each row, only exactly one is circled, for each column, also exactly one is circled, and such that all entries circled are only $x$ (if such a circling of entr... |
By unrolling the recursion,
\begin{equation*}
\begin{split}
T(n) &= T(\sqrt{n}) + 3 = T(n^{\frac{1}{2}}) + 3 \\
&= (T(n^{\frac{1}{4}})+3) +3 = T(n^{\frac{1}{4}}) +6 \\
&= (T(n^{\frac{1}{8}})+3) + 6 = T(n^{\frac{1}{8}}) +9 \\
\end{split}
\end{equation*}
Claim: $T(n) = T(n^{\frac{1}{2^k}}) + 3 \cdot k$
Base ... |
Problem Statement:
Suppose that I have a $0-1$ matrix $A$ (all of the entries are $0$ or $1$). I wish to find the tightest upper bound with $k$ many unique rows. To be more precise, let S denote the set of $0-1$ matrices $B$ such that it only has $k$ unique rows, $A_{ij} \leq B_{ij}$ for all $i$ and $j$.
Find
$$\min_{B... |
I have a multi-objective linear programming problem of the form Ax = b, where A is a matrix and x and b are vectors. x is known, and I'm looking to minimise each row of b by solving for A.
Constraints are:
Each column of A must add up to 1.
A will start with some values being 0, and those must remain 0. In other word... |
My question is whether a specific decision problem is in P or not. It's straightforwardly in NP. The decision problem is a specific case of the general $k$-color leapfrog problem.
I can already show that when $k=1$, the problem is in P. And when $k$ is unlimited, the problem is NP-complete. I have not been able to find... |
I am having trouble figuring out how to solve this recurrence problem...
$$
\begin{aligned}
&4T(n/2) + n \\
= &4(4T(n/4) + n/4) + n \\
= &16T(n/4) + 2n \\
= &4^kT(n/2^k) + kn
\end{aligned}
$$
I lose the trail here and I cannot figure out how to finish it and actually find the complexity. Can anyone help? How can this ... |
Consider the language $$L = \{ x \in \{0,1\}^* \mid |x| = 3 \}.$$
I think the above language is regular. A DFA can be used to determine the above language.
Am I correct? Is the above language regular?
If this language $L$ is regular, then it should satisfy the pumping lemma. Then there exist $w = xyz$, where $xy^nz \... |
I am given that $Z$ is independent of $(X,U)$, where $Z$ and $X$ are binary random variables while $U$ is an arbitrary random variable. I need to prove the following:
$$ H(X\oplus Z|U) \geq H(X|U)$$
Am I doing this right?:
$$ H(X\oplus Z|U) - H(X\oplus Z|U,Z) + H(X\oplus Z|U,Z) - H(X|U)$$
$$ H(X\oplus Z|U) - H(X\oplus ... |
So i'm currently reading a lot of things about graph NP-complete problems, and it seems that the goal of a lot of researchers is to find new results about their complexity, results like "independent set is 1.593 approximable for graphs which doesn't contains K4 K5 P3 as a minor" (this is probably a wrong result i just ... |
I have the following complexity equation: $T(n)=T(n-i)+T(n-(\frac{n}{m}-i))$ with the base case $T(m)=1$.
Is it possible to calculate a big $O$ approximation for such equation? What is the right method to do so?
Edit:
I actually need to calculate this equation for any $1\leq{i}<\frac{n}{m}$
so if it is easier to consid... |
independent problem is: there is a simple and undirected graph, we are looking for the maximum vertex in which there is no edge between any two of them.
cluster problem is: there is a simple and undirected graph, we are looking for the maximum number of the vertex in which there are proximity every two vertexes ( there... |
I have a simple script to calculate gaps in a sequence of digits of the square root of 2 (or any other multi-precision constant).
As input, I generated files with the bigfloat module in Python:
from bigfloat import sqrt, precision
MAX_PRECISION_BITS: int = 1 << 30
CONSTANT = 2
precision_bits: int = 8
while precision_... |
Problem. Given $X$ a finite metric space of cardinality $n$, construct a data structure in subquadratic time such that the query distance to the kth nearest neighbor of x can be resolved in sublinear time (independent of $k$) for arbitrary $k \leq n$ and $x \in X$.
What I have tried. I am aware of the existence of kdt... |
Given an infinite set $S \subseteq \mathbb{N}$, define the language:
$L_S = \{ \langle M \rangle : M $ is a deterministic TM that does not halt on $\epsilon$, or, $T_M \in S\}$
where $T_M$ is the number of steps that $M$ takes until it halts with the empty word $\epsilon$ as input (or $\infty$ if it doesn't halt).
Wha... |
I'm having troubles understanding two things from some notes about Uniform Hashing.
Here's the copy-pasted part of the notes:
Let us first argue by a counting argument why the uniformity property,
we required to good hash functions, is computationally hard to
guarantee. Recall that we are interested in hash functions ... |
I have this first task:
You have a set of numbers $S =\{ \dots \}$ of length $n$.
And a number $k$.
Both $n$ and $k$ are powers of $2$ and: $1 < k < n$
Your task is to write an algorithm (pseudo-code) that splits $S$ into $k$ sets (which have the same length each): $S_1 , S_2 , \dots, S_k$ such that all the numbers i... |
The example in this answer proves the fact familiar to CS students - that the "big-O" is not a total order. However, most algorithm running times analyzed using big-Oh notation are not expressed in piecewise form like this example. In fact, most algorithms I am familiar with have a running time expressed in terms of po... |
I can easily define a class that corresponds to the notion of a "monoidal structure" on a type M via
Definition associative {X:Type} (f : X -> X -> X) : Prop := forall x y z:X, f (f x y) z = f x (f y z).
Definition opId {X:Type} (f : X -> X -> X) (e : X) : Prop := forall x:X, f e x = x /\ f x e = x.
Class Monoid (M:... |
It is known that recognizing a unit disk graph is NP-hard [1].
However, the paper does not mention how hard the realization problem is.
I have looked up several references [2][3][4]. None of the papers answer whether the following problem is NP-hard:
Given a unit disk graph $G = (V,E)$, find a configuration of a set
$... |
I've been thinking about a division problem for groups that I haven't found a dynamic programming solution and I'm trying to analyze the complexity of the problem.
There is a set of $n$ positive numbers ($S$), a vector of group sizes (let's call it $Sizes$), and a parameter $Y$. Find a way for divide the $n$ numbers in... |
I am working on a project to convert equations to LaTeX code. After segmenting out the characters, I got stuck on the detection part and was looking for some pre-trained model that could detect characters of the equation for later conversion to LaTeX. Is there any such pre-trained model available on the internet that c... |
Disclaimer: I am just an undergraduate student so my exposure to a lot of things is certainly limited.
I am not sure about the actual popularity of the idea that consciousness is a computation but my impression is that it is very widespread. I lost count to how many times I saw, sometimes very serious scientists, claim... |
My problem is this:
Let's say I have an arbitrary list of integers A[2013, 54, 3, 32 1, 23...]
What is the best strategy to find which of those numbers I should add together to have a sum equal or closest to a given number ?
Obviously there is always the brute force method but I'm interested in knowing if there is a mo... |
Let $T \subseteq \Sigma^* \times \Sigma^*$ be a regular (rational) relation. We define the obligatory rewrite relation over $T$ as follows:
$$
R^{obl}(T) := N(T) \cdot (T \cdot N(T))^*
$$
$$
N(T) := Id(\Sigma^* \setminus (\Sigma^* \cdot dom(T) \cdot \Sigma^*)) \cup \{ \langle \epsilon, \epsilon \rangle \}
$$
$N(T)$ is... |
Let $L_1, L_2,...$ and $L=\cap_{k=1}^{\infty}L_k$ be languages over $\Sigma ^{*}$.
Prove /Disprove: if $\forall k\in \mathbb{N} $, $L_k$ is a regular language, then $L$ is a context-free language.
I know that statement is false, but couldn't find an example to disprove it.
Would appreciate your help:)
|
Consider the language $A=\{(\phi_1, \phi_2) | \phi_1 \in SAT, \phi_2\in \overline{SAT} \}$. What is the smallest class that $A$ is known to belong to?
Apparently, the answer is $\Pi_2$, although I thought it was $NP \cap coNP$, since if we have a non-deterministic machine $M_1$ that decides $SAT$ and another non-deter... |
I'm working on a research project where I have to pair up entities together and analyze outcomes. Normally, without constraints on how the entities can be paired, I could easily select one random entity pair, remove it from the pool, then randomly select the next entity pair.
That would be like creating a random sample... |
What part of the CPU communicates with all the other parts of the processor and makes the processor faster by containing frequently used data or instructions?
|
I'm asking for problems for which we know there exists a solution for which an equivalent parallel program cannot be written on a Turing machine.
Alternatively, have we proven the opposite to be true - that for every problem, there exists at least one parallelizable solution?
|
I was going through the text Introduction to Algorithms by Cormen et. al. where I came across the following statement:
If the keys are known to be random real numbers $k$ independently and uniformly distributed in the range $0 \leq k < 1$ , the hash function
$$h(k) = \lfloor km \rfloor$$
satisfies the condition of sim... |
I have an assignment to envision and calculate the possible effects the implementation of a general sorting algorithm that is O(n) time and O(1) space ( assuming general case ) would have on computation and society.
In order to do that, I am trying to estimate how much computation time computers in server farms spend o... |
I was going throught the text Introduction to Algorithm by Cormen et. al. where I came across the two alternative definitions of Universal Class of Hash Function.
The versions are as follows:
Definition 1: Let $\mathscr{H}$ be a finite collection of hash functions that map a given universe $U$ of keys into the range $... |
I have come across the following problem and I would love for your thoughts on an optimal solution or approximate calculations worth trying.
The formulation of the problem in the form of graph theory:
Given a weighted graph $G=(V, E)$. In addition, we have $C$ colors and $f([C_1, ...C_n])$ the distribution function of ... |
I was going through the text Introduction to Algorithms by Cormen et. al. where I came across the following excerpt regarding the said proof and the steps where I felt difficulty are marked with $\dagger$ and $\dagger\dagger$ respectively.
Designing a universal class of hash functions
$p$ is a prime number large enough... |
A non-deterministic finite automaton is considered to be halted when either the whole input string has been consumed or when we reach a state where no available transition (if any) matches the current character being read.
If the machine halts when it's in an accepted state and at the same time the whole input has been... |
Say you have a neural net that is being trained using back propagation and you are using relu activation. Say the input to a node is a weighted sum of the previous layer with a bias term and say for a particular data point, this weighted sum plus bias is negative. Then relu returns 0. Notice the change in the loss as a... |
In Sections 5.1 of The Design of Approximation Algorithms by Williamson and Shmoys, they describe a basic randomized algorithm for MAX SAT and how to derandomize it. The algorithm is just to assign each variable 1 (true) with probability 1/2 and 0 (false) with probability 1/2. In other words, sample uniformly at random... |
I read on en.Wikipedia that "Big-endian systems store the most significant byte of a word at the smallest memory address and the least significant byte at the largest. A little-endian system, in contrast, stores the least-significant byte at the smallest address."
But I don't know what is "the smallest memory address",... |
I am given a graph $G = (V, E)$ with $N$ connected components and $G^\prime = (V^\prime, E^\prime)$, where for each $v \in V$ there is $v_1, v_2 \in V^\prime$ and for each $(u, v) \in E$ there is $(u_1, v_2), (u_2, v_1) \in E^\prime$.
I need to prove:
$$G^\prime \textrm{ has 2N connected components} \Leftrightarrow G \... |
How to prove that every regular subset of $L=\{a^nb^n \mid n\ge0 \}$ is finite?
I know that every finite language is regular, and it's not true that every regular language is finite.
I also know that $a^n b^n$ is non-regular language.
I can find examples of finite regular subsets of $L$, for example $\{\epsilon, ab, aa... |
A friend of mine is studying business analytics, currently on the topic for Microsoft DAX, but he is very new to the technological field. He mentioned yesterday, during a conversation, the term "sideways recursion". Does anyone have idea what that means? I know a regular recursion(maybe direct recursion is the more pro... |
Linear Time Logic (LTL) is used for system verification. In my case, I am investing some time, to see the feasibility of using LTL this time to enforce a constraint on a stream of data. Enough of generalities, let's take a simple example:
The operator UNTIL in the expression u Until v in LTL means, event u until v, it ... |
How to simplify this context-free grammar into a similar one with no unit productions and no useless symbols?
$$
S \to ABA \\ A \to aAA \mid aBC \mid bB \\ B \to A \mid bB \mid Cb \\ C \to CC \mid cC
$$
Can the simplification result in this CFG?
$$
S \to ABA \\ A \to aAA \\ A \to Bb \\ B \to b
$$
|
How would you convert the following formal definition of deterministic pushdown automata into non deterministic ?
Deterministic PDAs In general terms, a deterministic PDA is one in
which there is at most one possible transition from any state based on
the current input. Formally, a deterministic PDA is a PDA where:
fo... |
In the reference below, a 1-sparse recovery algorithm over a vector $a \in R^n$ is defined as follows. My question is why do we need the modulus (i.e. $x \mod p$)?
Algorithm:
Keep track of
$$
\begin{split}
w_1 &= \sum a_i \\
w_2 &= \sum i a_i \\
w_3 &= \sum a_i z^i \mod p
\end{split}
$$
Test if
$$
... |
I read the following claim:
$PSPACE^{SAT}=PSPACE$
$EXP^{SAT}$ is not necessarily the same as $EXP$
The first claim makes sense; $PSPACE \subseteq PSPACE^{SAT}$ trivially, and for any language $B \in PSPACE^{SAT}$ decided by an oracle machine $M_B$, we can define a non-deterministic machine $M'_B$ that works like $M_B... |
How to remove null production and simply the grammar?
$$
S \to a \mid Ab \mid aBa \\ A \to b \mid \epsilon \\ B \to b \mid A
$$
Can the simplification result in this CFG?
$$
S \to a \mid aBa \\ A \to b \\ B \to b
$$
|
I was solving the recurrence using Recursion tree method:
$$ T(n) = T(n - a) + T(a) + cn$$
When I started solving I could easily conclude the fact that $T(a)$ would have total cost computation in the form of:
$$h*ca$$
But I could not figure out on how to solve the base case.
I know that $T(n-a)$ would be at base case w... |
According to Wikipedia https://en.wikipedia.org/wiki/RP_(complexity), $P \ne NP$ implies that $RP$ is a strict subset of $NP$. Does anybody have a reference?
Furthermore, am I correct that if this indeed the case, then $NP-COMPLETE \cap RP = \emptyset$ since we can use $NP$ completeness to solve all other $NP$ problems... |
Given the following language -
$L=\left\{\left\langle M_{1}, M_{2}\right\rangle \mid\left\langle M_{1}\right\rangle \notin L\left(M_{2}\right) \vee\left\langle M_{2}\right\rangle \notin L\left(M_{1}\right) \text { and are TM } M_{1}, M_{2}\right\}$
I know it's in CO-RE but why this is not a good acceptor for the above ... |
I have to prove that the language $L_2:=${$<M>$|$L(M)=\overline{A_TM}$} is (un-)decidable. In a previous assignment we proved that $L_1:=${$<M>$|$L(M)=A_TM$} is undecidable.
I would say that $L_1$ is decidable because we can build a decider S.
S="on input w": (rough outlined)
breadth first search
(a) if no accept stat... |
For example, given a cron schedule such as: 0 * 1 7 6 and a time span, like the next year, can you directly compute the number of times the schedule will fire? It can be brute forced pretty trivially but I'd like to use this to sort a list so I'd rather not just brute force it. It's pretty easy to compute the trivial c... |
The following is an NP-Complete problem:
Suppose you have a collection $\mathcal{C}$ of sets, so that $A_i\in \mathcal{C}$ and $A_i$ is some set--we can suppose the elements of $A_i$ are integers. We want some $k$ integers, say $X \subseteq \bigcup_{A_i\in \mathcal{C}}A_i$ where $X$ has $k$ elements, and subject to t... |
We are given a set of $n$ points on the plane $a_i = \{x^a_i, y^a_i\}$ and $b_i = \{x^b_i, y^b_i\}$.
Assume that the points b are an affine transform of the points a, we can find a matrix $M$ and vector $t$ such that $\sum_{i=0}^{n-1} ||M a_i + t - b_i ||^2$ is minimized, in fact, we can even do so analytically.
Assume... |
I want to know if finding solution to a specific number of 2SAT equations sepearted by OR gate (DNF form as below) is in P or NP.
The equation has total n variables and each clause is a 2SAT equation in itself in a subset of variables from 1 to n.
Example:
F = [(x1 || x2 ) && ( !x2 || x3) && (x3 || x4)] || [(x2 || x5) ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.