instruction
stringlengths
0
29.8k
⌀
|time-complexity|asymptotics|recurrence-relation|mathematical-analysis|
How to solve this recurrence relation: T(n) = R(n-1) + n log n R(n) = T(n-1) + n2
How to solve this recurrence relation: T(n) = R(n-1) + n log n R(n) = T(n-1) + n^2
How to solve this recurrence relation: T(n) = R(n-1) + n log n R(n) = T(n-1) + n^2
null
null
a) the set of Turing machine descriptions that accept only finitely many inputs b) the set of Turing machine decriptions that accept all their inputs. c) the set of Turing machine descriptions that accept infinitely many different inputs I struggle between the three answers, as I do not really understand what does...
FOO = {M | L(M)| < ∞} What does this turing machine defines?
|turing-machines|
null
null
**Introduction** I have simple polylines as sequences of points. I need a triangulation with a configurable width. The goal is to get a 2D 'band' from the input polyline without self-intersections. **Description:** Input is a 2D point sequence {P1, ..., Pn} (Polyline) and a target width of the triangulated ban...
null
Suppose i have 3 coins: **A, B, C**. Each one of them have different value: **a, b, c**. And if want to exchange coins A for coins B, i need to be able to give exactly a units of currency A and get exactly b units of currency B in return. The problem is to find how many different triples of coins i can have? For exa...
Coin exchange, find different triples of values
|algorithms|coin-change|
How to solve: - eliminate one of $T$ or $R$. - write the homogeneous part of the recurrence and plug $T/R(n)=r^n$. - after simplification, find the roots of the characteristic equation. - express the solution as a linear combination of terms $r^n$. - now you have to find particular solutions of the full ...
By pumping lemma, we choose the word $w=a^{p^2}$ that the decomposing is $[a^sa^ta^{p-s-t}]^p$ such that $u=a^s,v^i=a^t,x=a^{p-s-t}$ $[a^sa^{it}a^{p-s-t}]^p=[a^{p+it-t}]^p$ We choose i=p+1,we get $ [a^{(1+t)p}]^p $ $=a^{(1+t)p^{2}}$ we see that the power $(1+t)p^{2}$ has 4 dividers thus doesn't belong to the ...
Is $L = {a^{p^2}| p is a prime}$ regular?
|regular-languages|automata|finite-automata|
null
I'm Nestor Mermoz Thea. I have two definition over the Directed strong pseudoforest and Directed weak pseudoforest that I don't really well understand. **Directed weak pseudoforest:** A directed weak pseudoforest is a digraph, in which every weakly connected component contains at most one directed cycle. The class ...
Tree Width of Directed Graph
|graphs|dag|treewidth|
Is $L = \{a^{p^2}\mid p\text{ is a prime}\}$ regular?
FOO = {M | The length of language that M accepts is less than infinity} M: a turing machine M such that |L(M)| is less than inifinity: a turing machine such that the length of the language that the machine accepts, is less than infinity. a) the set of Turing machine descriptions that accept only finitely many inpu...
FOO = {M | |L(M)| < ∞} What does this turing machine defines?
FOO = {M | The length of language that M accepts is less than infinity} \ M: a turing machine \ M such that |L(M)| is less than inifinity: a turing machine such that the length of the language that the machine accepts, is less than infinity. \ For example, We have |M1| <3, it means this TM only accepts less than thr...
FOO = {M | The length of language that M accepts is less than infinity} \ M: a turing machine \ M such that |L(M)| is less than inifinity: a turing machine such that the length of the language that the machine accepts, is less than infinity. \ For example, We have |M1| <3, it means this TM only accepts less than thr...
How to solve: - eliminate one of $T$ or $R$. - write the homogeneous part of the recurrence and plug $T/R(n)=r^n$. - after simplification, find the roots of the characteristic equation. - express the solution as a linear combination of terms $r^n$. - now you have to find particular solutions of the full ...
FOO = {M | The length of language that M accepts is less than infinity} \ M: a turing machine \ M such that |L(M)| is less than inifinity: a turing machine such that the length of the language that the machine accepts, is less than infinity. \ For example, We have |M1| <3, it means this TM only accepts less than thr...
The interesting question is how to prove the equivalence (and what that equivalence actually means) under some required restrictions. The required restrictions are that your function's code must be "fully parametric": use only type parameters and never any specific types; no run-time identification of type parameter...
From a programmer's perspective, the real difference between $f : \forall \alpha. \alpha\to\alpha$ and $g : \beta\to\beta$ is that the function $f$ can be applied to an argument of an arbitrary type, because we can substitute $\alpha$ to any other type. But the function $g$ has a specific type $\beta\to\beta$, and can...
There is an answer to your question from the viewpoint of practical functional programming. Applicative functors are then defined via the `zip` method, not via `ap`. The `zip` method is clearly a useful method in practice, and a programmer with some practical experience expects `zip` to have certain properties. One of ...
You say "as far as I can tell, the parametricity theorem doesn't even allow you to specify the morphism part of the functors ,. It only takes them as type constructors." What you are missing is the fact that the morphism part of the functors is uniquely fixed by their type, at least in System F (and in many other la...
In a specific lambda-calculus, e.g., in System F, you can just write the type and see whether it is covariant in its free type parameters. Each function arrow creates a contravariant position to the left of it and a covariant position to the right of it. So, for example, `F a b = (a -> a -> b) -> a` is covariant in `a`...
I know the [Independent set problem][1] is NP-complete. But could there be a more efficient way to count the exact number of different independent sets in an arbitrary, given graph? [1]: https://en.wikipedia.org/wiki/Independent_set_(graph_theory)
Counting independent sets
|algorithms|graphs|combinatorics|counting|
I don't understand your points about telescoping and time complexity, but I don't think I need to. I see you have defined this program $r(f,x)$ and you have found a case where the program does not halt and there's no way to fix it to make it halt. What I think you have proven is: there is no such program $r(f,x)$ th...
No, this problem is well-known to be [#P-complete](https://en.wikipedia.org/wiki/%E2%99%AFP-complete). Even intuitively, imagine if you had an efficient algorithm for *counting* independent sets of size at least $k$, you could also efficiently decide whether an independent set of size at least $k$ exists which you know...
null
Instead of looking at primes I would prove this: The language { a^k: k is an element of S } where S is an infinite set of non-negative integers with arbitrary large gaps between elements is not regular. It's not more difficult than the statement you have, and it proves immediately that languages like $a^{n^2}$,...
No, this problem is well-known to be [#P-complete](https://en.wikipedia.org/wiki/%E2%99%AFP-complete). For more, you can see [this question on CSTheory](https://cstheory.stackexchange.com/q/10700/5693).
I was trying to figure out how I can perform multiplication of 2 big integers using FFT and convolutions, I ran into the following article: http://numbers.computation.free.fr/Constants/Algorithms/fft.html I understand the main points behind the algorithm but I can't understand this part: > **2.3  More on the c...
Multiplying 2 positive integers using FFT and convolutions
|integers|multiplication|fast-fourier-transform|
{"Voters":[{"Id":155618,"DisplayName":"kim120"}]}
I've been thinking about this for a day now,can someone help me ? what language does S->aaSbb|SS|epslion make?
what language does S->aaSbb|SS|epslion make?
|automata|
1. Introduce integer variables $x,y,z$. Let $x$ count the number of times that you've exchanged a units of currency A for b units of currency B, $y$ count the number of times that you've exchanged a units of currency A for c units of currency C, and $z$ count the number of times that you've exchanged b units of curren...
The Algorithm Archive has an article on [Multiplication as a convolution](https://www.algorithm-archive.org/contents/convolutions/multiplication/multiplication.html) where they give enough details to understand how to implement it, and they also have example code on both [convolutions](https://www.algorithm-archive.o...
Alan Turing defined a stack in 1946 ([article][1]) and that it provided a way to save the return address of all active subroutines, thereby allowing code to be simplified into reusable subroutines. The stack was expanded on with the work of Klaus Samelson and Friedrich Bauer in 1955 ([Wikipedia][2]), that focused on lo...
null
null
Kind of covered this in a class of mine so taking excerpts from lecture slides/online resources here is my attempt at answering it. In the context of using FFT for multiplication of two large integers, writing the numbers in a certain base B refers to expressing the coefficients of the numbers in that base. This is ...
> Without stack, the subroutine as a whole would have to be printed out multiple times in the program instruction sequence (i.e., there would not be subroutines. ) No. One can easily write the equivalent of a non-reentrant subroutine by storing the return address and the arguments in the "subroutine" itself: ...
null
**Introduction** I have simple polylines as sequences of points. I need a triangulation with a configurable width. The goal is to get a 2D 'band' from the input polyline without self-intersections. **Description:** Input is a 2D point sequence {P1, ..., Pn} (Polyline) and a target width of the triangulated ban...
The Algorithm Archive has an article on [Multiplication as a convolution](https://www.algorithm-archive.org/contents/convolutions/multiplication/multiplication.html) where they give enough details to understand how to implement it, and they also have example code on both [convolutions](https://www.algorithm-archive.o...
Kind of covered this in a class of mine so taking excerpts from lecture slides/online resources here is my attempt at answering it. In the context of using FFT for multiplication of two large integers, writing the numbers in a certain base $B$ refers to expressing the coefficients of the numbers in that base. This i...
Multiplication using FFT and convolution requires that your arithmetic is performed with some precision. There's always an argument "I use floating point arithmetic with rounding errors, but since I know that the correct result must be an integer, as long as I can prove that the rounding error is less than 0.5, I can d...
null
null
null
The [Valeriepieris Circle](https://en.wikipedia.org/wiki/Valeriepieris_circle) is a circle within which it is supposed that the majority of the World's Population lives. I'm interested in general-case and average-case algorithms for finding such a circle. I'm aware that this can be done in $O(nm)$ and perhaps $O(n +...
Find the smallest Valeriepieris circle
|optimization|greedy-algorithms|average-case|
The [Valeriepieris Circle](https://en.wikipedia.org/wiki/Valeriepieris_circle) is a circle within which it is supposed that the majority of the World's Population lives. I'm interested in general-case and average-case algorithms for finding such a circle. I'm aware that this can be done in $O(nm)$ and perhaps $O(n +...
null
The [Valeriepieris Circle](https://en.wikipedia.org/wiki/Valeriepieris_circle) is a circle within which it is supposed that the majority of the World's population lives. I'm interested in general-case and average-case algorithms for finding such a circle. I'm aware that this can be done in $O(nm)$ and perhaps $O(n +...
Let $L(G)$ as the language of grammar $G$ so $$L=\{w\in\{a,b\}^* \mid n_a(w)=n_b(w)\text{ such that any prefix } u \text{ of } w:\ n_a(u)\ge n_b(u)\}.$$ (Note that $n_x$ count number of occurrence of $x$ in string $w$.) Also you can prove that $L=L(G)$ by strong induction or try to show that $L(G)\subseteq L$ an...
I am studying theoretical computer science using the book "Foundations of Logic Programming" by J. W. Loyd. I am in the part about declarative semantics of definite programs. In the book, if $P$ is a definite program, we denote by $B_P$ the Herbrand base of $P$ and we define $T_P$ as: > **Definition.** Let $P$ be ...
In the declarative semantics of definite programs, $T_P \downarrow \omega$ is not equal to the greatest fixpoint of $T_P$
|prolog|lattices|
Our lattice is $L = 2^{B_P}$ with the partial order being set inclusion. In this case, $\top = B_P$ and $\bot = \emptyset$. Notice that the Herbrand universe is $U_P = \{f^n(a) \ | \ n \geq 0 \}$ and hence $B_P = \{ p(t)\ | \ t \in U_P \} \cup \{ q(t)\ | \ t \in U_P \} $. If we apply the definitions we get: ...
Here is a simple answer. If we have a lambda-term $x : \forall t.\,t$ then we should be able to apply the term $x$ to any type $t$ and obtain a *value* of type $t$. Denote type application by $x t$ and find that $x t$ is a value of any given type $t$. Let us apply this ability to the void type $0$. Then $x 0$ is a valu...
The type system in FP languages helps you avoid a certain number of errors. The more you use various features of the type system, the more errors you can exclude. For example, if you need the list of session IDs to be always non-empty, you can use a data type "non-empty list" and ensure at compile time that no place...
Let me answer all your questions as stated, keeping to the practical programmer's point of view. *Is it correct to say that requiring the functor laws on a type constructor is equivalent to requiring that its data constructors satisfy the naturality conditions or something along these lines?* No, this is not quit...
Inflate a polyline so that the 2D band can be triangulated without self-intersections
|algorithms|computational-geometry|polygons|triangulation|
Given an HP (Hamiltonian path) instance ($G=(V,E),s,t$), we define a Shortest-Simple-Path instance ($G,s,t,w,L$) as follows. We simply let the weight $w(e)$ of every edge $e∈E$ be $−1$ and let $L=−(n−1)$. ($n=|V|$ is the number of vertices in $G$.) So, in this instance, we need to know whether there is a simple pat...
null
Let $L(G)$ as the language of grammar $G$ so $$L=\{w\in\{aa,bb\}^* \mid n_a(w)=n_b(w)\text{ such that any prefix } u \text{ of } w:\ n_{a}(u)\ge n_{b}(u)\}.$$ (Note that $n_x$ count number of occurrence of $x$ in string $w$.) Also you can prove that $L=L(G)$ by strong induction or try to show that $L(G)\subseteq...
null
The obvious resource, [Wikipedia][1], I did not find very helpful. When inserting an element at most one (single or double) rotation is needed, at the lowest point where the tree is out of balance. After rotation the height of that subtree is the same as in the original subtree, so all nodes upwards are balanced. ...
null
[![enter image description here][1]][1] [1]: https://i.stack.imgur.com/kHT9Z.png Hey guys, Got a tricky question here. I need to determine if this TM will ever halt on a empty word "". Seems like it will halt but I can't proof it. Can anyone help?
Try to proof halting problem on a special TM
|turing-machines|
null
null
*Given $m$ sorted arrays $A_1,A_2,\dots,A_m$, also $\mid A_i\mid=n$ for each $i=1,2,\dots,m$. How we can compute $k^{th}$ smallest number in union of $A_i$s (i.e. $\cup_{i=1}^nA_i$) in at most $O(m\log mn)$?* $I.$ If I use Minheap to find $k^t{th}$ element, th running time will be $O(m+k\log mn)$, so that $k$ can be...
Returning $k^{th}$ smallest number in $m$ sorted arrays
|algorithms|
null
null
null
The usual way how you would prove that a TM halts on a given input is to write out its computation (ie what is the relevant content of the tape, and what is the current state, for each time step) culminating in it halting. It is possible to design a TM that will halt, and where there is a short proof that it will halt,...