instruction
stringlengths
0
29.8k
⌀
You are interested in the time `rec(i, j)` takes. If you look at the code, it doesn't depend on the contents of the `l` array, just on `i` and `j`. Just take each call to take time 1. Then, by the recursion, for the time $t_{i j}$ you have the recurrence: $$ t_{i + 1, j + 1} = t_{i + 1, j} + t_{i, j + 1} + t_{i, j} ...
Computer graphics is applied analytic geometry, and showing how games do their computations might be exactly the kind of motivating subject matter you are looking for.
null
In the CLRS book ([http://en.wikipedia.org/wiki/Introduction_to_Algorithms][1]) Chapter 26 (Maximum Flow) page 744 (third edition), there is the following equation - $ \sum\limits_{u \in U}e(u) = \sum\limits_{u \in U}\sum\limits_{v \in U}f(v, u) + \sum\limits_{u \in U}\sum\limits_{v \in \bar{U}}f(v, u) - \sum\li...
null
null
You are interested in the time `rec(i, j)` takes. If you look at the code, it doesn't depend on the contents of the `l` array, just on `i` and `j`. Just take each call to take time 1. Then, by the recursion, for the time $t_{i j}$ you have the recurrence: $$ t_{i + 1, j + 1} = t_{i + 1, j} + t_{i, j + 1} + t_{i, j} ...
As Yuval mentions, the datastructure is important here. I'll try to give a solution for some of the types of adjacency lists: 1. **Incoming edge list**: For each node, there is a list of vertices from which there is an incoming edge to this node. You can simply scan all vertices and check if the size of their adjac...
I'm just learning about Turing Machines, and I'm a bit confused by the difference in formal description between Wikipedia and my textbook. My textbook says the following: $$M=\langle Q,\Sigma,\Gamma,\delta,q_{0},q_{accept}, q_{reject} \rangle$$ where: 1. $Q$ is the set of states, 2. $\Sigma$ is the input a...
Is there a single valid definition for a Turing Machine, or is it mutable?
|turing-machines|
The ordering of the items in the 7-tuple M is completely immaterial to the behavior of the Turing machine. There is no "correct" or "incorrect" ordering; but I would say that both orderings are essentially the same definition. And I don't see that the blank character is treated any differently in the two definitions. I...
The ordering of the items in the 7-tuple M is completely immaterial to the behavior of the Turing machine. There is no "correct" or "incorrect" ordering; but I would say that both orderings are essentially the same definition. And I don't see that the blank character is treated any differently in the two definitions. I...
I believe the reason for favoring regular expressions over LALR(1) grammars for accepting simple grammars stems from the time needed to *build* an LALR(1) automaton. Let $m$ denote the size of the grammar which is used to build the automata for accepting the language defined by said grammar. If you need to build up the...
There are several valid definition of a Turing machine but they (the TM's) are all equivalent in power (they all compute the same functions). You could use the original definition (coined by Alan Turing himself in his paper "Computing Machinery and Intelligence". He describes the Turing machine in English. It's what a ...
null
The running time is exponential. As Yuval showed in his answer, we have $$f(i,j) = \begin{cases} O(1), & i = 0 \text{ or } j = 0, \\ f(i-1,j) + f(i,j-1) + f(i-1,j-1) + O(1), & \text{otherwise}. \end{cases}$$ Let's look at a $g = O(f)$ defined by $g(i,0)=g(0,i)=1$ and $g(i,j)= g(i,j-1) + g(i-1,j)$. This gives...
|algorithms|optimization|streaming-algorithm|online-algorithms|
The [Graham scan](http://en.wikipedia.org/wiki/Graham_scan) algorithm computes the convex hull of a finite sets of points. It works only in the plane but is also fast (time $O(n \log n)$). An old exam question asks, why does the algorithm not extend for three dimensional space? I just can't find an answer; it seems ...
Why does Graham Scan not extend to three dimensions?
|algorithms|computational-geometry|
I would like to know if there are some topics that could be covered in an undergraduate first-term course about analytic geometry, but related to Computer Science. I know that, for example, the simple equation for the line can be used for explaining linear regression or other topics in elliptic cryptography (too adv...
Overlap between computer science and analytic geometry?
|algorithms|graphs|
|regular-languages|efficiency|parsers|
|terminology|turing-machines|
|algorithms|algorithm-analysis|runtime-analysis|recurrence-relation|
The running time is exponential. As Yuval showed in his answer, we have $$f(i,j) = \begin{cases} O(1), & i = 0 \text{ or } j = 0, \\ f(i-1,j) + f(i,j-1) + f(i-1,j-1) + O(1), & \text{otherwise}. \end{cases}$$ Let's look at a $g = O(f)$ defined by $g(i,0)=g(0,i)=1$ and $g(i,j)= g(i,j-1) + g(i-1,j)$. This gives...
What is an algorithm to calculate the maximum "score" possible in a directed graph, with the constraint that edges with the same value can only be traversed once? For example, in the graph below, given that you can use each of *a*, *b*, and *c* once, the best path is to use *a* and *b* to get to 7, and *c* to get to 2,...
What is an algorithm to calculate the maximum "score" possible in a directed graph, with the constraint that edges with the same value can only be traversed once? For example, in the graph below, given that you can use each of *a*, *b*, and *c* once, the best path is to use *a* and *b* to get to 7, and *c* to get to 2,...
As mentioned before by other people the are variety of Turing machines with a little bit different definitions like : Two-way infinite tapes, Arbitrary numbers of read-write heads, Multiple tapes,... (link: http://plato.stanford.edu/entries/turing-machine/#Equiv). The point is that all of them are "equivalent" in theor...
One other topic that could be covered is numerical methods and algorithms. Efficient way of visualizing the multidimensional graphs, functions,....
As we know, using pumping lemma, we can easily prove the language L = {WW|W ∈ {a,b}*} is not a regular language. However, The language, L1 = {W1W2| |W1| = |W2|} is a regular language. Because we can get the DFA like below, DFA: --►((even))------a,b---------►(odd) ▲ ...
How can I tell a regular language?
|untagged|
well, there are things that a DFA can do, and things that DFA cannot do. A DFA is quite a simple machine, and it has no access to "memory". The only "memory" it has is its current state, i.e., a very limited memory. A DFA can do tasks that require *finite* amount of memory, but nothing more than that. To check if th...
As we know, using the pumping lemma, we can easily prove the language $L = \{ w w \mid w \in \{a,b\}^* \}$ is not a regular language. However, the language $L_1 = \{ w_1 w_2 \mid |w_1| = |w_2| \}$ is a regular language. Because we can get the DFA like below, DFA: --►((even))------a,b---------►(o...
|regular-languages|finite-automata|
How come {ww} isn't regular when {uv | |u|=|v|} is?
I have been posed with a question whereby a computer truncates binary to x number of digits. Due to this, if this computer is trying to store a decimal number which has a binary equivalent greater than x, it truncates the remaining digits producing a different binary number. However, this binary number is still an 'app...
Implications of truncation of data when converted into binary
|binary-arithmetic|storage|
null
It's a homework assignment, we were asked to read, understand, and present to our colleagues a short paper/article (suggested 4-6 pages) for our Computability, Decidability or Complexity class. The articles I was able to find in the past couple days using google scholar a way over what we were taught, plus, 50-100+ ...
Where can I find a short and 'easy' peer reviewed paper on something from computability, decidability or complexity?
|complexity-theory|computability|turing-machines|research|
It's a homework assignment, we were asked to read, understand, and present to our colleagues a short paper/article (suggested 4-6 pages) for our Computability, Decidability or Complexity class. The articles I was able to find in the past couple days using google scholar a way over what we were taught, plus, 50-100+ ...
"By definition" recent research papers usually contain non-trivial results and they often (always?) require a deep knowledge of the argument in order to be well understood, so if you pick a paper at random you'll probably find a bunch of obscure signs in your hands :-) So my suggestion is to look at "old" research p...
Assuming that **P** ≠ **NP**, **NPI** is the class of problems in **NP** without any polynomial time algorithms, but which are not **NP**-hard. I'm interested in problems in **NP**, such that 1. there is a candidate problem in **NPI** which is reducible to it, but without any known reverse reduction...
Natural NPI problems harder than other NPI problems
You are interested in the time `rec(i, j)` takes. If you look at the code, it doesn't depend on the contents of the `l` array, just on `i` and `j`. Just take each call to take time 1. Then, by the recursion, for the time $t_{i j}$ you have the recurrence: $$ t_{i + 1, j + 1} = t_{i + 1, j} + t_{i, j + 1} + t_{i, j} ...
Let's assume that $\mathsf{P} \neq \mathsf{NP}$. $\mathsf{NPI}$ is the class of problems in $\mathsf{NP}$ which are neither in $\mathsf{P}$ nor in $\mathsf{NP}$-hard. You can find a list of problems conjectured to be $\mathsf{NPI}$ [here][1]. [Ladner's theorem][2] tells us that if $\mathsf{NP}\neq\mathsf{P}$ then t...
Natural candidates for the hierarchy inside NPI
This question was analized in great length by Knuth in his "A Simple Program Whose Proof Isn't", see @InCollection{Knuth:1990:SPW:119872.119899, language = {english}, author = {Knuth, Donald E.}, title = {A Simple Program Whose Proof Isn't}, booktitle = {Beauty i...
The question of finding a binary fraction which can be transformed back to the same decimal fraction was analized at great length by Knuth in his "A Simple Program Whose Proof Isn't", see @InCollection{Knuth:1990:SPW:119872.119899, language = {english}, author = {Knuth, Donald E.}, ...
Given a regular language $L$, then it is easy to prove that there is a constant $N$ such that is $\sigma \in L$, with $\lvert \sigma \rvert \ge N$ there exist strings $\alpha$, $\beta$ and $\gamma$ such that $\lvert \alpha \beta \rvert \le N$ and $\lvert \beta \rvert \ne \epsilon$, and for all $k$ it is $\alpha \beta^k...
Languages that satisfy the pumping lemma but aren't regular?
|formal-languages|proof-techniques|
$\{ \$ a^nb^n \mid n \ge 1 \} \cup \{ \$^kw \mid k\neq 1, w\in \{a,b\}^* \}$ seems to be simple. The second part is regular (and can be pumped). The first part is nonregular, but can be pumped "into" the second part by choosing $\$$ to pump.
Assuming "older" papers are ok, what about Stephen Cook's well known *The Complexity of Theorem-Proving Procedures* [1]? It is 8 pages long, and if for the most part you have been able to keep up in your computability class, you can likely keep up with this paper as well. A copy is freely available from the [author's...
The standard answer to this was given by Bentley in ["Programming Pearls"][1]: Sort this way [horizontal hand wave] then this way [vertical wave]. In more detail: - For each word in your dictionary, set up a signature computed by sorting its letters - Sort the dictionary by signatures The set of anagrams ar...
You can also consider an algebraic graph theoretic approach. The diameter $\text{diam}(G)$ is the least integer $t$ s.t. the matrix $M=I+A$ has the property that all entries of $M^t$ are nonzero. You can find $t$ by $O(\log n)$ iterations of matrix multiplication. The diameter algorithm then requires $O(M(n) \log n)$ t...
I have been reading on converting first order logic sentences to conjunctive normal form, and then performing resolution. One of the steps of converting to CNF, is to Standardize variables: rename all variables so that each quantifier has its own unique variable name. Most general Unifier is the least specialized...
MGU and Variable Standardization - CNF
|logic|artificial-intelligence|knowledge-representation|first-order-logic|
So as to optimize an application, I must implement data caching: not to recompute some data - those heavy on cpu but that don't change often. When playing with the idea, I imagined something like the way win32/MFC manages the windows screen i.e.: - While a part is valid, it is not repainted. - When a rectang...
Cache strategies, what reference article could I study?
|optimization|
How can i prove that the cover time for a directed graph G can be exponential in the size of G.
null
How can I prove that the cover time for a directed graph G can be exponential in the size of G?
The best overall view on optimization I've seen is Bentley's "Writing efficient programs" (sadly out of print), the medular part of its rules are in his ["Programming pearls"][1]. For analysis of the algorithms I'd dig into Cormen et al "Introduction to Algorithms" (don't let the "introduction" fool you, it is more an ...
I'd look at the "further reading" suggestions in your textbook. If the author made some effort here, the papers listed should be on-topic, important, and probably accessible.
For C, Bentley's ["Programming pearls"][1] discusses some pitfalls and gives an (oldish) program to measure costs of several operations. For Java and other JITed languages it's more of a challenge, as the first run of the operation will get it compiled to native code and run that way. In general, the only really rel...
Each TM can be described by a finite string of symbols (the examples of TMs described in textbooks or elsewhere should give a good idea of how to do it with a limited supply of symbols). Any set of finite-length strings made of a finite set of symbols is countable. To get some non-countable set of machines would requir...
It depends on what you are measuring. A well-designed P2P network will spread the load among the members evenly, so the maximal load is just a fraction of the case in an C/S system (where all traffic goes to the server). In terms of total traffic, P2P uses more, as there is no guarantee that the answer to a question is...
The best strategy to find best suitable algorithms for caching is to read "survey" paper in this area. I recommend the paper: A survey of Web cache replacement strategies (http://dl.acm.org/citation.cfm?id=954341) which reviews many general techniques for caching.
This is an interesting history article titled: "A Short History of Computational Complexity" which will give you a big picture in this area. http://people.cs.uchicago.edu/~fortnow/papers/history.pdf
Let's assume that $\mathsf{P} \neq \mathsf{NP}$. $\mathsf{NPI}$ is the class of problems in $\mathsf{NP}$ which are neither in $\mathsf{P}$ nor in $\mathsf{NP}$-hard. You can find a list of problems conjectured to be $\mathsf{NPI}$ [here][1]. [Ladner's theorem][2] tells us that if $\mathsf{NP}\neq\mathsf{P}$ then t...
Looking at the pdf Fundamentals of Computing Series pdf: "[The Stable Marriage Problem][1]" Theorem 1.2.3 on page 12: > In a man-optimal version of stable matching, each woman has worst > partner that she can have in any stable matching. and proof: > Suppose not. Let M0 be the man-optimal stable matc...
Stable Matching Problem Proof
|algorithms|proof-techniques|matching|
The claim is not that every woman ends with the last man on her list. Rather, consider *all* stable matchings, and all partners of some woman $w$ in these stable matchings. Among them, pick the worst one (according to her view) $m$. Then in the man-optimal matching, $w$ is matched to $m$. Now that you understand wha...
obviously the "Finding an $n/2$ size clique in a directed/ non directed graph" is not $\sf NL$ but I'd really like to understand where does it fall in terms of the definition of the $\sf NL$ definition. I have to have an input and witness tapes, both of them can be polynomial and a logarithmic size of work stripe. S...
How come finding an $n/2$ size clique in a directed/ non directed graph is not in $\sf NL$?
|complexity-theory|time-complexity|
null
The ideal random permutation of Fisher and Yates (Algorithm P in Knuth vol.2) requires for a sequence of n objects n-1 random numbers. Is there a random permutation operation requiring only one (or two) random numbers that has the best performance of its genre?
Best random permutation employing only one random number
|permutations|
(Turning my comments into an answer.) You have to deterministically verify that the $\mathcal{O}(n)$ vertices on your _witness tape_ form a clique. Since you can only move to the right, you can only do linear amount of work for this set, however there are $\mathcal{O}(n^2)$ _pairs of vertices_ in the clique, and yo...
I am looking at the document _Fundamentals of Computing Series_, [The Stable Marriage Problem][1]. Theorem 1.2.3 on page 12: > In a man-optimal version of stable matching, each woman has worst > partner that she can have in any stable matching. Proof: > Suppose not. Let $M_0$ be the man-optimal stable m...
Proof of the Stable Matching Problem
null
The ideal random permutation algorithm of [Fisher and Yates][1] (Algorithm P in Knuth vol.2) for a sequence of $n$ objects requires $n-1$ random numbers. Is there a random permutation operation requiring only one (or two) random numbers and has the best performance of its genre? [1]: http://en.wikipedia.org/wi...
can anyone prove that the following is a CFL? or not? why? <br><br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;L={w=w1w2 $ len(w1)=len(w2) and w1 does not equal w2} Tanx everyone!
could anyone prove that this is a context free language or not?
|untagged|