instruction stringlengths 0 29.8k ⌀ |
|---|
For $\sum_{0 \le r \le k} r \cdot 2^r$, start with:
$$
\frac{1 - z^{k + 1}}{1 - z} = \sum_{0 \le r \le k} z^r
$$
As this is a polynomial, the following mangling doesn't need any justification:
$$
z \frac{d}{dz} \frac{1 - z^{k + 1}}{1 - z} = \sum_{0 \le r \le k} r z^r
$$
Doing the operations indicated:
$$
\sum... |
Let $F$ be the set of all functions $f(n)$ such that $\sum_n f(n)$ diverges. Then $F$ is bounded from below by $f(n) = 1/n^2$ (for example), but there is no infimum: for every divergent sequence, you can find a sequence which diverges more slowly. This is a classical result of Hausdorff.
Similarly, if $F$ is the set... |
null |
Given an undirected unweighted multigraph $G=(V,E)$ and $s,t \in V$ find a simple $st$-path $P$ s.t. the number of edges leaving $P$ (i.e. the edges with exaclty one endpoint in $P$ ) is minimized.
Does anybody have any idea how to solve this?
I first thought about replacing edges by two arcs and weight them accor... |
Suppose input graph is simple (without parallel edges), now, If you solve your problem, you can check existence of Hamiltonian path, actually if s-t path of cost zero for some pair exists means there is Hamiltonian path and you can check this for all pair of vertices as (s,t), so you are unlucky to have polynomial time... |
For $k$-bit inputs, this function works:
$\mathrm{hash}(n) = (n \bmod 2^{\lceil\frac{k}{2}\rceil})\cdot 2^{\lceil\frac{k}{2}\rceil} + n \,\mathrm{div}\, 2^{\lceil\frac{k}{2}\rceil}$
This is reversible, in that $\mathrm{hash}(\mathrm{hash}(n)) = n$, and has non-sequential pairs $\{n,m\}, n < m$, where $\mathrm{has... |
Use dynamic programming to find division number of each node, For leaf nodes set it to $0$
Then recursively for parent of each leaf node set it to sum of division of it's child, and for each child because that child is not counted in division number of itself we should add its division number by one to calculate the ... |
null |
null |
One of my lectures makes the following statement:
$$( f(n)=O(n) \wedge f(n)\neq o(n) )\rightarrow f(n)=\theta(n)$$
Maybe I'm missing something in the definitions, but for example bubble sort is $O(n^2)$ and not $o(n^2)$ but it's also not $\theta(n^2)$ since it's best case run time $\Omega(n)$.
What am I missin... |
$( f(n)=O(n) \wedge f(n)\neq o(n) ) \rightarrow f(n)=\theta(n)$ |
|time-complexity|asymptotics|landau-notation| |
What you are missing is a very important point:
An algorithm is never $O()$ of anything, since it is usually not a even a real-valued function.
When we say that bubble-sort is $O(n^2)$, what we mean is that in the function $f$, that represents the *worst case run-time* of bubble sort, is $O(n^2)$.
In this case, ... |
I can think of functions such as $n^2 sin^2 n$ that don't have asymptotically tight bounds, but are there actually common algorithms in computer science that don't have asymptotically tight bounds on their worst case running times? |
Common Algorithms without Asymptotically Tight Bounds |
|time-complexity|asymptotics|landau-notation| |
This is somewhat of an anomaly, but yes - technically you could say that there are such algorithms. For example, consider an algorithm that checks whether a number in unary encoding is a prime - the first thing the algorithm can check is whether the number is even, this takes $O(n)$ time.
If it is, the algorithm rej... |
Let $\Theta$ and $o$ be defined as usual (Landau-notation).
For two equivalence classes defined by $\Theta$ we define
$$\Theta(f) <_o \Theta(g) :\Leftrightarrow f \in o(g)\qquad.$$
Let $$\mathbb{F}:= \{\Theta(f)|f:\mathbb{N}\rightarrow\mathbb{N}\}$$
**My question**:
Is $\langle \mathbb{F},<_o\rangle$ Dedekind-co... |
I have a recurrence relation and trying to use master theorem to solve it. The recurrene relation is:<p>
T(n) = 3T(n/5) + n<sup>0.5</sup>
</p>
Can i use the master theorem in that relation? If so, can i say that T(n) is Θ(n<sup>0.5</sup>) ?<p>Thanks</p> |
The use of master theorem appriopriately |
|algorithms|time-complexity|recurrence-relation|recursion| |
null |
I have used FSM in Digital sequential Circuit designs. But I am unfamiliar with Finite Automata. Can somebody help me in understanding 'basic' difference between the two ? |
What is the difference between Finite Automata and FSM |
|finite-automata| |
A real-life example is any of the simple sorting algorithms. E.g. insertion sort takes $\Omega(n)$ and $O(n^2)$, and those bounds can't be improved (best case is already ordered, in which case it just checks it is ordered in linear time; worst case is reverse order, and the time is quadratic). |
{"OriginalQuestionIds":[2789],"Voters":[{"Id":98,"DisplayName":"Raphael"}]} |
|terminology|finite-automata| |
|time-complexity|algorithm-analysis|asymptotics|runtime-analysis| |
I can think of functions such as $n^2 \sin^2 n$ that don't have asymptotically tight bounds, but are there actually common algorithms in computer science that don't have asymptotically tight bounds on their worst case running times? |
I have a recurrence relation, it is like the following:<p>
T(e<sup>n</sup>) = 2(T(e<sup>n-1</sup>)) + e<sup>n</sup>, where e is the natural logarithm.
</p>
To solve this and find a Θ bound, i tried the following: I put k=e<sup>n</sup>, and the equation transforms into:
<p>
T(k)=2T(k/e)+k
</p>
Then, i try to ... |
Not sure if my solution to following recurrence is true |
|algorithms|time-complexity|recurrence-relation| |
I am seeking help understanding Floyd's cycle detection algorithm. I have gone through the explanation on wikipedia (http://en.wikipedia.org/wiki/Cycle_detection#Tortoise_and_hare)
I can see how the algorithm detects cycle in O(n) time. However, I am unable to visualise the fact that once the tortoise and hare point... |
Floyd's Cycle detection algorithm | Determining the starting point of cycle |
|algorithms|linked-lists| |
null |
As pointed out by vzn above, the [wiki](http://en.wikipedia.org/wiki/Rabin%E2%80%93Karp_algorithm#Use_of_hashing_for_shifting_substring_search) article has all the details you are looking for.
Firstly, what is pre-processing and what is the online runtime, depends on what is remaining constant and what is varying. ... |
I have a recurrence relation, it is like the following:
$T(e^n) = 2(T(e^{n-1})) + e^n$, where $e$ is the natural logarithm.
To solve this and find a $\Theta$ bound, I tried the following: I put $k=e^n$, and the equation transforms into:
$$T(k)=2T(k/e)+k$$
Then, I try to use the master theorem. According to ... |
Not sure if my solution to following recurrence is correct |
I don't know much about yacc, bison, flex or lex and please correct me if I'm wrong but a programming language is also a Turing machine and a Turing machine is defined as the tuple $(Q, \Gamma, b, \Sigma, \delta, q_0, F)$ where $Q$, $\Gamma$, $b \in \Gamma$, $\Sigma \subseteq \Gamma \smallsetminus \{ b \}$ as input, $\... |
What is the exact relation between programming languages and Turing machines? |
The Turing machine model is a _theoretical_ model of what "computing" is all about. As a theoretical model it was designed so it is simple to manipulate and to prove things about it, specifically to explore what can or can't be computed. It also serves as a simple model in which to discuss (and prove things about) the ... |
Symbolic algebra is a vast area... perhaps you should sniff around the sites for [maxima][1], [Pari/GP][2], or [SAGE][3], all open source (full details on how they are built is available, essentially) packages. There are specialized journals on computer algebra and symbolic computation in general.
For enumerative co... |
Short version:
Is there an operator $\exists$ (on complexity classes) s.t. $\exists P = NP$ and $\exists REC=RE$, i.e. you can use the same operator on multiple interesting classes without explicitly stating a class of functions that limits the length of the witnesses?
The construction should not rely on any specif... |
Your question is closely related to the [busy beaver problem][1]. It asks for the maximum number of symbols an $n$-state Turing machine with 2 output symbols that always halts writes before halting. The function of $n$ defined this way is not computable.
[1]: http://en.wikipedia.org/wiki/Busy_beaver |
Hash table collision probability |
Short version:
Is there an operator $\exists$ (on complexity classes) s.t. $\exists P = NP$ and $\exists REC=RE$, i.e. you can use the same operator on multiple interesting classes without explicitly stating a class of functions that limits the length of the witnesses?
The construction should not rely on the existe... |
True, all programming languages are believed to be equivalent to the Turing machine, see Church-Turing thesis. That does not mean that programming a Turing machine is a practical thing to do. Far from it. To do real programming better languages are developed. In fact those languages evolve over time, when we learn what... |
As far as I understand, both have "states", and "actions" that make the machine move from one state to another upon an input signal. Thus the conceptual ideas are the same. There is some difference in the details.
In FSM for circuit designs the input signal is mostly assumed to be a bit (binary), whereas in finite s... |
Based on my experience as well as the Wikipedia article, there are several kinds of [finite state machines](http://en.wikipedia.org/wiki/Finite_state_machine), including
* [finite automata](http://en.wikipedia.org/wiki/Nondeterministic_finite_automata),
* [transducers](http://en.wikipedia.org/wiki/Finite_state_tr... |
|terminology|automata|finite-automata| |
Tell the lecturer they're wrong. Take the function
$$ f(n) = \begin{cases} n & n \text{ is even}, \\ 1 & n \text { is odd}. \end{cases} $$
This function is $O(n)$ but neither $o(n)$ nor $\Theta(n)$.
Here is a monotone example, which might be more convincing:
$$ g(n) = \exp \exp \lfloor \ln \ln n \rfloor. $$ |
What is the difference between finite automata and finite state machines? |
Short version:
Is there an operator $\exists$ (on complexity classes) s.t. $\exists P = NP$ and $\exists REC=RE$, i.e. you can use the same operator on multiple interesting classes without explicitly stating a class of functions that limits the length of the witnesses?
The construction should not rely on the existe... |
null |
Perhaps it is faster looking at this in another way... the largest prime less than $\sqrt{10^9}$ is 31607, for a total count of 3401 primes between 2 and 31607, not a very large number. Write each of the numbers you are given fully factored over the primes up to 31607:
$$
a_i = p_1^{n_{i 1}} p_2^{n_{i 2}} \ldots P_i
... |
null |
I find it fairly easy to generate an upper bound for nearly any iterative solution (e.g. look at the limits on each loop, etc.), and can oftentimes create an upper bound for normal recursive functions.
However, I am now trying to determine a "Big-O" for a DP problem I've memoized. I don't really care about the answ... |
Time Complexity Upper Bound of Memoized DP Problems |
|asymptotics|dynamic-programming| |
Use the [Akra-Bazzi method][1]. In terms of the notation there you have:
$$
\begin{align*}
g(x) &= \frac{x}{2} = O(x^c) \\
a_i &> 0 \quad \forall i \\
0 &< b_i < 1 \quad \forall i \\
\end{align*}
$$
The requisites check out (and the somehow implied differences $h_i(x)$ due to truncation if the divisions don't... |
Counter-example:
$L_1 = \{a^n b^n c^m \mid m,n \ge 1 \}$
$L_2 = \{a^m b^n c^n \mid m,n \ge 1 \}$
$L = (L_1 \cdot L_2^*) \cup \epsilon$ is context-free.
Any nonempty word $x \in L^\#$ has a prefix $p = a^n b^n c^m \in L_1$. It must be $n = m$, because due to $L_2$, any pair of a $b^+$ and a directly succeedi... |
One of my lectures makes the following statement:
$$( f(n)=O(n) \land f(n)\neq o(n) )\implies f(n)=\Theta(n)$$
Maybe I'm missing something in the definitions, but for example bubble sort is $O(n^2)$ and not $o(n^2)$ but it's also not $\theta(n^2)$ since it's best case run time $\Omega(n)$.
What am I missing he... |
$( f(n)=O(n) \land f(n) \neq o(n) ) \implies f(n)=\Theta(n)$ |
|asymptotics|landau-notation| |
The [Rabin-Karp algorithm][1] looks for a substring by computing a rolling hash, of the form $h(a_{n - 1} a_{n - 2} \ldots a_0) = \sum_{0 \le k \le n - 1} a_k q^k$ for a prime $q$. Note that the algorithm works just the same if $h$ is computed modulo the word size, so using e.g. `unsigned int` in C would be wise. What ... |
I have a recurrence relation, it is like the following:
$T(e^n) = 2(T(e^{n-1})) + e^n$, where $e$ is the base of the natural logarithm.
To solve this and find a $\Theta$ bound, I tried the following: I put $k=e^n$, and the equation transforms into:
$$T(k)=2T(k/e)+k$$
Then, I try to use the master theorem. A... |
#The Akra-Bazzi method#
The [Akra-Bazzi method][1] gives asymptotics for recurrences of the form:
$$
T(x) = \sum_{1 \le i \le k} a_i T(b_i x + h_i(x)) + g(x) \quad \text{for $x \ge x_0$}
$$
This covers the usual divide-and-conquer recurrences, but also cases in which the division is unequal. The "fudge terms" $h... |
$c=1\gt \ln 2\approx0.7$. That's [case 3](http://en.wikipedia.org/wiki/Master_theorem) of the master theorem. It follows that:
$$T(n)=\Theta(n)$$
Your solution is fine. |
This looks like the running time of a divide-and-conquer algorithm. You can apply the [Akra-Bazzi](http://en.wikipedia.org/wiki/Akra%E2%80%93Bazzi_method) method here. The method works for recurrences of the form:
$$T(n)=\sum_i^k a_iT(b_i n+h_i(n))+g(n), \forall n\ge n_0$$
In your case:
$k=1$
$g(n)=\log n$
... |
This looks like the running time of a divide-and-conquer algorithm. You can apply the [Akra-Bazzi](http://en.wikipedia.org/wiki/Akra%E2%80%93Bazzi_method) method here. The method works for recurrences of the form:
$$T(n)=\sum_i^k a_iT(b_i n+h_i(n))+g(n), \forall n\ge n_0$$
In your case:
$k=1$
$g(n)=\log n$
... |
null |
Let $F$ be the set of all functions $f(n)$ such that $\sum_n f(n)$ diverges. Then $F$ is bounded from below by $f(n) = 1/n^2$ (for example), but there is no infimum: for every divergent sequence, you can find a sequence which diverges more slowly. This is a classical result of Hausdorff.
Similarly, if $F$ is the set... |
Let $\Theta$ and $o$ be defined as usual (Landau-notation).
For two equivalence classes defined by $\Theta$ we define
$$\Theta(f) <_o \Theta(g) :\Leftrightarrow f \in o(g)\qquad.$$
Let $$\mathbb{F}:= \{\Theta(f)\mid f:\mathbb{N}\rightarrow\mathbb{N}\}$$
**My question**:
Is $\langle \mathbb{F},<_o\rangle$ Dedekin... |
For $\sum_{0 \le r \le k} r \cdot 2^r$, start with:
$$
\frac{1 - z^{k + 1}}{1 - z} = \sum_{0 \le r \le k} z^r
$$
As this is a polynomial, the following mangling doesn't need any justification:
$$
z \frac{d}{dz} \frac{1 - z^{k + 1}}{1 - z} = \sum_{0 \le r \le k} r z^r
$$
Doing the operations indicated:
$$
\sum... |
Short version:
Is there an operator $\exists$ (on complexity classes) s.t. $\exists P = NP$ and $\exists REC=RE$, i.e. you can use the same operator on multiple interesting classes without explicitly stating a class of functions that limits the length of the witnesses?
The construction should not rely on the existe... |
null |
The operational semantics is determined by what the language designer wants programs to do. If you define $\mathrm{pred}$ by $\mathrm{pred} \: \mathrm{false} \to \mathrm{true}$ and $\mathrm{pred}$ by $\mathrm{pred} \: \mathrm{true} \to \mathrm{false}$, that's perfectly fine mathematically speaking. On the other hand, h... |
null |
nice question, but you're overthinking this. getting lost in the symbols. lets look at it all in a simple, basic way. a programming language is in ASCII or say just 0/1 bits for characters. now imagine the TM has 0/1 bits to simplify it, or say ASCII as input characters.
the key realization, and analogy, is that TM... |
nice question, but you're overthinking this. getting lost in the symbols. lets look at it all in a simple, basic way. a programming language is in ASCII or say just 0/1 bits for characters. now imagine the TM has 0/1 bits to simplify it, or say ASCII as input characters.
the key realization, and analogy, is that TM... |
nice question, but you're overthinking this. getting lost in the symbols. lets look at it all in a simple, basic way. a programming language is in ASCII or say just 0/1 bits for characters. now imagine the TM has 0/1 bits to simplify it, or say ASCII as input characters.
the key realization, and analogy, is that TM... |
Skip lists have other properties which might make them attractive in situations where operations other than just insert/lookup/delete are used.
For instance, skip lists have $O(1)$ expected time local updates when the modification location is known. This is certainly possible in $O(1)$ worst-case time with certain b... |
null |
|turing-machines|formal-grammars|programming-languages|computation-models| |
null |
Should be easy to reduce the problem to:
Given a list of bit vectors, find the minimum number of them such that `and` all of them result the $0$ bit vector.
So in your problem, the length of the bit vectors is at most $4500$, since each number have at most $9$ unique factors.
Now create a bipartite graph $G(A,B... |
Should be easy to reduce the problem to:
Given a list of bit vectors, find the minimum number of them such that `and` all of them result the $0$ bit vector.
So in your problem, the length of the bit vectors is at most $4500$, since each number have at most $9$ unique factors.
Now create a bipartite graph $G=(A,... |
null |
True, all (useful, and not too exotic) programming languages are believed to be equivalent to the Turing machine. (According to the Church-Turing thesis, they will not compute more, and usually it is clear how to simulate a TM in your favourite language). That does not mean that programming a Turing machine is a practi... |
## Generating Functions $\newcommand{\nats}{\mathbb{N}}$
Every series of numbers corresponds to a [generating function](https://en.wikipedia.org/wiki/Generating_function). It can often be comfortably obtained from a recurrence to have its coefficients -- the series' elements -- plucked.
This answer includes the g... |
I don't think there is a polynomial probability for losing 'balance'. After you insert an element in a skip list, you build a tower of copies above it by flipping a coin until it comes up heads.
So you have layers with fewer and fewer elements as you reach the top. Since a tower has height $k$ with probability $2^{... |
This question arises from my reading of ["Types and Programming Languages"][1] ([WorldCat][2]) by Benjamin C. Pierce.
On page 36 is the definition for *satisfied*
> A rule is *satisfied* by a relation if, for each instance of the rule,
> either the conclusion is in the relation or one of the premises is
> not.
... |
TAPL: Explanation and example(s) for satisfied |
|operational-semantics|small-step-semantics| |
null |
Should be easy to reduce the problem to:
Given a list of bit vectors, find the minimum number of them such that `and` all of them result the $0$ bit vector.
So in your problem, the length of the bit vectors is at most $4500$, since each number have at most $9$ unique prime factors.
Now create a bipartite graph ... |
I need to find a context-free grammar for the above expression, $a^{m}b^{n}$ for the set $L = \left\{{a, b}\right\}$, but I am having difficulty accounting for the condition $m \neq n$.
This is what I have so far, but it clearly doesn't satisfy the above condition:
$\begin{align}
&S \rightarrow aAb &\\
&S... |
CFG using the set $L =\left\{{a,b}\right\}$ for the expression $a^{m}b^{n}$, where $m \neq n$ |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.