instruction stringlengths 35 29.1k |
|---|
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 the slo... |
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?
|
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 (was... |
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 stating
NP is the set of decision problems for which the problem instances, where the answer is "yes", have... |
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
|
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 minimum ... |
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 out.
My ... |
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.
Example... |
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 instance, we ... |
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 ... |
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 there are to functions train_short_memory and train_long_memory. train_... |
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 ... |
I have the two following questions:
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)
I have this simple randomized algorithm for approximating the MAX-SAT problem:
The algorithm sets each vari... |
$T(n)=5T(n/3)+n^2$ Consider this to be the running time of a program. How could we interpret
then numbers 5 and 3.
My Thoughts:
5 times will mean that the problem is divided into 5 subproblems each of size n/3
and then probably to get the solution to the main problem it required $n^2$ steps
I am not sure if that is a p... |
Suppose we are given $n$ points on the real line, where each point is colored with a color from set $C=\{c_1,c_2,\ldots,c_k\}$ that contains $k$ distinct colors. We try to cover the $k$ distinct colors with as few unit length intervals as possible.
I think this problem is NP-hard and we can reduce from set cover proble... |
I have seen the solution to the knapsack problem and understand it. But I am trying to
come up with a dynamic programming solution to the following problem, which is a modified
a version of the knapsack.
Consider a store with n boxes, each containing m items, and we could only choose one
item out of each box, and the ... |
If
int a = 250;
int b = 3;
int c = (a + b/2)/b * b;
Why doesn't c equal 251, but rather 249?
How is it that c is smaller than a when we are adding?
Doesn't the divide by b and multiply by b cancel out?
I thought c= int(250+1.5)=251
|
I dont know if this is any important IRL, but I am trying to understand lines below.
4K words of main memory (this implies 12 bits per address).
4M X 16 means the memory is 4M long (4M = $2^2 \times
2^{20} = 2^{22}$ words) and it is
16 bits wide (each word is 16 bits).
So, how bits per address is really calculated... |
Let $A$ be an array sorted in non-increasing order. Let $m$ be a natural number. For example, let $m = 10$. We want to find the index $i$ such that $A[:i]$ contain elements less than or equal to $m$, whereas $A[i:]$ contain elements strictly greater than $m$.
We can easily do this using binary search in logarithmic tim... |
If I rememeber right, I read somewhere that $NP\subseteq coNP/poly$ is the same as $coNP\subseteq NP/poly$. Is this true? If yes, is there a relatively simple proof for this?
Definitions
Class $NP/poly$.
We say that a language $L$ belongs to the complexity class $NP/poly$ if there is a Turing machine $M$ and a sequence... |
I wonder if there is an algorithm which takes multiple (source,target) pairs and a max_depth parameter and returns all or some of the paths found with those pairs?
Thinking of Dijkstra's algorithm, it would start from each start node and then in each iteration it would also check other pairs' tables to see if there is ... |
I'm having problems determining the productions for a CFG describing the language $L=\{ a^nb^m | n \le m+3 \}$
where $n,m \ge 0$
I'm very new to this so this example might be a little harder, but everything I try I end up not finding the correct solutions. Some example strings are $\epsilon$, $a$, $aa$, $aaa$, $b$, $ab... |
Is it possible to create an union of two context-free grammars? I found a PDF material from the university of Iowa where they claim that it's possible but I just don't know how. They had that for grammar G1:
$S_1 \rightarrow 0S_11 | \epsilon$
and for grammar G2
$S_2 \rightarrow 1S_20$
Now they created a union by doing:... |
In the problem of pair-sum we are given a multiset $A$ and a number $\alpha$. We are asked to find whether there is a pair ($2$ numbers) of $A$ s.t. their sum is $\alpha$. Here all numbers are small/constant, $O(1)$, sum of $2$ small numbers requires $O(1)$ actions and their size is $O(1)$ bits for representation.
I'd ... |
I've started with thinking of a bucket sort/radix sort variation, only to be disproved by a colleague.
Here's the problem:
Given an array with $k$ distinct elements, it is known that the
smallest element appears once, the 2nd smallest element appears twice,
the 3rd smallest element appears 4 times, the 4th smallest ap... |
a friend sent me a question where we're given language $L$ and its subset $E(L)$ such that:
$$E(L)=\{E(w)\ |\ w\in L\}\\\text{such that}\\
E(w)=\{w_{even}=\sigma_2\sigma_4\dots\ |\ w=\sigma_1\sigma_2\dots\sigma_{n-1}\sigma_n\}$$
We need to prove that if $L\in P$ then $E(L)\in NP$.
My Question: I'm finding it somehow ha... |
I am wondering if there is an "official" name for a directed graph where we cannot re-enter a vertex once we leave it to a different vertex. Here's an example of one such graph, where once you leave a given vertex to a different one, there is no way to come back to the same vertex.
I encounter these type of graphs fre... |
You are going on a trip from point $s$ to point $f$, in the way there
are $n$ hotels, $p_1, p_2,..., p_n$ each denotes the number of $km$
from $s$. You must complete the trip by at most $t$ days ($t<n$) while
stopping at one of the hotels each night. The cost of each day is
$d^2$, where $d$ is the number of $km$ trave... |
I need to find the production rules for the following language:
$L = \{u \in \{a, b\}^* \mid |u|_a = |u|_b\}$
Well, the first thing I could come up with is
$S \to aSb | \epsilon$
But this only covers the situation where all symbols $a$ precede $b$.So I tried to add all rules containing only one symbol of $a$, $b$, and ... |
I am learning complexity theory with a background in mathematics, and I want to better understand why certain reductions are polynomial-time computable.
Let me give two examples of my worries.
Example 1: The Cook–Levin reduction.
In the proof of the Cook–Levin theorem (say in Arora–Barak or Sipser),
given a language $L... |
Say I have a bipartite graph G with vertex set A and B when |A|=|B|=n and edge set E. Then how do I determine whether the graph has unique matching efficiently. I am not sure but the permanent of adjacency matrix will give the number of perfect matching. But it will take O(n^3) can it be done in O(n+e) if not what is t... |
By other words, can anyone explain how indirect addressing works?
I red MARIE's LoadI X over and over and still didnt understand the logic behind it.
LoadI X loads the value which is stored at address of the address X into the AC
Thanks for any answer.
|
This question is about the second frequency algorithm described in N. Alon, T. Matias, and M. Szegedy The space complexity of approximating the frequency moments. Specifically, I am asking about the stochastic algorithm for the second moment.
It seems its usage it very much limited. The storage required is proportiona... |
Given a Boolean formula over $n$ variables in CNF and a partial assignment to it, all the algorithms I can think of to evaluate the assignment run in time $\Theta(n^2)$. Is it possible to do it in $O(n)$? I'd say no, because otherwise SAT would be in NTIME(n) and we know that P is different from NTIME(n), but maybe thi... |
My question is motivated by this one
I am looking for a reference in which the definition of an $f$-speedup is provided.
Let's assume that we have an algorithmic problem to solve. This problem takes an integer $n$ as input to describe it and provides as output a bit string providing the answer we are expecting.
Then, I... |
We know that $3SAT \in NP$,
and the definition of $NP$ is as follows:
$NP$ is the class of languages that have polynomial time verifiers.
But I have a question:
what does input mean for the $3SAT$ question? Is it the number of variables $n$ or the number of clauses $m$,
Let's take an example, given a CNF expression, ... |
I've already posted in the Math StackExchange section, but nobody answered.
I’m wondering if, given a planar graph $G$ And two vertices $v,u$, is there an efficient algorithm to know if adding the edge $(v,u)$ to $G$ makes the graph non-planar?
I’m thinking something that runs in $O(1)$ for every query, even if it need... |
I am trying to find an algorithmic solution to a thought experiment that occurred to me recently. Please excuse me if the question is a bit naïve as I am not a CS expert.
Basically I have a tree with $n$ nodes, each of which is assigned a numeric label $l\in\{0,\ldots,k\}$, $k\in\mathbb{Z}, k\geq0$. More than one node... |
To pop an element off of a priority queue, the worst-case complexity is:
O(logN) where N is the number of elements.
Now if you do K pop operations on the priority queue, the number of elements decreases.
So the cost of these K operations would be:
O(logN) + O(log(N-1)) + O(log(N-2)) + O(log(N-3))... O(log(N-K))
How d... |
I'm currently working on an exercise that has made me ponder for a bit. The following exercise is from the 6th Edition of Data Structures and Algorithms in Java:
An inverted file is a critical data structure for implementing applications such an index of a book or a search engine. Given a document D, which can be view... |
given CFG G1 = {V1, Σ1, R1, S1} in its CNF form,
I have to define a new G5 grammar that constructs L(G5) using {V1, Σ1, R1, S1}:
while L(G5) = { x ∈ L(G1) | |x| is even }
i . e .
L(G5) composed of all even length words in L(G1)
How can I do it?
|
Let's assume I have graph above with spanning tree pointed out by blue edges.
Vertex at position (1,1) (row 1, column 1) is connected to the bottom vertex and has degree 1.
Vertex at position (4,2) (row 4, column 2) is connected to the up, left and right vertex and has degree 3.
Let's call (up, down, left, right) a de... |
Let $G$ be a flow network, where $c(e)$ is the capacity of an edge, and the source is $s$ and sink $t$. Define a node $v$ to be "source-like" if for every min-cut $(S,T)$ of $G$ where $S$ contains $s$, $S$ contains $v$. Find an efficient algorithm to determine the source-like nodes.
I was thinking that since Ford-Ful... |
I have a square n-by-n matrix of integers. The number of columns is equal to the number of rows.
Each column and row are sorted from the lowest to highest numbers. For example:
Another example:
I need an algorithm to find whether a given number is in the matrix, with a complexity of $n$ or lower.
Thanks people
|
$L=\{ w \in \{ 0,1 \} \}$ where $w$ contains at least three ones
Here is one solution for the productions:
$S \to A1A1A1A$
$A \to 1A | 0A | \epsilon$
However, now I have a question. Could I modify the second rule to be as follows:
$A \to A1 | A0 | \epsilon$
What I did was just switch the places of the non-terminals and... |
In his book The Emperor's New Mind, Roger Penrose gives an overview of Turing machines in Chapter 2. In his definition of what a Turing machine is he is very minimalist. There is a single linear tape infinite in both directions composed of cells, each of which is either blank or contains a single mark. He represents a ... |
I found a solution of exercise C-8.28 from Data Structures and Algorithms in Java (6th Edition), but I'm having trouble understanding how the for loop condition works here.
for(Position<E> c : T.children(p))
I'm having trouble understanding what the condition in the for loop means. From what I've learned so far the fo... |
A complete $k$-CNF formula on $n$ variables $(k\le n)$ is a $k$-CNF formula which contains all clauses of width $k$ or lower it implies.
Let us define the (Complete/Assign) 3-SAT problem: Given $F$, a complete 3-CNF formula on $n$ variables and $I$, a partial assignment of $l$ literals among $n$ (where $l\le n$). Let $... |
We have a Turing Machine that cannot write the same symbol it has read in a transition, meaning it should always alter the symbol when passing it. How can we prove that such machines have equal processing power compared with the standard Turing Machines?
|
Say you have the finite alphabet $\{a,b,c,d,e,f,g\}$ and an enumeration of finite strings over it by the shortlex order (length-lexicographic ordering), starting with the empty string, i.e.,
$\epsilon, a, b, c, d, e, f, g,$ $aa, ab, ac, \cdots,$ $gg, \cdots, aaa, aab, aac,$ $\cdots, ggg, \cdots$.
What's the most effici... |
I have a question about the use of calibration in neural networks and its relation to accuracy. In Guo et al. it says: "Because the parameter T does not change the maximum of the softmax function, the class prediction remains unchanged. In other words, temperature scaling does not affect the model’s accuracy."
This mak... |
I have a coding problem I'm running into that feels like it's solved:
Given a (directed) graph, and an equivalence relation on nodes, merge the equivalent nodes in a way that preserves the graph structure to create a "factor" graph, in the sense that every edge connected to one of the equivalent nodes is connected to t... |
I am trying to do some runtime analysis on a problem, but get stuck on some details.
I have a string $P$ of length $n$, where I am allowed to halve substrings inside of it and keep the right-hand side of it to form new strings. We can now halve substrings in the new string. The length of the substrings that are halved ... |
According to my syllabus, this is a dynamic programming problem yet the explanation to the problem I’m supplied with is really confusing and not close to being understandable.
The problem is such:
You are required to give change equal to n (n is a positive nonzero integer, not necessarily bigger than biggest coin) with... |
Motivation & Question
So I can theoretically build a "computer" to calculate the exact anti-derivative of a particular function.
Using classical calculations and the Robin boundary condition I show
that one calculate the anti-derivative of a function within time $2X$
(I can compute an integral below)
$$\frac{2 \alpha... |
Pipelined processors suffer from stalls due to different kind of hazards and one way of dealing with it is to implement forwarding of different types. For example ALU-ALU forwarding or full forwarding (MEM stage -> EX stage). A result of implementing forwarding in a pipelined processor is that we get an increased throu... |
Given a Min-Heap with $n$ elements.
Assume that we choose $\lceil \log_2n \rceil$ elements from the heap (not in any specific order/index's), and we subtract a value $k>0$ from all of their keys.
Suggest an algorithm to fix the min-heap that runs in $O((\log_2n)^2)$.
My thoughts:
In a min heap the key value of chi... |
I've been assigned to find the loop invariant for the following code:
i=0;
j=n-1;
while(i < n/2){
l = A[i];
r = A[j];
A[j] = l;
A[i] = r;
j = j-1;
i = i+1;
}
I understand the code function (reverses array), the guard (i < n/2), and I can find different invariants (e.g. i+j = n-1), but I'm stuck... |
$L=\{a^ib^ja^k \mid j \text{ is odd, then } k=i^2+j
;\ j \text{ is even, then } k =i+j\}$
I tried writing $L$ as the union of the language created with $j$ odd and the one with $j$ even.
When $j$ is odd, I can prove using the pumping lemma that it is not a cfl.
When $j$ is even, I can prove that it is a cfl by writing ... |
What is being summed and why?
$s'$ is the next state. Don't we just want the next state with the max value?
There is an $s'$ under the summation, so are all the possible $s'$ in $P$ and the $s'$ in $V(s')$ being summed? Or is everything to the right of the summation being summed? The $s$, the $a$, the $s'$ and the $V(s... |
I heard a few times that if we allow computations with infinite precision, we could have unrealistic powers of computation up to the point of solving NP problems efficiently.
Is it true? If yes:
what is the model of computations used to define infinitely precise arithmetic? Like do we need to assume that accessing to ... |
I would love to learn visual AI and what better way than creating a bot to play offline games. The problem is with no experience in AI other than Azure through my college, I have no experience.
Does anyone have resources that could aid in my learning or any tips for getting started? All will be appreciated.
|
Let $L$ be a context-free language. Prove that there exists integer $p>0$ such that
$ \forall z\in L $ such that $ |z|\ge p $, there exists a partition $ z=uvwxy $ such that
$|vwx|\le p$
$|vx|\geq2$
$\forall i\geq 0 : uv^iwx^iy\in L$
HINT: $p$ needs to be bounded $ p\leq 2^{2k}$ which gives you more power. What is th... |
I'm wondering if a language (A) is a decidable language and language (B) is a regular language, is the intersection between A and B regular?
|
I'm looking for a book that contains the formal definition of sigma protocol (something like: A sigma protocol for a relation $R$ and a challenge space $C$ is... that satisfies the properties of soundness..., completeness..., honest verifier zero-knowledge...)
I keep finding books that gives an example of sigma protoco... |
Suppose there is an integer array $a_1,a_2,...,a_n$. Calculate the sum of average of all subarrays. For example, the sum of average of all subarrays of array $[1,3,5]$ is $1+3+5+\frac{1+3}{2}+\frac{3+5}{2}+\frac{1+3+5}{3} = 18$
I'm wondering does it exist an $O(n)$ algorithm?
|
Is it better to think about tokens from right to left and perform right factoring on grammar for an LR(1) parser? As apposed to thinking about tokens left to right and doing left factoring on grammar for an LL(1) parser.
Example java import statement.
S1 -> S2 ;
S2 -> S5
S2 -> S3 id
S2 -> S4 *
S3 -> S5 as
S4 -> S5 .
S5... |
I'm trying to prove that $\mathrm{HALF}\text-\mathrm{FALSE}$ is NP-hard, where $\mathrm{HALF}\text-\mathrm{FALSE}$ is the following problem:
given a boolean formula $\phi(x_1,\dots,x_n)$, is there a satisfying assignament in which exactly $n/2$ variables have value false?
Now, i got the problem down if it was like th... |
$L = \{{a^{2n+1}b^{m+2}a^n | m \neq 2n}\}$
I tried to split $L$ in 2: when $m > 2n$ and $m<2n$, however both resulting languages are not context-free, so I did not find out anything about $L$.
The pumping lemma did not give any results either, because the string $a^{2p+1}b^pa^p$ for example can be pumped when $vwx$ is ... |
Let $(X_1,Y_1)$ and $(X_2,Y_2)$ be identically and independently distributed. Also consider $Z=X_1+X_2$. I am trying to prove the following inequality:
$$ H(X_2 \vert Y_1 Y_2 Z) \leq H (X_1 \vert Y_1)\leq H(Z \vert Y_1 Y_2).$$
I think I can show that middle term is the average of the other two. So now if I can show
$$... |
Suppose we have a directed, weighted graph, $G = (V, E, w)$, with non-negative weights. We define the weight of the shortest path different from the original definition.
The weight of a path with at most 5 edges (including 5) will be defined as usual, meaning the sum of the edges weights. The weight of a path with at l... |
An instance of the Dominating Set problem is given by an undirected graph
$G = (V, E)$ and an integer $k$; it is a ‘yes’-instance if there is a subset of vertices $S ⊆ V$
with $|S| ≤ k$ such that for each $v ∈ V$ we have $v ∈ S$ or $u ∈ S$ for some ${u, v} ∈ E$.
I'm trying to show that if the degree of each vertex of $... |
The problem that I'm trying to solve goes like this:
A project is split into tasks. Each task takes a known number of days. Some tasks can be done at any time(lets call these simple tasks), others depend on other tasks that must first be done. Design an algorithm that can find the minimum number of days necessary to fi... |
A standalone statement of my question
Given a program that takes no argument, we are interested in whether the program will eventually terminate. My question is this:
Theoretically speaking, can we always find a proof of the termination/non-termination of a program?
Clarification
Unlike the general halting problem, thi... |
Lets say a system has 1TB of memory and 4kB blocks. How many MB of memory do we need if we want to store a bitvector to represent the current memory allocation situation with a bitvector?
Bitvector: a string of concatenated 0s and 1s, where 0 means a block is free, 1 means it is already allocated.
The solution is given... |
I'm trying to train some linear logistic regression models and I need regularization. My models contain around 4000 features.
I know that without regularization, a good rule of thumb is to have 10x the number of data points as the number of features.
Unfortunately I have on the order of 1000 examples. With high regular... |
Is it possible to solve the maximum flow problem in the real world, ie. using water running through physical pipes? So you would have a tap at the source node, pipes of various diameter (depending on their capacity) connecting nodes and a sink at the target node. You would turn on the tap on full and then try to measur... |
I wonder if there's Digital Logic Circuit (using combinatorial logic gates) that check if number is prime or not.
For example given input fixed 8-bit that will produce 1-bit output.
00000101 will produce output 1 (1 means prime)
00000110 will produce output 0 (0 means composite).
I know it's possible if using Sequentia... |
if UTC is universal, what drawbacks does it have in using it in a distributed system to coordinate events or use it as a global objective reference clock?
isn't it right to just use UTC to timestamp every message to order messages without using lamport logical clocks!
|
I've been solving a lot of questions lately about determining the type of a given language, by type I mean whether it's regular, CFL, in P, Turing-decidable, Turing-acceptable, or all the languages. and I have this language here:
$$L=\{w:|w|\text{ is even, and it has }\frac{|w|}2\text{ consecutive 0's}\}$$
So my main p... |
In the book "Fundamentos de sistemas operativos" (Gunnar Wolf, Esteban Ruiz, Federico Bergero, Erwin Meza p.254) it says:
Al cargar un programa el sistema operativo calcula cuánta memoria va a
requerir a lo largo de su vida prevista. Esto incluye el espacio
requerido para la asignación dinámica de memoria con la famil... |
I recently started learning context free grammars and was working on a couple of exercise problems and couldn't really figure out how would this exactly look like.
I started with:
$$\begin{align}S&\to S_1S_2\\
S_1&\to aS_1\mid\epsilon\\
S_2&\to bS_2\mid\epsilon\\
\end{align}$$
But I'm not sure how to create transitions... |
I see this occasionally when solving Dynamic programming questions. I like to solve dp questions using recursion, then Memoize it based on the number of parameters I pass to the recursive function.
The question is, in my code below, even though I passed three parameters to my recursive function, the solution still work... |
Looking for an example of a LR(1) grammar that can not be turned into an LL(1) grammar that parsers the same language.
|
prove this language verifies the conclusion of the pumping lemma
show that $L=\{a^*\}\cup\{b^ja^{n^2}|0<j,1\leq n \}$
Holds the pumping lemma for context-free languages
the problem is that I know how to refute with pumping lemma that a language is not context-free.
but I don't know how to prove Language holds the p... |
What are some equations/ inequalities and properties of bitwise X-OR that can be used in competitive programming.
|
I have to show that given $f:\mathbb{N}\rightarrow\mathbb{N}$ the function that returns the number of times $6$ appears in the input (for example $f(436546)=2$) is primitive recursive.
The exercise says to assume that the functions $rem(m,n)$ and $div(m,n)$, which returns the remainder and the quotient, are recursive p... |
Definitions:
1.
$$\mathsf{NP} = \{S \: \mid \: \text{Exists a polynomial, non-deterministic algorithm $A$ s.t. $A$ decides $S$} \}$$ Where a polynomial non-deterministic algorithm, is an algorithm that it's runtime is bounded by $p$ some polynomial, and may behave differently from run to run.
$$\mathsf{P/poly} = \bigc... |
Printing an array using recursion is much slower as compared to printing an array using iteration. Why? Is iteration always faster than recursion?
|
Given a graph $G = (V, E)$ where
G is directed: $ \forall \ e \in E$ : $e$ has a direction.
G is acyclic (no cycles): $ \forall$ path $v_1, \dots , v_n : (v_n, v_1) \not\in E $.
If indegree $\gt0$, indegree $\ge$ outdegree: $ \forall \ v \in V : d^{-1}(v) \gt0\implies d^{-1}(v) \ge d^{+1}(v) $.
If indegree $=$ $0$, ou... |
Suppose i have a CNF formula. If i negate the CNF formula, then i obtain DNF formula. However, i can't find anywhere on internet that mention the time complexity. What is the time complexity of negating a CNF formula and converting it to DNF formula?
|
Generating numbers with $k$ bits set for a poker simulation
Context
I'm trying to generate all possible Texas Hold'em games for $p$ players, which means there will be at most $2 \cdot p + 5$ cards at play.
To make things a little bit easier, I figured that I could use a 64-bit number to represent each of the cards in a... |
I've learned some basics about P and NP. Please excuse if the following is not very precise.
I've read that NP-complete problems are the hardest problems in NP. (Is that correct?)
But now I'm wondering if P problems have polynomial runtime, and assuming P=NP for a moment, how can polynomial runtime problems ever have s... |
I'm struggling with this question. I would appreciate a detailed solution as it would help me better understand the subject.
Convert the following Context Free grammar into a Regular Grammar:
S -> aSb | A
A -> bA | a
|
I believe this is true and I have given a simple proof of this:
If A is Turing-reducible to B then there exists a Turing machine with oracle for B that decides A, because B is Turing-recognizable then by using the oracle for B we can decide A and therefore A is Turing recognizable.
|
I have implemented an indexed linked list that runs (under mild assumptions) all single-element operations in $\mathcal{O}(\sqrt{n})$ time. The description is here and Java implementation is here.
It’s clear to me that the running time is linear in $n$ in the worst case, but I would love to see something smarter than t... |
Assume in a distributed network, where the nodes are not trusted and are identified by their public keys, we intend to select one of them in a random process. In such a situation, all of the nodes have the same chances to be elected.
Since the system is not centralized and there is no trusted server performing the elec... |
Consider an arbitrary sequence of $m$ MAKESET operations, followed by $u$ UNION operations, followed
by $f$ FIND operations, and let $n = m + u + f$ in a disjoint set union data structure. Prove that if we use union by rank and FIND with
path compression, all $n$ operations are executed in $O(n)$ time.
I'm not sure how... |
Normally, when working with dictionaries, we expect around O(1) complexity when we go to retrieve a value given the key (and when we insert). I work in Python, but this might apply to any dynamic typed language. I have been working with dictionaries where the keys are frozensets, which are just sets that are hashable ... |
Let WALKSAT be defined as follows:
Let $σ$ be a random truth assignment to the vars
For $t = 1, 2, . . . , 3n$:
◦ If $\phi$ is satisfied by $σ$, exit the loop
◦ Else, pick an unsatisfied clause $c$ and a var $x$ in $c$ uniformly at random
◦ Flip the value of $x$ in $σ$ (e.g., $x ← TRUE$ becomes $x ← FALSE$ )
Output $σ$... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.