instruction stringlengths 35 29.1k |
|---|
If I copy a picture and paste it into Microsoft Word, would there be the difference if I embedded the same picture into another Word file ? Are they both object embedding?(As the object is saved in the document?)
|
Precondition: true
int i = 0;
while (i < a.length && a[i] != x) {
i++;
}
Postcondition: (∀ j : 0 ≤ j < i : a[j] ≠ x) ⋀ (i = a.length ∨ a[i] = x) }
As I read it, the program has no precondition to be established, thus the precondition is always true? Is it like an indicator: "This program has no precondition"?
|
I was viewing the solutions of other Leetcode users for the classic "post-order traversal of a binary tree" question, when to my surprise, I found a ton of users simply finding the reverse preorder traversal (because it is considerably easier to implement iteratively), and then reversing the output. To my further surpr... |
In Conflict-free Replicated Data Types: An Overview and other CRDT-related publications by Preguiça's group, a dot symbol often appears without definition. What does it indicate, how standard is it as notation, and what field's literature does it come from? For example:
$$\{ v \mid \mathrm{wr}(v) \in O \land \nexists \... |
I came across one Big Theta expression:
Here I am thinking this expression to be valid. But please correct me as the answer doesn't goes in the same way.
As per definition of Big Theta.. any function f(n) execution time must lie between c1g(n) (f(n) is greater than this function) and c2g(n)(f(n) is smaller than this ... |
Let's say there is a single objective optimization problem SP (e.g. a linear program) and an optimization algorithm SA for it (e.g. simplex). Then applying SA to SP yields an optimal solution s=SA(SP).
Now let's assume there is a multi objective optimization problem MP (e.g. a linear program with two linear objectives)... |
I have a list of 256-bit binary data to store. Any algorithm for doing lossless compression on it in a way I can retrieve an entry by its index without decompressing the whole data (if possible). The decompressed data will also be stored as binary. I will also need to code this algorithm ground-up in a domain-specific ... |
$A_{TM}= \{ \langle M,w\rangle \mid M$ is a TM that accepts $w\}$
$E_{TM}= \{ \langle M\rangle \mid L(M) = \emptyset \}$
The standard proof for the undecidability of $E_{TM}$ is given in this question, right?. Doesn't this automatically create a mapping reduction $f$ from $A_{TM}$ to $E_{TM}$ ? Whenever $w \in A_{TM... |
i am relatively new here, so if this was asked before, feel free to redirect me. I am searching for an answer in form of a (iterative or recursive) Formula or even better, an algorithm to list them all. But if you know the name of what i am searching for or have some strategy how i could approach this or tips for liter... |
What is the tightest lower and upper bound for the expected maximum value of k IID Binomial(n, p) random variables
I tried to derive it :
$$Pr[max \leq C] = (\sum_{i = 0}^C {n \choose i}p^i(1 - p)^i)^k$$
$$E[max] = \sum_{C = 1}^n C(pr[max \leq C] - pr[max \leq C - 1]) = \sum_{C = 1}^n c((\sum_{i = 0}^C {n \choose i}p^i... |
I have an undirected, unweighted graph $G=(V,E)$, and a function $f:V\to [0,1]$ where $[0,1]$ denotes the interval of real numbers from $0$ to $1$ inclusive.
Given an input threshold $t\in [0,1]$, I need an algorithm which returns all maximum sized connected sub-graphs $H\subseteq G$, such that every node $u\in H$ has ... |
I read an example of using cosine distance in RGB space, and it pointed out that (eg.) dark red and light red have a cosine distance (CD) of zero because CD only gives you the angle between vectors and doesn't consider length. Fair enough. I wondered if a way to fix this was by making it a four dimensional problem by a... |
let's suppose we've got a simple Recurrence Relation:
$$ T(n) = \begin{cases}
1 & n=1 \\
T(n-1) + \Theta(n) & \text{otherwise}
\end{cases}
$$
At lesson we've resolved it, but I tried two other ways of resolution, and I would like to ask you if they're right and which, among all, is the most formal way t... |
Suppose given number $k$ and undirected unweighted graph $G=(V,E)$, also given two vertices $s$ and $t$. Can we find $k$ shortest paths between $s$ and $t$ in $O(n+m)$ without term $k$?
I read this link but I can't findout the answer of my question. I think this problem can't solve in polytime.
|
Let $L$ be the set of all languages that satisfy the pumping lemma, including non-regular languages that satisfy it. Is the set $L$ closed under concatenation?
I couldn’t prove it or find a counterexample.
|
Supposed someone came up with a compression algorithm that doesn't iterate through bytes or anything to compress data, does that proves P=NP?
That is, an algorithm that doesn't rely on patterns/redundancy occurrence in data to work, but instead on some clever mathematical operations.
Such algorithm will be able to comp... |
The $y$-fast trie is a data structure for storing a sorted collection of $n$ integers from the range $[0, M)$. It builds on the $x$-fast trie, which also stores elements in this range.
The space usage of an $x$-fast trie is $O(n \log M)$ words. To reduce the space usage to $O(n)$ words, the $y$-fast trie applies a leve... |
I have received the below question for presentation. It was random assignment, its not my field. What is this specifically in Computer Architecture?
how CPU and GPU architecture, memory bandwidth/interfaces, and storage interfaces, all combine to contribute to overall computing performance?
How and where can I get th... |
I want to know the time complexity of specifically calculating ${n \choose k}$ where it is defined as
$$
{n \choose k} = \frac{n!}{k!(n-k)!}.
$$
If the factorial function is recursive $O(n)$:
def factorial(n):
if n == 0:
return 1
else:
return n * factorial(n-1)
then the time complexity would be... |
Problem statement- Given a sorted array, print out the pair of elements of the array that have a sum of K, where K is a whole number.
The solution to the above problem goes like this:
With using the Two Pointers pattern, and Pointer 1 pointing to the beginning of the array and Pointer 2 pointing to the end of the arra... |
Let $G = (V, E)$ be an undirected, connected and weighted graph.
Let also $(e_{1},\ldots , e_{|E|})$ be some sort of the edges of $G$.
Let $w, w' \colon E\rightarrow \mathbb{R}$ such that:
$$w(e_{1})<w(e_{2})< \dots < w(e_{|E|})$$
$$w'(e_{1})<w'(e_{2})< \dots < w'(e_{|E|})$$
Prove that the two MST's resulting from the... |
Given array of numbers $A[1..n]$. We search for element $x$ with linear search. Also we know that, element $x$ occurs in $A$ and probability of $x$ be in second half of the array is $3$ times of probability $x$ be in first half. What is the time complexity of linear search in average case?
Because of $x$ is in $A$, le... |
I am trying to build an algorithm to compute the partition of a set into singletons or pairs for a set of cardinality 16. I am doing it in MATLAB and came up with codes that either run forever or require more memory than available. Do you know any time and space efficient algorithm?
I have added my function below.
func... |
I've been given the question in the title:
Create a data structure that can insert a string S in O(|S|), string may belong to group A or B (or both). The structure should be able to return a string in it that the amount of lexicographic smaller string from A in the structure equals the amount of lexicographic larger st... |
Given the following family of hash functions:
$$
\mathbb{H} = \{h_c(x) = (12x + c) \bmod
m \mid c \in \mathbb{N} \},
$$
where $m$ is the key size.
Prove that $\mathbb{H}$ is not a universal family of hash functions.
So I got the following idea:
If $m = 12 $ then $H$ is not an universal family of hash functions. ... |
We have a cake of length $n$ and we have two arrays $A$ and $B$ of size $n$. The two arrays have order like below. $A[0]<A[1]<\dots <A[n]$, $B[0]>B[1]>\dots >B[n]$. We define a envyless location as a cut in the cake where it satisfies $A[i]=B[i]$. For example, $A=[1,2,3,4,5,6,7]$ and $B=[7,6,5,4,3,2,1]$, $A[3]=B[3]=4$,... |
I am really confused about this. I am trying to prove that the worst case of heap sort is Ω(nlogn) but i don't even know how to start.
|
Supose we have $n$ customers with interval that represent their range. For example, $[1,8], [2,5], [4,6], [1,9]$ for each customer. For a customer to have range coverage, a tower must be present within their range. For example, for customer $[1,8]$ to have coverage, a tower must be within range $[1,8]$. I need to make ... |
Given an array of numbers with length $n=3^k$, we try to find an
element that occurs more than $\frac{n}{3}$ times. So work as follow:
We divide the array into 3 parts of equal length. Find
recursively a candidate $x$ in each partition and do a scan on
array to find number of occurrence of each candidate and then
retu... |
Suppose given two arrays $A$ and $B$ with length $n$. Array $A$ is sorted and $B$ is unsorted. Is there any lower bound for computing $A\cup B$?
|
I read this link and I have similar question.
Suppose given two Arrays $A$ that is sorted array with length $n$ and $B$ unsorted array with length $n$. We want to find union of two arrays (i.e. we try to compute $A\cup B$) with comparison computation model. Can we claim that the lower bound of this problem is $\Omega(n... |
Consider the following proof from Papadimitriou's "On the Complexity of Integer Programming":
Corollary 1. There is a pseudopolynomial algorithm for solving m x n integer programs, with fixed m.
Proof. We can solve the m x n integer program Ax = b by dynamic programming, proceeding in stages. At the jth stage we compu... |
Savitch's Theorem states that $NSPACE\left( f \left( n \right)\right) \subseteq DSPACE\left( \left( f \left(n \right) \right)^2 \right)$ for any $f\left(n \right) \in \Omega \left( \log{n} \right)$.
The proof I am familiar with states the following: we are given a non-deterministic turing machine $N$ for our language $... |
The subset sum problem is: given a list of $n$ positive integers, and a positive number $T$, find a sub-list with largest sum that is at most $T$. The problem can be found in time polynomial in $n$ and $T$ by dynamic programming: for each integer between $1$ and $T$, record whether or not there is a subset with this su... |
Using IEEE 754 algorithm i assume, that it can be implemented in a branchless way.
But how does CPU determine special cases (Reserved Exponent values):
Exponent
Significand
is
11111111
000000000...
Inf
11111111
000001000...
NaN
00000000
000000000...
0
00000000
000001000...
Subnormal
Without any tricks... |
A chain-complete partial order (equivalently, a pointed dcpo) is a set $D$ with a partial order $\leq$ such that all chains of $D$ have a supremum. The least upper bound ($\bigsqcup$) of the empty chain is the least element $\bot$ of the CCPO.
A function $f\colon M \to N$ is monotone if for all $a, b \in M$, the follow... |
In university, I was taught the computational model hierarchy given in the following figure: https://devopedia.org/images/article/210/7090.1571152901.jpg
Essentially, Pushdown Automata (PDA) can solve more problems (i.e. recognize more languages) than Finite State Machines (FSM), Turing machines (TM) can solve more pro... |
In Agda, if I disable axiom $\mathbb{K}$ I'm not able to prove
$$
\forall\{A : \textbf{Set}\}\{a\ b : A\}\{p\ q : a \equiv b\} \to p \equiv q,
$$
which I guess is normal since the system does not truncate equalities. However, I'm still able to prove transitivity
$$
\forall \{A : \textbf{Set}\}\{a\ b\ c : A\} \to (b \eq... |
AVL trees are height balanced binary search trees. As a consequence of this balance, the height of an AVL tree is logaritmic in its number of nodes. Then, searching and updating AVL-trees can be efficiently done.
The fact that AVL-trees have logaritmic height can be shown by analyzing "minimal" AVL-trees, where for eac... |
First time posting on here; if this question is too rough I would appreciate if you could point me to a stackexchange forum where this question may be a better fit.
Generative adversarial networks (GANs), introduced here by Ian Goodfellow, are a setup to train a neural generator $G_\phi$ which is supposed to learn to g... |
I am writing a blockchain as a side project in Go and I am struggling to find good a theoretical treatise on the subject.
The information online is either too basic or too specific.
Thanks
|
Here is a dominance frontiers algorithm, mentioned on Wikipedia:
for each node b
dominance_frontier(b) := {}
for each node b
if the number of immediate predecessors of b ≥ 2
for each p in immediate predecessors of b
runner := p
while runner ≠ idom(b)
dominance_fro... |
I'm having trouble understanding lamport timestamps in practice and how they guarantee causal ordering.
Definitions
Lamport defines the "happens before" relationship in his paper. He states that an event a happens before an event b (denoted as a -> b) under the following conditions:
(1) If a and b are events in the sa... |
Let $P_1P_2...P_k$ be a page sequence that gives $n$ page faults with the optimal page replacement algorithm. Does the page sequence $P_kP_{k-1}...P_1$ give the same number of page faults. This can be proved quite easily in the case of LRU, and disproved for FIFO. Does it hold for Optimal Replacement?
|
I am given an undirected, weighted graph $G$, on its base I have to create a spanning tree with such a property that the difference between the largest edge weight and the smallest edge weight is the smallest possible.
I know how to find a minimal spanning tree, e.g. using Prim's algorithm or Kruskal's algorithm, but I... |
Given a BST $T$, $x$ is a random node in it and $y$ is the right child of $x$.
How does the PostOrder traversal of BST $T$ change after we rotate the tree left on node $x$? In which cases does the traversal not change?
My Attempt:
I've decided to draw a sketch of the sub-tree of $T$ rooted in $x$:
x
... |
Everyone knows that merge sort will continuously divide the array into halves until they are small enough to (like 2 elements per block or so) be able to be sorted quickly, hence its time complexity being (n*log n). n part being the merge and log n being the splitting part of the algorithm.
But how would the algorithm ... |
Is it possible to enumerate through all the Turing Machines that solve the same given problem? For example, we know that there exists a Turing Machine that finds a satisfying assignment given a 3SAT formula. Therefore there are infinitely many 3SAT assignment finder Turing Machines. Could we enumerate all of them? Intu... |
This MIPS code is given:
loopA: lw $t0, 0($s1) # $ array element
addu $t0, $t0, $s3 # add scalar in s3
sw $t0, 0($s1) # store result
addi $s1, $-4 # decrement pointer
bne $s1, $zero, loopA # branch if s1!=0
loopB: lw $t0, 0($s2) # $ ar... |
What is the time complexity of finding the kth smallest element of all the elements in two order statistics binary search trees? An order statistics tree is a binary search tree where the size of a subtree at each node is stored at that node. Taking the root of the first tree and trying to find the largest element not ... |
I have a hierarchical graph structure on a vertical timeline with nodes that have a fixed y coordinate. I am now looking for:
an algorithm (suggestions, any related papers, anything at all) to optimize the x of each node to reduce edge crossings (and generally increase graph readability).
One idea that I have been ex... |
Double-SAT = {: has at least two satisfying truth assignments}. Hint: reduce from SAT. Start with a formula and modify it to get a formula so that is satisfibale if and only if has at least two satisfying truth assignments. If is not satisfiable, then also needs to be unsatisfiable.
How do I the problem lies in... |
So I've boiled a certain problem I have down to the point where I have two images of (approximately) the same scale. One which contains a closed curve, and one which is a partial curve. I want to determine what rotation and translation (and possibly scale, though for now that is not required) will best map the partia... |
One definition for $P$ is the set of all languages that have a deterministic turing machine $M$ s.t. if $x\in A$ the machine accepts in polynomial time and otherwise it rejects, also in polynomial time. There is no loops, so $P\subseteq R$.
One definition for $NP$ is having a certificate and a deterministic turing mach... |
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 ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.