instruction
stringlengths
0
29.8k
⌀
Amortized analysis deals with the runtime cost of an operation as an *average over a sequence of operations.* This is similar to the financial concept of amortization -- a single lump sum, such as a loan, is *amortized* over a period of time. This fixes a monthly payment for example, even though the principal balance...
null
A recent [puzzle blog post][1] about finding three evenly spaced ones lead me to a [stackoverflow question][2] with a top answer that claims to do it in O(n lg n) time. The interesting part is that the solution involves squaring a polynomial, referencing a [paper that describes how to do it in O(n lg n) time][3]. No...
Where is the mistake in this apparently-O(n lg n) multiplication algorithm?
|algorithms|time-complexity|
A recent [puzzle blog post][1] about finding three evenly spaced ones lead me to a [stackoverflow question][2] with a top answer that claims to do it in O(n lg n) time. The interesting part is that the solution involves squaring a polynomial, referencing a [paper that describes how to do it in O(n lg n) time][3]. No...
null
Your algorithm is very similar to Schönhage–Strassen. In the FFT step, there are large numbers involved - as you mention, their size can be up to $O(\log n)$. Arithmetic on them doesn't come for free. You need to apply the construction recursively, and you'll lose something.
The potential function method is complicated, your example is simple. The number of bits changed is 1 about half the time, 2 about a quarter of the time, 3 about an eighth of the time, and so on. This is because the number of bits changed, starting from 0, is 1,2,1,3,1,2,1,4 and so on (you get the pattern). So the aver...
null
Let $a_i$ be the amortized costs of operation $i$, $c_i$ be the actual costs of operation $i$, and $D_i$ the data structure after operation $i$. The amortized costs of an operation are **defined** as $$a_i:=c_ i+ \Phi(D_i) -\Phi(D_{i-1}).$$ You usually assume the following 1. The potential is always positive, tha...
I try to figure out **a redundant power of two-sided error randomized Karp - reduction.** It's well known fact and it is relatively hard to show that [BPP](http://en.wikipedia.org/wiki/BPP) is reducible by a one-sided error randomized Karp-reduction to coRP (in case of promise problem). Without delving into detai...
The Power of Randomized Reduction
|complexity-theory|reductions|
I try to figure out **a redundant power of two-sided error randomized Karp - reduction.** It's well known fact and it is relatively hard to show that [BPP](http://en.wikipedia.org/wiki/BPP\_\(complexity\)) is reducible by a one-sided error randomized Karp-reduction to coRP (in case of promise problem). Without de...
|algorithm-analysis|amortized-analysis|
FRP is about streaming events and behaviours through pure functions. The Actor model - at least, as implemented in Akka - is about streaming immutable messages (which can be considered to be discrete events) through potentially impure objects, called actors. So on the surface they seem related. What else can we s...
How do Functional Reactive Programming and the Actor model relate to each other?
|functional-programming|
null
It is still $\sf{NP}$-complete, even for $k=2$. Given an instance of subset sum, we can transform it in to this variant by splitting up the numbers and adding some extra bits. First, the sum of all numbers in the problem will be less than $2^m$ for some value of $m$. Now, let's take a number $n$ from the origina...
This is a simple question on the definition of routing tables. I will add a brief explanation. Let's take the SALES router. It has two interfaces. The interface top (65.21.1.2) is connected to the network 65.21.1.0/24. The interface bottom (65.21.6.1) is connected to the network 65.21.6.0/23. This can be ex...
null
I am tackling the halting problem right now and its remarkable theorem. My book states $\text{HALT}(x,y)$ is true if $\psi^{(1)}_{\mathcal P}$ is defined and conversely $\text{HALT}(x,y)$ is false if $\psi^{(1)}_{\mathcal P}$ is undefined. The purpose of the theorem, of course, is showing that $\text{HALT}(x,y)$ is...
Clarification on halting predicate computability
|halting-problem|
I am tackling the halting problem right now and its remarkable theorem. My book states $\text{HALT}(x,y)$ is true if $\psi^{(1)}_{\mathcal P}$ is defined and conversely $\text{HALT}(x,y)$ is false if $\psi^{(1)}_{\mathcal P}$ is undefined. The purpose of the theorem, of course, is showing that $\text{HALT}(x,y)$ is...
I am tackling the halting problem right now and its remarkable theorem. My book states $\text{HALT}(x,y)$ is true if $\psi^{(1)}_{\mathcal P}$ is defined and conversely $\text{HALT}(x,y)$ is false if $\psi^{(1)}_{\mathcal P}$ is undefined. The purpose of the theorem, of course, is showing that $\text{HALT}(x,y)$ is...
null
In the definitions in this question the relationship between the program and its inputs and the arguments of the $\text{HALT}(x,y)$ predicate is missing. Suppose $\text{HALT}(x,y)$ is true if the program encoded by the number $x$ terminates on an input $y$. Now assuming $\text{HALT}(x,y)$ is computable, define a ...
Neither actors nor FRP are about streaming. Actors don't even support external configuration of an output stream. FRP is strongly characterized by its modeling signals and events on a linear timeline, which enables FRP behaviors to compose in a deterministic manner. Actors are strongly characterized by processing m...
Let's walk through the proof given by [Davis94]. I am familiar with this text and have it in front of me. The HALT predicate is defined: $$ HALT(x,y) \Longleftrightarrow \text{program number $y$ eventually halts on input $x$.} $$ Given this defintion of HALT, don't worry about how such a program would be defi...
|algorithm-analysis|proof-techniques|amortized-analysis|
|distributed-systems|functional-programming|programming-paradigms|
|programming-languages|programming-paradigms|
|computability|halting-problem|
They way I read the question for the first time, I understood $k$ to be a fixed parameter. Define the following languages, for $k\ge 1$: $$L_k = \{ a^ku \mid u\in \{a,b\}^* \text{ and $u$ has at least $k$ $a$'s }\}$$ $$\tilde L_k = \{ a^ku \mid u\in \{a,b\}^* \text{ and $u$ has at most $k$ $a$'s }\}$$ The diff...
They way I read the question for the first time, I understood $k$ to be a fixed parameter. Define the following languages, for $k\ge 1$: $$L_k = \{ a^ku \mid u\in \{a,b\}^* \text{ and $u$ has at least $k$ $a$'s }\}$$ $$\tilde L_k = \{ a^ku \mid u\in \{a,b\}^* \text{ and $u$ has at most $k$ $a$'s }\}$$ The diff...
Amortized analysis deals with the runtime cost of an operation as an *average over a sequence of operations.* This is similar to the financial concept of amortization -- a single lump sum, such as a loan, is *amortized* over a period of time. This fixes a monthly payment for example, even though the principal balance...
I'd like your help with the following question: Assume we proved that $\mbox{BPP}\subseteq \Pi_2$ -What conclusions can you make? [BPP ][1] is the class of decision problems solvable by a probabilistic Turing machine in polynomial time, with an error probability of at most 1/3 for all instances, $\Pi_2$ is...
Assuming $\mbox{BPP}\subseteq \Pi_2$ -What conclusions can we make?
|complexity-theory|time-complexity|
null
null
Let's walk through the proof given by [Davis94]. I am familiar with this text and have it in front of me. The HALT predicate is defined: $$ HALT(x,y) \Longleftrightarrow \text{program number $y$ eventually halts on input $x$.} $$ Given this defintion of HALT, don't worry about how such a program would be defi...
Based on the definition of a [Multiset][1] and the information in this [paper][2], why do we use multiset in proving the termination of a program? Is not the well-founded order enough ? [1]: http://mathworld.wolfram.com/Multiset.html [2]: http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.145.8728
The use of Multiset Ordering in proving Termination
|algorithms|combinatorics|sets|binary-arithmetic|finite-sets|
I'm interested in finding a solution for the following problem: - problem space: any language that has more than 1 article - let's take german language as example. So the articles in German are "der", "die", "das". - every word has an article as prefix and you must use the article. for example you can't say just "A...
analyzing rules of articles in languages
|formal-languages|
As I understand the paper (and I was not familiar with it before) to prove termination of a program using the method of Floyd it is enough to find a function $\tau$ that maps the states of the program into some well-founded set $(S,\prec)$ such that this function is consistent with the program steps. Here consistency m...
As I understand the paper (and I was not familiar with it before) to prove termination of a program using the method of Floyd it is enough to find a function $\tau$ that maps the states of the program into some well-founded set $(S,\prec)$ such that this function is consistent with the program steps. Here consistency m...
Let $a_i$ be the amortized costs of operation $i$, $c_i$ be the actual costs of operation $i$, and $D_i$ the data structure after operation $i$. The amortized costs of an operation are **defined** as $$a_i:=c_ i+ \Phi(D_i) -\Phi(D_{i-1}).$$ You usually assume the following 1. The potential is always positive, tha...
First, I have tried to build a DFA over the alphabet $\sum = \{0,\dots, 9\}$ that accepts all decimal representations of natural numbers divisible by 3, which is quite easy because of the digit sum. For this I choose the states $Q = \mathbb{Z}/3\mathbb{Z}\cup\{q_0\}$ ($q_0$ to avoid the empty word), start state $q_0$, ...
DFA that accepts decimal representations of a natural number divisible by 43
|formal-languages|
Anyone knows if there is an algorithm for directly write the context-free grammar that generates a given regular expression?
Regular Expression to Context-Free Grammar
|formal-grammars|regular-expressions|context-free|
If the string read has a certain decimal value, then reading the next digit changes that value : multiply by $10$ and add that digit. The DFA keeps track of that value modulo $43$. Thus, for $q\in \{0,1,\dots,42\}$ and $a\in \{0,1,\dots,9\}$, $\delta(q,a) = 10\cdot w + a \bmod 43$.
I think the problem statement is clearer when you think of it as a counter that starts at 0 and has an operation that increments the value by one. Every time the counter from your problem is incremented, exactly one bit is flipped on and zero or more bits are flipped off$^*$. The potential function from the example pr...
Yes. I give the high-level answer, without many details. First you have to parse the expressions. That can be done using a simple recursive decent parser. Several examples on the web. Then you should add "semantic" rules to the parser, when returning from the recursion. Those are standard in any formal language t...
A language is a result of a complex historical development. If the development were guarded by simple language generating rules it would've been different like some artificial languages such as the Esperanto language. Many natural languages have nouns split into several categories. These categories are often referre...
A language is a result of a complex historical development. If the development were guarded by simple language generating rules it would've been different like some artificial languages such as the Esperanto language. Many natural languages have nouns split into several categories. These categories are often referre...
Concerning the Master Theorem. I have found the following equation as the base of analysis: `T(N) = aT(N/b) + Θ(N^k)` but I also found the following: `T(N) = aT(N/b) + Θ(N^k* logN)` where `logN` is base `p` where `p` is a real number Can anyone explain the second equation?I understand the proof with the...
Explanation of a specific formula of Master Theorem
|algorithms|algorithm-analysis|asymptotics|recursion|master-theorem|
I am following the idea of @vonbrand: **Hint 1:** Solve first for $b=0$. You might use the [Myhill-Nerode](http://en.wikipedia.org/wiki/Myhill%E2%80%93Nerode_theorem) Theorem. >! We define the following relation $\bar x\approx \bar y :\iff x\equiv y \mod 10$. This is obviously an equivalence relation. Furthermor...
Concerning the Master Theorem. I have found the following equation as the base of analysis: $T(n) = aT(n/b) + \Theta(n^k)$ but I also found the following: $T(n) = aT(n/b) + \Theta(n^k\cdot\log_p n)$ where the base $p$ is a real number. Can anyone explain the second equation? I understand the proof with ...
|machine-learning|natural-language-processing|
Critical section code: int turn = 0; /* shared control variable */ Pi: /* i is 0 or 1 */ while (turn != i) ; /* busy wait */ CSi; turn = 1 - i; This solution form this page http://phoenix.goucher.edu/~kelliher/cs42/sep27.html ...
Mutual exclusion for n processes
|process-scheduling|
|formal-languages|regular-languages|finite-automata|
If the string read has a certain decimal value, then reading the next digit changes that value: multiply by $10$ and add that digit. The DFA keeps track of that value modulo $43$. Thus, for $q\in \{0,1,\dots,42\}$ and $a\in \{0,1,\dots,9\}$ you do $\qquad \delta(q,a) = (10\cdot q + a) \bmod 43$. Note that the DFA...
I assume you want to get a grammar that generates the same language as the given regular expression. You can achieve that by the following steps: 1. Translate the regular expression into an NFA. 2. Translate the NFA into a (right-)regular grammar. Both translations are standard and covered in basic textbook...
Concerning the Master Theorem. I have found the following equation as the base of analysis: $\quad T(n) = aT(n/b) + \Theta(n^k)$ but I also found the following: $\quad T(n) = aT(n/b) + \Theta(n^k\cdot\log_p n)$ where the base $p$ is a real number. Can anyone explain the second equation? I under...
Explanation of a specific recurrence with respect to Master Theorem
|algorithm-analysis|asymptotics|recurrence-relation|master-theorem|
I want to implement mutual exclusion for $n$ processes. Critical section code: int turn = 0; /* shared control variable */ Pi: /* i is 0 or 1 */ while (turn != i) ; /* busy wait */ CSi; turn = 1 - i; This solution from [this page](h...
|concurrency|mutual-exclusion|
|operating-systems|concurrency|synchronization|
|programming-languages|concurrency|mutual-exclusion|
I am following the idea of @vonbrand: **Hint 1:** Solve first for $b=0$. You might use the [Myhill-Nerode](http://en.wikipedia.org/wiki/Myhill%E2%80%93Nerode_theorem) Theorem. >! We define the following relation $\bar x\approx \bar y :\iff x\equiv y \mod 10$. This is obviously an equivalence relation. Furthermor...
I am following the idea of @vonbrand: **Hint 1:** Solve first for $b=0$. You might use the [Myhill-Nerode](http://en.wikipedia.org/wiki/Myhill%E2%80%93Nerode_theorem) Theorem. >! We define the following relation $\bar x\approx \bar y :\iff x\equiv y \mod a$. This is obviously an equivalence relation. Furthermore...
It is known. As your final statement says, BPP $\subseteq \Pi_2 \cap \Sigma_2$. It is called the Sipser–Gács–Lautemann theorem.
null
It is known. As your final statement says, $\mbox{BPP} \subseteq \Pi_2 \cap \Sigma_2$. It is called the [Sipser–Gács–Lautemann theorem][1]. It can be strengthened to $\mbox{BPP} \subseteq \mbox{MA} \subseteq \mbox{S}^P_2 \subseteq \Pi_2 \cap \Sigma_2 \subseteq \Pi_2$ (see also [Arthur-Merlin protocol][2]). ...
It is known. As your final statement says, $\mbox{BPP} \subseteq \Pi_2 \cap \Sigma_2$. It is called the [Sipser–Gács–Lautemann theorem][1]. (All though your "so" is somewhat misleading.) It can be strengthened to $\mbox{BPP} \subseteq \mbox{MA} \subseteq \mbox{S}^P_2 \subseteq \Pi_2 \cap \Sigma_2 \subseteq \Pi_2$...
I need to show that $H_1(x)$ defined as follows is partially computable. \begin{equation} H_1(x)= \begin{cases} 1 \;\;\;\;\;\text{ if } \Phi(x,x) \downarrow \\ \uparrow \;\;\;\;\; \text{ otherwise} \end{cases} \end{equation} The thing is my textbook, that is "Computability, Complexity, and Languages" by Da...
Show $H_1(x)$ is partially computable
|computability|check-my-proof|
I'm interested in finding a solution for the following problem: - problem space: any language that has more than 1 article - let's take German language as example. So the articles in German are "der", "die", "das". - every word has an article as prefix and you must use the article. for example you can't say just "A...
Analyzing rules of articles in languages
Based on the definition of a [multiset][1] and the information in this [paper][2], why do we use multisets in proving the termination of a program? Is not the well-founded order enough? [1]: http://mathworld.wolfram.com/Multiset.html [2]: http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.145.8728
The use of multiset ordering in proving termination
If I have a collection of oracle machines, can I decide every language? (I got this question from a former university exam and it sparked my interest). I thought if my collection has to be countable than I can't decide every language, since there's an uncountable amount of languages. But if my collection can be o...