instruction
stringlengths
0
29.8k
⌀
Repost from Stack Overflow: I'm going through past exams and keep coming across questions that I can't find an answer for in textbooks or on google, so any help would be much appreciated. The question I'm having problems with at the moment is as follows: >Given a regular expression (a|bb)*, derive an estimate ...
Cost in time of constructing and running an NFA vs DFA for a given regex
|regular-languages|automata|finite-automata|compilers|
Normally universities teach discrete math / discrete structure. My question is, how much math does one need to know to understand this area? Is calculus required or will precalculus do just fine? Does one need to have done proofs before to be able to understand this area? Thank you all for your answers. Note: My ...
How much math does one need to know to understand discrete math/structures for computer science?
|discrete-mathematics|
null
Surely spatial and amorphous computing share similarities and overlap. Is spatial computing a subset of amorphous computing? How are the two different?
How is amorphous computing different from spatial computing?
|complexity-theory|distributed-systems|parallel-computing|agent-based-computing|
|distributed-systems|parallel-computing|agent-based-computing|
Discrete Maths contains Sets, Relations, Trees, Graphs, Boolean Algebra etc. which are some conceptual Topics not Calculus. Discrete Math is very useful as view of Programming.
> Show that L={a^(n^2) | n >= 0} is not regular Hey guys. I'm taking a CS class and this stuff is really new to me so bear with me. I tried to look if I get some contradiction by using the pumping lemma for regular languages and I worked it out like this: > Suppose L is regular. Then there must be a natural num...
Proof that a^(n^2) is not regular
|pumping-lemma|
You can't deduce that $uv = a^{k^2}$, all that the pumping lemma gives you is that $|uv| \leq m$. Not all numbers less than $m$ are squares. Not only that, but even supposing that $uv = a^{k^2}$, there is no reason to assume that $v = a^{2k-1}$; all the pumping lemma gives you is that $v$ is non-empty. Finally, in orde...
> Show that $L=\{a^{n^2} | n \geq 0\}$ is not regular Hey guys. I'm taking a CS class and this stuff is really new to me so bear with me. I tried to look if I get some contradiction by using the pumping lemma for regular languages and I worked it out like this: > Suppose $L$ is regular. Then there must be a nat...
Proof that $a^{n^2}$ is not regular
null
Surely [spatial computing][1] and [amorphous computing][2] share similarities and overlap. Is spatial computing a subset of amorphous computing? How are the two different? [1]: http://www.spatial-computing.org/ [2]: http://en.wikipedia.org/wiki/Amorphous_computing
there is a very tricky aspect of all garbage collectors that might be glossed over in some descriptions, and that is the "full scan" or "full collect". periodically, randomly, intermittently they must scan all objects. generational collectors are better at postponing the full scan and minimizing its duration, but it is...
there is a very tricky aspect of all garbage collectors that might be glossed over in some descriptions, and that is the "full scan" or "full collect". periodically, randomly, intermittently they must scan all objects. generational collectors are better at postponing the full scan and minimizing its duration, but it is...
there is a very tricky aspect of all garbage collectors that might be glossed over in some descriptions, and that is the "full scan" or "full collect". periodically, randomly, intermittently they must scan all objects. generational collectors are better at postponing the full scan and minimizing its duration, but it is...
As far as I know, the more collision-resistant a hash function is, the better. But is there any way to define a hash function with *predicted* collisions? In other words, a hash function that collides for some known set of possible inputs and avoids collisions for other input values. To state the problem simplier: L...
|regular-languages|pumping-lemma|
Can anyone suggest me a linear time algorithm that takes as input a directed acyclic graph $G=(V,E)$ and two vertices $s$ and $t$ and returns the number of simple paths from $s$ to $t$ in $G$. I have an algorithm in which I will run a DFS(Depth First Search) but if DFS finds $t$ then it will not change the color(fro...
Algorithm that finds the number of simple paths from $s$ to $t$ in $G$
|algorithms|graphs|
Can anyone suggest me a linear time algorithm that takes as input a directed acyclic graph $G=(V,E)$ and two vertices $s$ and $t$ and returns the number of simple paths from $s$ to $t$ in $G$. I have an algorithm in which I will run a DFS(Depth First Search) but if DFS finds $t$ then it will not change the color(fro...
I'm using the book Introduction to Computer Science by John Zelle and at the end of Chapter 3 (Computing with numbers), I'm asked to find the nth term of a Fibonacci sequence presumably using a definitive for loop, as no other decision structure has been introduced yet. Is this possible? I've tried everything I cou...
Is it possible to find the nth term of a Fibonacci sequence using a definitive for loop?
|untagged|
|algorithms|imperative-programming|
I'm using the book Introduction to Computer Science by John Zelle and at the end of Chapter 3 (Computing with numbers), I'm asked to find the nth term of a Fibonacci sequence presumably using a definitive for loop, as no other decision structure has been introduced yet. Is this possible? I've tried everything I cou...
If you only have to use a for loop that iterates until it finds the n-th Fibonacci number, you could use something like this: int fib(int n) { int p = 0; int c = 1; for (int i = 1; i < n; i++) { int next = p + c; p = c; c = next; ...
If you only have to use a for loop that iterates until it finds the n-th Fibonacci number, you could use something like this: int fib(int n) { int p = 0; int c = 1; int r = 0; // The result is initialized to 0 (undefined). for (int i = 0; i < n; i++) { ...
If it is only the third chapter, I doubt the authors have covered dynamic programming, but I will illustrate what is going on when a for loop is used to compute the $n^\text{th}$ Fibonacci number, $F_n$. Recall the definition, $$F_n = \begin{cases} 0 & n = 0\\ 1 & n = 1\\ F_{n-1} + F_{n - 2} & \text{otherwise} ...
If it is only the third chapter, I doubt the authors have covered dynamic programming, but I will illustrate what is going on when a for loop is used to compute the $n^\text{th}$ Fibonacci number, $F_n$. Recall the definition, $$F_n = \begin{cases} 0 & n = 0\\ 1 & n = 1\\ F_{n-1} + F_{n - 2} & \text{otherwise} ...
If it is only the third chapter, I doubt the authors have covered dynamic programming, but I will illustrate what is going on when a for loop is used to compute the $n^\text{th}$ Fibonacci number, $F_n$. Recall the definition, $$F_n = \begin{cases} 0 & n = 0\\ 1 & n = 1\\ F_{n-1} + F_{n - 2} & \text{otherwise} ...
If it is only the third chapter, I doubt the authors have covered dynamic programming, but I will illustrate what is going on when a for loop is used to compute the $n^\text{th}$ Fibonacci number, $F_n$. Recall the definition, $$F_n = \begin{cases} 0 & n = 0\\ 1 & n = 1\\ F_{n-1} + F_{n - 2} & \text{otherwise} ...
null
you only need to notice that the number of path from one node to the target node is the sum of the number of path from its children to the target. You know that this algorithm will always stop because your graph doesn't have any cycles. Now, If you save the number of path from one node to the target as you visit the...
I am self-learning [proof assistants][1] and decided to start on some basic proofs and work my way up. Since proofs are based on other proofs and so form a hierarchy, is there a repository of the hierarchy of proofs? I know I can pick a particular proof-assistant and analyze it's library to extract its hierarchy, ho...
Is there a repository for the hierarchy of proofs?
|reference-request|proof-assistants|
Computing the number of $s$-$t$ paths in a DAG is given by the recurrence, $$\text{Paths}(u) = \begin{cases} 1 & \text{if } u = t \\ \sum_{(u,v) \in E} \text{Paths}(v) & \text{otherwise.}\\ \end{cases}$$ A simple modification of DFS will compute this given as def dfs(u, t): if u == t: ...
null
|machine-learning|probability-theory|statistics|
I think that answer depends slightly on the curriculum and the teaching method for the class (Discrete Math). If this is an undergraduate class, thought from Kenneth Rosen's book it usually does not require much pre-requisite at all beyond standard math classes. I would say that the only pre-requisite is understandi...
For proofs, hands down: [How to Prove it: A Structured Approach][1] by Daniel Velleman. It has the best paced and detailed introduction into proving techniques. I read many books on the subject of proofs, but this one helped me really get the hang of it. More introductory reading would be "[How to think like...
I am curious as to how one might *very compactly* compress the domain of an arbitrary [IDN](http://en.wikipedia.org/wiki/Internationalized_domain_name) hostname (as defined by [RFC5890](http://tools.ietf.org/html/rfc5890)) and suspect this could become an interesting challenge. A Unicode host or domain name (U-label) c...
Of large sparse biparite graphs (say degree 4) with N verticies, roughly speaking, which of them cause the worst case running time of the [Hopcroft-Karp algorithm](https://en.wikipedia.org/wiki/Hopcroft%E2%80%93Karp_algorithm)? What is their general structure and architecture, and why does it cause a problem? Furthe...
Worst-case sparse graphs for Hopcroft-Karp Algorithm
|algorithms|graphs|algorithm-analysis|runtime-analysis|
As far as I know, the more collision-resistant a hash function is, the better. But is there any way to define a hash function with *predicted* collisions? In other words, a hash function that collides for some known set of possible inputs and avoids collisions for other input values. To state the problem simpler: Le...
null
null
I wonder how come that the following language is in $R$. $L_{M1}=\{\langle M_2\rangle|M_2\ is\ a\ TM, L(M_1)=L(M_2)\ and\ |\langle M_1\rangle| > | \langle M_2 \rangle| \} $ (I know that it's in $R$ since there's an answer for this multi-choice question, but without explanation). I immediately thought that the ...
Why $L_{M1}=\{\langle M_2\rangle|M_2\ is\ a\ TM, L(M_1)=L(M_2)\ and\ |\langle M_1\rangle| > | \langle M_2 \rangle| \} \in R $?
|undecidability|
It is in $R$ simply because the number of machine descriptions smaller than a given machine description is finite and any finite language is in $R$.
(in addition to all the great books that others have recommended) For proofs, hands down: [How to Prove it: A Structured Approach][1] by Daniel Velleman. It has the best paced and detailed introduction into proving techniques. I read many books on the subject of proofs, but this one helped me really get the ...
$L_{M_1}$ is in $R$ simply because the number of machine descriptions smaller than a given machine description is finite and any finite language is in $R$.
I am self-learning [proof assistants][1] and decided to start on some basic proofs and work my way up. Since proofs are based on other proofs and so form a hierarchy, is there a repository of the hierarchy of proofs? I know I can pick a particular proof-assistant and analyze it's library to extract its hierarchy, ho...
null
[ProofWiki][1] contains a decent amount of proofs from various areas of mathematics. It is by no means complete, but is a good starting point for what you want. [1]: http://www.proofwiki.org/
> What is the time complexity of finding the diameter of a graph > $G=(V,E)$? > > - ${O}(|V|^2)$ > - ${O}(|V|^2+|V| \cdot |E|)$ > - ${O}(|V|^2\cdot |E|)$ > - ${O}(|V|\cdot |E|^2)$ The diameter of a graph $G$ is the longest distance between two vertices in graph. I have no idea what to do about it, I ne...
I think you've hit the nail on the head with your comment. It's not true that in any functional language maps can be parallelized - the language must be [pure](http://en.wikipedia.org/wiki/Purely_functional). (I believe Haskell is the only vaguely mainstream purely functional language. Lisp, OCaml and Scala are all ...
Your current implementation will compute the correct number of paths in a DAG. However, by not marking paths it will take exponential time. This can be handled with dynamic programming. Computing the number of $s$-$t$ paths in a DAG is given by the recurrence, $$\text{Paths}(u) = \begin{cases} 1 & \text{if }...
I wonder how come that the following language is in $\mathrm R$. $L_{M_1}=\Bigl\{\langle M_2\rangle \;\Big|\;\; M_2 \text{ is a TM, and } L(M_1)=L(M_2), \text{ and } |\langle M_1\rangle| > | \langle M_2 \rangle| \Bigr\} $ (I know that it's in $\mathrm R$ since there's an answer for this multi-choice question, but...
For a Turing Machine $M_1$, how is the set of machines $M_2$ which are "shorter" than $M_1$ and which accept the same language decidable?
null
Your current implementation will compute the correct number of paths in a DAG. However, by not marking paths it will take exponential time. For example, in the illustration below, each stage of the DAG adds another multiple of 3 to the total number of paths. This exponential growth can be handled with dynamic programmi...
see the [TPTP archive](http://www.cs.miami.edu/~tptp/), thousands of problems for theorem proving & is somewhat standard in the field. this is more the "nodes" of the theorem graph you are asking about. some papers referring to the archive may have explored the edges in this graph. note that in the field of ATM, aut...
I am self-learning [proof assistants][1] and decided to start on some basic proofs and work my way up. Since proofs are based on other proofs and so form a hierarchy, is there a repository of the hierarchy of proofs? I know I can pick a particular proof-assistant and analyze it's library to extract its hierarchy, ho...
Preface: I asked this question yesterday, so don't assume I know what I'm talking about. This should get you on the right path (I hope), but don't take it as fact. From my understanding of it, the cost in time (or memory) is based on orders of complexity. As per: http://en.wikipedia.org/wiki/Regular_expression#Imp...
null
Preface: I asked this question yesterday, so don't assume I know what I'm talking about. This should get you on the right path (I hope), but don't take it as fact. From my understanding of it, the cost in time (or memory) is based on orders of complexity. As per: http://en.wikipedia.org/wiki/Regular_expression#Imp...
In Chapter 9 of the Dragon Book, the authors describe the dataflow framework for global analysis (described also in [these slides][1]). In this framework, an analysis is defined by a set of transfer functions, along with a [meet semilattice][2]. At each step of the iteration, the algorithm works by maintaining two ...
Dataflow framework for global analysis: Why meet, then apply?
|compilers|program-optimization|
I've been visiting all the links provided by Nick. They do look wonderful indeed and I have added all those sites to my bookmarks. Hope that the following link especially designed to test search algorithms suits your needs as well: [Pathfinding Benchmarks][1] by Nathan Sturtevant. It contains various maps from diffe...
I've been visiting all the links provided by Nick. They do look wonderful indeed and I have added all those sites to my bookmarks. Hope that the following link especially designed to test search algorithms suits your needs as well: [Pathfinding Benchmarks][1] by Nathan Sturtevant. It contains various maps from diffe...
null
How can I prove that a set is complete for Pi_2 complete? Can you give me an example proof? Say for All_TM = Turing machines whose accepted language is all strings?
How to show a set is Pi_2 complete
|computability|
How can I prove that a set is complete for $\Pi_2$ complete? Can you give me an example proof? Say for $All_{TM}$ = Turing machines whose accepted language is all strings?
How to show a set is $\Pi_2$ complete
null
null
In the article [Parsing Expressions by Recursive Descent by Theodore Norvell (1999)](http://www.engr.mun.ca/~theo/Misc/exp_parsing.htm) the author starts with the following grammar for arithmetic expressions: $$E ~\to~ E ~~\mbox{"+"}~ E ~\mid~ E ~~\mbox{"-"}~ E ~\mid~ E ~~\mbox{"*"}~ E ~\mid~ E ~~\mbox{"/"}~ E ~\mid...
$F=\{\langle M \rangle: M$ is a turing macgine which stops on every input in no more than 50 steps $\}$. I need to decide whether $F$ is decidable or recursive enumerable. This "50 steps" part immediate turns the $R$ sign for me, I know that if it was for specific input it was decidable for sure, but here it's ...
$Does F=\{\langle M \rangle: M$ is a turing macgine which stops on every input in no more than 50 steps $\}$ decidable?
|undecidability|
null
$F=\{\langle M \rangle: M$ is a turing macgine which stops on every input in no more than 50 steps $\}$. I need to decide whether $F$ is decidable or recursive enumerable. This "50 steps" part immediate turns the $R$ sign for me, I know that if it was for specific input it was decidable for sure, but here it's ...
In the article [Parsing Expressions by Recursive Descent by Theodore Norvell (1999)](http://www.engr.mun.ca/~theo/Misc/exp_parsing.htm) the author starts with the following grammar for arithmetic expressions: $\qquad \displaystyle E\ \to\ E\ \mathtt{+}\ E ~\mid~ E\ \mathtt{-}\ E ~\mid~ E\ \mathtt{*}\ E ~\mid~ E \ ...