instruction stringlengths 0 29.8k ⌀ |
|---|
The running time of the function on an input $n$ can be expressed as: $$T(n) = T(\sqrt n) + \mathcal{O}(1)$$
which implies the running time of the function and the number of recursions differ only by a constant.
The recursions ends when $n$ has been reduced to some value $k$, where $k \le 2$. The number of recurs... |
The running time of the function on an input $n$ can be expressed as: $$T(n) = T(\sqrt n) + \mathcal{O}(1)$$
which implies the running time of the function and the number of recursion functions differ only by a constant.
The recursion ends when $n$ has been reduced to some value $k$, where $k \le 2$. The number o... |
The running time of the function on an input $n$ can be expressed as: $$T(n) = T(\sqrt n) + \mathcal{O}(1)$$
which implies the running time of the function and the number of recursions differ only by a constant.
The recursive chain ends when $n$ has been reduced to some value $k$, where $k \le 2$. The number of r... |
The longest a path can be without any cycles is `|V|`. We start with a source, so we already have a path of length 1, so we need `|V| - 1` more nodes to get the longest path.
The order doesn't matter because every order will maintain the invariant:
after `n` iterations, the value for each node is the cost of the mi... |
The longest a path can be without any cycles is `|V|`. We start with a source, so we already have a path of length 1, so we need `|V| - 1` more nodes to get the longest path.
The order doesn't matter because every order will maintain the invariant:
after `n` iterations, the value for each node is less than or equal... |
The longest a path can be without any cycles is `|V|`. We start with a source, so we already have a path of length 1, so we need `|V| - 1` more nodes to get the longest path.
The order doesn't matter because every order will maintain the invariant:
after `n` iterations, the value for each node is less than or equal... |
null |
The running time of the function on an input $n$ can be expressed as: $$T(n) = T(\sqrt n) + \theta(1)$$
which implies the running time of the function and the number of recursions differ only by a constant.
The recursive chain ends when $n$ has been reduced to some value $k$, where $k \le 2$. The number of recurs... |
The running time of the function on an input $n$ can be expressed as: $$T(n) = T(\sqrt n) + \theta(1)$$
which implies the running time of the function and the number of recursions differ only by a constant.
The recursive chain ends when $n$ has been reduced to some value $k$, where $k \le 2$. The number of recurs... |
The running time of the function on an input $n$ can be expressed as: $$T(n) = T(\sqrt n) + \mathcal{O}(1)$$
which implies the running time of the function and the number of recursions differ only by a constant.
The recursive chain ends when $n$ has been reduced to some value $k$, where $k \le 2$. The number of r... |
It appears the question that you are asking is:
> What is the set of formula for which a witness attempting to prove the formula false will always fail?
That is, you are asking whether a formula is [**valid**][1]: whether it is true for every interpretation. A formula is valid if and only if its negation is unsat... |
So I would like to show that the class of Recursively Enumerable languages are closed under the shrink operation. In other words, $shrink_a(L) = \{x | x=shrink_a(w), w\in L\}$ and where $shirnk_a(w)$ is the string formed from $w$ by replacing every maximal substring of two or more a's by a single a. For example, $shrin... |
Seeking Alternate Proof Regarding Closure Of Recursively Enumerable Languages |
|formal-languages|turing-machines|proof-techniques| |
Exact answer is given on p. 17 of “[Type classes as Objects and Implicits][1]” by Olvera et al.
[1]: http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.176.5300&rep=rep1&type=pdf |
If a `Run` only retains characters and sizes in an array, it seems as though you only need to find the indices corresponding to `changedOffset` and `changedOffset + changedLength`, and then potentially change the sizes of the characters in the indices to the right and left by simple addition. That is, if you have an ar... |
Exact answer is given on p. 17 of “[Type classes as Objects and Implicits][1]” by Oliveira et al.
[1]: http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.176.5300&rep=rep1&type=pdf |
The time complexity here is proportional to the depth of the recursion tree. At each level, the square root of $n$ is taken. So how many times can the square root be taken before we get 2?
This can be calculated in the same way shown at [this post](http://stackoverflow.com/questions/7280224/tn-sqrtn-tsqrtn-n).
> ... |
Please help me calculate the time complexity of the following program.
int fun (int n)
{
if (n <= 2)
return 1;
else
return fun(sqrt(n)) + n;
}
Please explain.
There were four choices given.
(a) $\Theta(n^2)$ <br>
(b) $\Theta(n \log n)$ <br>
(c) $\Theta(\log n)$... |
|algorithm-analysis|runtime-analysis|landau-notation| |
So I would like to show that the class of Recursively Enumerable languages are closed under the shrink operation. In other words, $\text{shrink}_a(L) = \{x \mid x=\text{shrink}_a(w), w\in L\}$ and where $\text{shirnk}_a(w)$ is the string formed from $w$ by replacing every maximal substring of two or more $a$'s by a sin... |
1. Is it always true that a problem which is in $NP$-$Hard$ but not $NP$-$Complete$ is a optimization problem such as $Minimum$ $Vertex$ $Cover$ and many others.
2. Is it always true that a $NP$-$Complete$ problem is always a decision problem such as $Vertex$ $Cover$ of size $k$, $Independent$ $Set$ of size $k$ and ... |
NP-Hard Problems which are not NP-Complete |
|np-complete|optimization|np-hard|decision-problem|complexity-classes| |
Suppose I have a formula, and a lying witness is attempting to make it evaluate to False.
> Given a [truth table][2] $c(F_1,…, F_n)$, how could you force a lying
witness to contradict herself?
A contradiction is simply when the witness's statements are logically impossible; i.e. that $x_1,x_2$ are each True, but... |
Given a truth table, force a contradiction |
null |
1. No. E.g. halting problem is a decision problem which is NP-hard but not in NP and therefore not NP-complete.
2. In normal usage yes, because an NP-complete problem must be in NP and NP is a class of decision problems. But see http://cs.stackexchange.com/a/476/703 |
null |
Reductions confuse me.
I've read that "every problem in NP can be reduced to every problem in NP complete".
My question is on the choice of the word "reduce". If I were to "reduce" a polynomial problem in NP to an exponential problem in NP, I just plain feel weird about using the word "reduce" because I feel lik... |
np complete reductions |
|np-complete|reductions| |
So I would like to show that the class of Recursively Enumerable languages are closed under the shrink operation. In other words, $\text{shrink}_a(L) = \{\text{shrink}_a(w)\mid w\in L\}$ and where $\text{shrink}_a(w)$ is the string formed from $w$ by replacing every maximal substring of two or more $a$'s by a single a.... |
I've read that "Every problem in NP can be reduced to every NP-complete problem".
My question is on the choice of the word "reduce". If I were to "reduce" a polynomial problem in NP to an exponential problem in NP, I just plain feel weird about using the word "reduce" because I feel like I've increased the proble... |
NP-complete reductions |
|terminology|np-complete|reductions| |
1. Is it always true that a problem which is in ${\sf NP}$-hard but not ${\sf NP}$-complete is a optimization problem such as **Minimum-Vertex-Cover** and many others.
2. Is it always true that a ${\sf NP}$-complete problem is always a decision problem such as vertex cover of size $k$, independent set of size $k$ an... |
|terminology|np-complete|optimization|np-hard|decision-problem| |
I am designing a poker agent with different heuristics to decide whether to raise, fold or pass (in Texas holdem poker). I am planning to have 4 heuristics with the agent biased to one of them.
The poker game will consist of 10 agents playing against each other.
I have two heuristics now:
1. bluff - Agent wou... |
> - System has a two level paging scheme
> - Average CPU time for a instruction = 100ns
> - Regular memory access = 150 ns
> - Page fault service time = 8ms
> - TLB hit ratio = 0.9
> - Page fault rate = 0.0001
>
> What is the average instruction time if the time required for address translation is negligi... |
Calculation of effective average instruction execution time in a 2-level paging system |
|operating-systems|virtual-memory|paging| |
null |
Consider the shortest path from $s$ to $t$, $s, v_1, v_2, \dots, v_k, t$. This path consists of at most $|V|-1$ edges, because repeating a vertex in a shortest path is always a bad idea (or at least there is a shortest path which does not repeat vertices), if we do not have negative weight cycles.
In round one, we k... |
|formal-languages|computability|proof-techniques|closure-properties| |
|complexity-theory|terminology|np-complete|reductions| |
|computability|terminology|undecidability| |
I think the question wants you to assume that only about 30% of instructions involve a data memory access (which is somewhat low even for a RISC, Hennessey & Patterson give 47% for MIPS for 5 SPECint2000 benchmarks). 100ns + (1.3 * 420ns) = 646.
(Unless the average number of memory accesses per instruction was prov... |
> - System has a two level paging scheme
> - Average CPU time for a instruction = 100ns
> - Average number of memory accesses per instruction = 2
> - Regular memory access = 150 ns
> - Page fault service time = 8ms
> - TLB hit ratio = 0.9
> - Page fault rate = 0.0001
>
> What is the average instruction ... |
> $L_1$ is a recursively enumerable language over some alphabet
> $\Sigma$. An algorithm effectively enumerates its words as $w_1, w_2, ...$. <br> $L_2$ is another language over $\Sigma \cup \{\#\}$ as
> $\{w_i\#w_j : w_i, w_j \in L_1, i < j\}$<br> Consider the following
> assertions.
>
> 1. $L_1$ is recursive i... |
Decidability of languages |
|computability| |
The question actually is easy, provided you take the right definition. RE languages can be defined using a Turing Machine in two equvalent ways. As an acceptor which accepts words in the language and halts (and may halt or loop otherwise), or as an enumerator, which will write the elements of the language (probably in ... |
null |
I have to find a negative cycle in a directed weighted graph. I know how the bellman ford algorithm works, and that it tells me if there is a reachable negative cycle. But it does not explicitly name it.
How can I get the actual path $v1, v2, ... vk, v1$ of the cycle?
After applying the standard algorithm we alre... |
Getting negative cycle using bellman ford |
|algorithms|graph-theory|graphs|shortest-path| |
I have to find a negative cycle in a directed weighted graph. I know how the Bellman Ford algorithm works, and that it tells me if there is a reachable negative cycle. But it does not explicitly name it.
How can I get the actual path $v1, v2, \ldots vk, v1$ of the cycle?
After applying the standard algorithm we a... |
Getting negative cycle using Bellman Ford |
|algorithms|graphs|shortest-path| |
For any kind of a serious argument about computably enumerable sets, you need to free yourself of details concerning Turing machines. So you should look for general useful principles that allow you to prove properties of c.e. sets. Here is one:
> If $A$ is computably enumerable and $f$ is computable then $f(A)$ is c... |
I am unsure if I have even identified the problem correctly, but reading up on [knapsack problem][1] seems the closest to what I am trying to solve:
> A cook has $k$ ingredients of $p$ quantities. Given a
> list of $n$ unique recipes, each consisting varying ingredients of varying
> quantities.
> Now, the cook w... |
You are right for the most part. Just one more addition. When you go back the predecessor chain when trying to find the cycle, you stop when you either reach the starting vertex $v_1$ or any other vertex that has already been seen in the predecessor chain that you have seen so far. Basically, you stop and output vertic... |
|formal-languages|computability| |
I have to find a negative cycle in a directed weighted graph. I know how the Bellman Ford algorithm works, and that it tells me if there is a reachable negative cycle. But it does not explicitly name it.
How can I get the actual path $v1, v2, \ldots vk, v1$ of the cycle?
After applying the standard algorithm we a... |
I am unsure if I have even identified the problem correctly, but reading up on [knapsack problem][1] seems the closest to what I am trying to solve:
> A cook has $k$ ingredients of $p$ quantities. Given a
> list of $n$ unique recipes, each consisting varying ingredients of varying
> quantities.
> Now, the cook w... |
null |
From what I understand, your first algorithm intends to process the $a$ and $b$ inputs separately, which doesn't seem necessary. Your difficulty seems to come from formalizing a TM, which you can do in a couple ways.
**Direct Conversion** (Courtesy of Raphael in the comments)
> You can view an NFA as TM that can ... |
$\newcommand{\PH}{\mathsf{PH}}$To expand the comments:
Suppose there did exist a $\PH$-Complete language $L \in \Sigma_i$ for some $i$. By definition of completeness $L' \leq L$ for all $L' \in \PH$. Therefore there exists some language $L' \in \Sigma_{i+1}$ that reduces to $L$. This is a contradiction with the stri... |
For the purposes of this discussion, a "program" is a piece of code which always takes an integer as an input, and either runs forever or returns an integer. We say that two programs $f$ and $g$ are *extensionally equal* if they compute the same function, i.e., for every number $n$ either both $f(n)$ and $g(n)$ run for... |
The title of the question expresses what I'm looking for in an answer - this is to help me better understand the prerequisites for the [Non-Deterministic Time Hierarchy Theorem][1]
For instance, the Arora-Barak book explains the theorem using $g(n) = n$ and $G(n) = n^{1.5}$ - but, I can see that $n \in o(n^{1.5})$ a... |
Give an example of two functions g(n), G(n) such that g(n) = o(G(n)) but g(n+1) $\neq$ o(G(n)) |
|complexity-theory| |
The title of the question expresses what I'm looking for - this is to help me better understand the prerequisites for the [Non-Deterministic Time Hierarchy Theorem][1]
For instance, the Arora-Barak book explains the theorem using $g(n) = n$ and $G(n) = n^{1.5}$ - but, I can see that $n \in o(n^{1.5})$ as well! So, I... |
Two functions $g(n)$, $G(n)$ such that $g(n) = o(G(n))$ but $g(n+1) \neq o(G(n))$ |
|complexity-theory|time-complexity|landau-notation| |
You seem to be right. But as Raphael says, be careful.
Statement 1. Note that the $L_2$ is defined using the enumerating algorithm $\cal E$ for $L_1$, not by $L_1$ itself. To decide whether $u\#v \in L_2$, decide whether both $u,v$ in $L$, and if confirmed run the enumerator $\cal E$ and see whether $u$ is output be... |
Take $g(n)= n!$ and $G(n) = (n+1)!$. |
One example is $g(n) = 2^{2^{n-1}}$, $G(n) =2^{2^{n}}$.
We have $g(n) = \sqrt{G(n)}$, so $g(n) = o(G(n))$.
Meanwhile, of course, $g(n+1) = G(n)$ so $g(n+1) = \Theta(G(n))$, so $g(n+1)\neq o(G(n))$
Why double exponential? When we add one to $n$, we want the effect to be more than a multiplicative constant (bec... |
One example is $g(n) = 2^{2^{n-1}}$, $G(n) =2^{2^{n}}$.
We have $g(n) = \sqrt{G(n)}$, so $g(n) = o(G(n))$.
Meanwhile, of course, $g(n+1) = G(n)$ so $g(n+1) = \Theta(G(n))$, so $g(n+1)\neq o(G(n))$
Why double exponential? When we add one to $n$, we want the effect to be more than a multiplicative constant (bec... |
One example is $g(n) = 2^{2^{n-1}}$, $G(n) =2^{2^{n}}$.
We have $g(n) = \sqrt{G(n)}$, so $g(n) = o(G(n))$.
Meanwhile, of course, $g(n+1) = G(n)$ so $g(n+1) = \Theta(G(n))$, so $g(n+1)\neq o(G(n))$
Why double exponential? When we add one to $n$, we want the effect to be more than a multiplicative constant (bec... |
An independent set $I$ is a subset of the nodes of a graph $G$ where: no 2 nodes in $I$ are adjacent in $G$. For natural number $k$, the problem $k-IND$ asks if there is an independent set of size $k$.
I'd really love your help with showing that $IND \in L$ i.e can be decided using a logarithmic amount of memory spa... |
Showing that $k-IND \in L$- Independent set of size $k$ can be decide using a logarithmic amount of memory space |
|complexity-theory|time-complexity|space-complexity| |
|complexity-theory|time-complexity|asymptotics|landau-notation| |
|algorithms|arrays| |
One example is $g(n) = 2^{2^{n-1}}$, $G(n) =2^{2^{n}}$.
We have $g(n) = \sqrt{G(n)}$, so $g(n) = o(G(n))$.
Meanwhile, of course, $g(n+1) = G(n)$ so $g(n+1) = \Theta(G(n))$, so $g(n+1)\neq o(G(n))$
Why double exponential? When we add one to $n$, we want the effect to be more than a multiplicative constant (bec... |
null |
I'm currently studying for an exam for a course where some of the material covered included finite state automata, I've completed a question and I'm not sure about my answer.
**Question**
https://i.stack.imgur.com/vDFax.png
**My Answer**
https://i.stack.imgur.com/rSnEv.png
Are multiple completion states ... |
Finite state automata, multiple completion states? |
|automata|finite-automata| |
Your DFA is a close, but not quite right. Note that the description requires the strings in the language to have at least one $a$, whereas your DFA will accept the empty string. The fix is simple of course:
![DFA accepting a^{+}b^{*}][1]
And yes, having multiple accept states is fine (in fact, some languages requir... |
Your DFA is a close, but not quite right. Note that the description requires the strings in the language to have at least one $a$, whereas your DFA will accept the empty string. The fix is simple of course:
![DFA accepting a^{+}b^{*}][1]
And yes, having multiple accept states is fine (in fact, some languages requir... |
One example is $g(n) = 2^{2^{n-1}}$, $G(n) =2^{2^{n}}$.
We have $g(n) = \sqrt{G(n)}$, so $g(n) = o(G(n))$.
Meanwhile, of course, $g(n+1) = G(n)$ so $g(n+1) = \Theta(G(n))$, so $g(n+1)\neq o(G(n))$
Why double exponential? When we add one to $n$, we want the effect to be more than a multiplicative constant (bec... |
Using the halting problem seems like the good solution. Suppose you have a function `red` that takes the code of a function (or [λ-term][1]) (or a untyped function), reduces one step (or [β-redex][2]) in it and return the code of the resulting function. Suppose also that you have a function `normal` that says if the te... |
Using the halting problem seems like the good solution. Suppose you have a function `red` that takes the code of a function (or [λ-term][1]) (or a untyped function), reduces one step (or [β-redex][2]) in it and returns the code of the resulting function. Suppose also that you have a function `normal` that says if the t... |
The naive algorithm for determining $B$ from $A$:
> For $k=1,\dots,n$, determine the value of $B(k)$ by comparing each $A(i)$ to $A(k)$ for
> $i=1,\dots,k$ and counting those that satisfy $A(i)<A(k)$.
This algorithm compares $A(1)$ to all others ($n-1$ times), $A(2)$ to $n-2$ others, etc. so the total number o... |
|algorithms|arrays|permutations| |
I ended up figuring it out, thanks all for the help.
![enter image description here][1]
[1]: https://i.stack.imgur.com/KtfsA.png |
Rather than determining each $B(k)$ one at a time, we can be forward looking and only go through each number in $A$ *once*! But we'll use $n$ space, and we’re assuming each update takes 1 step, which isn’t (completely) unreasonable. To explain via demonstration:
$$\begin{vmatrix}
A & & 1 & 2 & 3 & 4 & 5 & 6 & 7 &... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.