instruction
stringlengths
0
29.8k
⌀
null
|algorithms|algorithm-analysis|runtime-analysis|recurrence-relation|
I am trying to analyze the running time of a bad implementation of generating the $n$th member of the fibonacci sequence (which requires generating the previous 2 values from the bottom up). Why does this algorithm have a time complexity of $\Omega(2^{\frac{n}{2}})$? Where does the exponent come from?
Why does a recurrence of $T(n - 1) + T(n - 2)$ yield something in $\Omega(2^{\frac{n}{2}})$?
|algorithms|algorithm-analysis|asymptotics|runtime-analysis|recurrence-relation|
I am not sure this SE website is the best place to ask this but I couldn't think of any better one. Feel free to migrate! Is there an explanation Christofides's Heuristic for solving TSP which does not simply state the algorithm and go ahead to prove the bound? To be specific: (Disclaimer : I am an engineer who ...
A Good Resource for Christofides' Heuristic
|algorithms|heuristics|
Expanding on Reza's answer, every recurrence of the form $T(n) = T(n-1) + T(n-2)$, with arbitrary initial values, has a solution of the form $$ T(n) = A \left( \frac{1+\sqrt{5}}{2} \right)^n + B \left( \frac{1-\sqrt{5}}{2} \right)^n, $$ for some $A,B$. Note that $|(1-\sqrt{5})/2| < 1$, and so the second term tends to...
null
In the long run, it's really better to understand the graph theory terminology, but for now, here is an explanation of Christofides's algorithm. I'm not an expert in this area so I can't offer much by way of intuition. Also, I should note that by now, better algorithms are known for some variants, see for example the [...
There are at least three encodings of (aspects of) [Category Theory in Coq][1]. Approaches using a proof assistant guarantee correctness by design, though I don't know whether they will enhance understand. You'll then have both the proof assistant and Category Theory to learn. If you want a reasonably introductory,...
**I am developing a chart and graph library and am having trouble developing an algorithm.** **This is not a homework assignment for a student. See my open source project: https://github.com/eddieios/CoreChart The algorithm is to space the Y axis labels in a given coordinate graphical space. It should space the ...
Algorithm for graphically spacing items
|algorithms|
null
null
If you are referring to the problem of deciding whether a formula given in $2-DNF$ form is satisfiable, then it is in $P$, as well as general $DNF$ satisfiability. Indeed, such a formula is satisfiable iff there is a clause that does not contain an inner contradiction. That is, a clause that does not contain both $p$ a...
I want to know whether 2-DNF problem is NP-cpmplete or not? if it is NP-complete, can anyone provide the proof?
About whether 2-DNF is NP-complete or not
|np-complete|
A path from the last node to the leaf would always be a longest path. This is because the last node is always at the lowest level in the heap. Now, assume the root is at level $0$. Then the number of nodes at a completely filled level $i$ would be $d^i$. Let level $k$ be the last completely filled level in the he...
An additional note to Shaull's answer. Checking if a DNF formula $\phi$ is *valid* (i.e. is a *tautology*) is co-NP-complete. Indeed a formula $\phi$ is valid if and only if its negation is not satisfiable. But if you negate a DNF formula and apply De Morgan's laws you get a CNF formula. So the problem is equival...
null
I am having trouble understanding the concept of AI. Is AI just a software that uses Probability, Linear Algebra and some advanced Mathematics to make independent decision ? Please give me some simple examples of AI.
Simple examples of Artificial Intelligence
|artificial-intelligence|
There is no proof that a computer can make an "independent decision". In fact, there is no real proof that humans can, either... Perhaps the AI "holy grail" is the Turing-Test: http://en.wikipedia.org/wiki/Turing_test In practice, AI covers, or touches a wide range of topics, from theorem-proving, planning, deci...
null
the now standard simple example of this is [CAPTCHAs](http://en.wikipedia.org/wiki/CAPTCHA) which stands for "Completely Automated Public Turing test to tell Computers and Humans Apart" which was intentionally devised in the theoretical community partly to detect/deflect automated spammers. however, the technology can ...
null
you can find for **Every linear recurrence with constant coefficients** a closed form. (See the [link][1]) the [Fibonacci][2] numbers have a closed-form solution as (the approximation is for large ns): $F_n \times \sqrt{5} ={ \left( \frac { 1+\sqrt { 5 } }{ 2 } \right) }^{ n }-{ \left( \frac { 1-\sqrt { 5 } }{ 2...
null
This should probably be migrated to cs.stackexchange.com. Meanwhile: You are missing an important nuance. How would you know if the message is only 2 bits, or if it's part of a bigger message? For that, you must also encode a bit that says that the message starts, and a bit that says it ends. This bit should be a n...
I read on Wikipedia and in lecture notes that if a lossless data compression algorithm makes a message shorter, it must make another message longer. E.g. In this set of notes, it says: > Consider, for example, the 8 possible 3 bit messages. If one is > compressed to two bits, it is not hard to convince yourself ...
Lossless data compression must make some messages longer?
|data-structures|
null
null
In boolean circuit complexity, a circuit is just defined by a Directed Acyclic Graphs with designated input and output nodes, where the intermediate nodes compute a specific boolean function. A circuit is called a formula if the underlying graph is a tree. i.e., the fan-out of each node is $1$. Is it true that for a fo...
Formulas vs Circuits
|complexity-theory|circuits|
This question is not homework but it's related to material in a general course I take about programming languages, so I don't know whats the site policy about this In ML the following expression: fun f x y z = x (y , z) = x (z, y) ; Evaluates to this: val ('a, ''b) f = fn : ('a * 'a -> ''b) -> 'a ->...
How is the following ML Curry expression evaluated
|programming-languages|functional-programming|
I think you should consider the (binary) messages of length **up to** a certain value, say $n$. Then you have $2^{n+2}-1$ messages, which you have to map onto the same $2^{n+2}-1$ messages, if you don't permit "compressed" messages with more than $n$ bits. In other words, your compression is a permutation $f$. Any word...
The now standard simple example of this is [CAPTCHAs](http://en.wikipedia.org/wiki/CAPTCHA) which stands for "Completely Automated Public Turing test to tell Computers and Humans Apart" which was intentionally devised in the theoretical community partly to detect and deflect automated spammers. However, the technology ...
No. Take for example $\mathsf{AC^0}$. It is polynomial-size bounded-depth circuits. Being DAG or tree doesn't change the class. The fan-in can be arbitrarily large. If the fan-in is bounded we end-up with $\mathsf{NC^0}$ which is much weaker. It cannot compute any function where the output depends on more than a bo...
It seems that what you are confused about is the common practice of *Curryfication*: the function $$ (\alpha\times \alpha\rightarrow \beta)\rightarrow \alpha\rightarrow \alpha\rightarrow \mathrm{bool} $$ Is parenthesized as: $$ (\alpha\times \alpha\rightarrow \beta)\rightarrow (\alpha\rightarrow (\alpha\rightarr...
How does the code in the vbs file get converted into machine instructions? What is in between the vbs file and the processor?
How does a *.vbs script work?
|compilers|
{"Voters":[{"Id":4249,"DisplayName":"Pål GD"},{"Id":69,"DisplayName":"Patrick87"}]}
null
One possible approach which does not require any hairy arguments is to come up with a "nicety" measure, find a range of offsets, and choose the best one. Usually rounding errors are accounted for by taking a $\pm 1$ (in your case $\pm 5$) modification from the starting point. In your case, you would calculate the nicet...
You are missing an important nuance. How would you know if the message is only 2 bits, or if it's part of a bigger message? For that, you must also encode a bit that says that the message starts, and a bit that says it ends. This bit should be a new symbol, because 1 and 0 are already used. If you introduce such a symb...
null
fan-in in a circuit tree/formula (ie outdegree=1 as you mention) is limited by the number of input variables. a node/gate cannot connect to more than the input variables. however note that often in many constructions, indegree is limited to 2, and gates are combined using the simple rule $a \wedge b \wedge c$ = $(a \we...
Is there an explanation Christofides's Heuristic for solving TSP which does not simply state the algorithm and go ahead to prove the bound? To be specific: (Disclaimer : I am an engineer who knows very little about graph theory but need this for a logistics course) - I understand that I first create an MST. So f...
|algorithms|heuristics|graph-traversal|
|data-structures|data-compression|
|programming-languages|functional-programming|typing|
Suppose I have a script (`.vbs`, for example) that is stored in a file. How does the code in the file get converted into machine instructions? What is between the vbs file and the processor?
How does interpreting a script work?
|programming-languages|compilers|interpreters|
{"Voters":[{"Id":39,"DisplayName":"Gilles"}]}
null
That depends on a lot of factors. If it is a pure interpreter (like most shells), the interpreter reads each line/instruction, analyzes it, and executes it. If it is a pure compiler, the program (or a part of it) is read in, analyzed, and then the machine language is written out to run later. Many programming languages...
|formal-languages|context-free|formal-grammars|check-my-proof|
null
In 2009 Doron has published a paper stating "Using 3000 hours of CPU time on a CRAY machine, we settle the notorious P vs. NP problem in the affirmative, by presenting a “polynomial” time algorithm for the NP-complete subset sum problem.". I've been looking for other people's opinions on this but I haven't found anythi...
Doron ZEILBERGER's P = NP computer proof
|complexity-theory|np-complete|
That paper is a hoax. If you look, it just throws numbers around for a _huge_ polynomial bound, purports to solve a problem by "Laurent polynomials" without _any_ clue on how they relate to the problem, shifts to integrals and estimates them by numerical means "sufficiently precisely" (and that is supposed to give the ...
So, I know that testing if a regular language $R$ is a subset of regular language $S$ is decidable, since we can convert them both to DFAs, compute $S \cap \bar{R} $, then test if this language is empty. However, since this requires converting to DFAs, it's possible that the DFAs, and thus the testing algorithm, wil...
Is there a efficient test for if an NFA accepts a subset of another NFA?
|algorithms|regular-languages|automata|np-complete|decision-problem|
The problem of deciding language containment in NFAs is $PSPACE$-complete. To prove this, it is easy to reduce from the universaility problem for NFAs (testing whether $L(A)=\Sigma^*$) So, in a way, you have to determinize, but you may do so on-the-fly. You observation about co-NP is wrong (but nice). Such a witne...
So, I know that testing if a regular language $R$ is a subset of regular language $S$ is decidable, since we can convert them both to DFAs, compute $S \cap \bar{R} $, then test if this language is empty. However, since this requires converting to DFAs, it's possible that the DFAs, and thus the testing algorithm, wil...
In my opinion, that's all you can really say about them. The idea is that in a higher-order language, a function is just another kind of value. The same way you can have (3+4) without an identifier in C, you can have (lambda (x) +(3 x))) without an identifier in scheme. The key here isn't that there's anything sp...
Can I use principles of set theory in order to solve the following question? > For every $A,B \in \mathsf{co\text{-}RE}$ with $A \cap B = \emptyset$, there is a separating language $C$ with $A \subseteq C$ and $B \cap C = \emptyset$ so that $C$ is recursive.
|terminology|artificial-intelligence|
There is no proof that a computer can make an "independent decision". In fact, there is no real proof that humans can, either... Perhaps the AI "holy grail" is the [Turing-Test](http://en.wikipedia.org/wiki/Turing_test). In practice, AI covers, or touches a wide range of topics, from theorem-proving, planning, de...
|complexity-theory|np-complete|satisfiability|
I want to know whether the 2-DNF problem is NP-complete or not? If it is NP-complete, can anyone provide a proof?
Is 2-DNF is NP-complete?
|complexity-theory|logic|circuits|
Many a times if the complexities are having constants such as 3n, we neglect this constant and say O(n) and not O(3n). I am unable to understand how can we neglect such three fold change? Some thing is varying 3 times more rapidly than other! Why do we neglect this fact?
Justification for neglecting constants in Big O
|complexity-theory|
We are going over the pumping lemma in class and we recently went over the following example: 1. Let $$ L = \{ w \mid w \text{ has a different number of 0s and 1s} \} $$ 2. Consider $$ s = 0^P1^\left(P+P!\right) $$ 3. $ s $ can be divided into $ s = xyz $ 4. Consider $$ y = 0^m; 0 \leq m \leq P $$ 5. Let ...
Factorial usage within proof using the pumping lemma
|pumping-lemma|
$f(n)=O(g(n))$ means $\lim\limits_{n\to\infty} \frac{f(n)}{g(n)}<+\infty$. If this is true for $g(n)=n$, this is true for $g(n)=3n$ as well, and vice versa. Similarly, $O(n^2)=O(.00005321n^2+1000000000n+10^{46803})$. Here the equality means that $f$ belongs to the LHS iff it belongs to the RHS. The $=$ sign here ...
Recall the definition of Big-O: $f(n)\in O(g(n))$ iff there exists $c>0$ such that $f(n)\le cg(n)$ for all $n$. Under this definition, we have that $dn\in O(n)$ for every constant $d$. The purpose of the $O$ notation is exactly to simplify expressions in this manner. Indeed, $3n$ grows 3 times as fast as $n$, but...
$f(n)=O(g(n))$ means $\limsup\limits_{n\to\infty} \frac{f(n)}{g(n)}<+\infty$. If this is true for $g(n)=n$, this is true for $g(n)=3n$ as well, and vice versa. Similarly, $O(n^2)=O(.00005321n^2+1000000000n+10^{46803})$. Here the equality means that $f$ belongs to the LHS iff it belongs to the RHS. The $=$ sign he...
I am trying to define a non terminal symbol in a LALR(1) grammar (with CUP parser). It is requested that the <code> token must appear exactly two times, while <hour> token must appear at least one time. In the end I came up with this definition: section ::= hour_l CODE SC hour_l CODE SC ...
How to define at least one occurrence of a string between two tokens in bottom up LALR(1) parser grammar
|formal-grammars|parsing|
As you propably know, a process (in terms of process algebra like CSP) can consume an input and will the behave like another process (unless it is a process that does not accept input, usually called STOP). You can construct a graph where the nodes are the processes and the outgoing edges the input that the node can...