instruction stringlengths 0 29.8k ⌀ |
|---|
null |
We are given a graph with $n$ vertices, $m$ edges, and path edge costs of $x$. For vertices without a direct path that are distant exactly one neighbor, we can add new edge with edge cost $y$. Our task is to find shortest path (i.e minimum cost) between the start vertex and all others vertices.
I have developed an a... |
null |
null |
Let's begin with a 2D infinite memory.
point (0,0) is 0. Then, we go in "circles" around the (0,0) so that we cover all the plane. Each "step" increases the image index by one..
$walk \equiv (x,y) : (0,0) \to (1,0) \to (1,1) \to (0,1) \to (-1,1) \to \cdots$
See the image in:
* http://www.cut-the-knot.org/do_you... |
|turing-machines|simulation|machine-models| |
Best first search is different from BFS and DFS by that that it uses problem specific information to chose which node of the search tree to expand next. Best first search is informed search and DFS and BFS are uninformed searches.
In order to use infored search algorithm you need to represent the knowledge of the pr... |
I did not found a closed form, but according to this entry in the [Online Encyclopedia of Integer Sequences](http://oeis.org/A056971) the sequence starts with
1, 1, 1, 2, 3, 8, 20, 80, 210, 896, 3360, 19200, 79200, 506880, 2745600, 21964800, 108108000, 820019200, 5227622400, 48881664000, 319258368000, ...
You ca... |
How would I solve these problems involving time complexity:
1. Suppose we are comparing implementations of insertion sort and merge sort on the same machine. For inputs of size $n$, insertion sort runs in $8n^2$ steps, while merge sort runs in $64n \log_2 n$ steps. For which values of $n$ does insertion sort beat me... |
|time-complexity|algorithm-analysis| |
In the comparison-based model of computation, you may implement the priority queue using a Fibonacci heap instead of an ordinary heap. This will give you the following bounds: $O(1)$ amortized time for insert and $O(\log n)$ amortized time for deletion operations.
If you depart from the comparison-based model and ad... |
In the comparison-based model of computation, you may implement the priority queue using a Fibonacci heap instead of an ordinary heap. This will give you the following bounds: $O(1)$ amortized time for insert and $O(\log n) $ amortized time for deletion operations.
If you depart from the comparison-based model and ... |
In the comparison-based model of computation, you may implement the priority queue using a Fibonacci heap instead of an ordinary heap. This will give you the following bounds: $O(1)$ amortized time for insert and $O(\log n)$ amortized time for deletion operations.
If you depart from the comparison-based model and a... |
null |
null |
A [grammar][1] is *[ambiguous][2]* if at least one of the words in the
language it defines can be parsed in more than one way. A simple example of an ambiguous grammar
$$
E \rightarrow E+E \ |\ E*E \ |\ 0 \ |\ 1 \ |\ ...
$$
because the string 1+2*3 can be parsed as (1+2)*3 and 1+(2*3). For
context free gramma... |
Hardness of ambiguity/non-ambiguity for context-free grammars |
|computability|formal-grammars|context-free|undecidability|ambiguity| |
Ambiguous grammars can be enumerated, since each ambiguous grammar has a proof of ambiguity, namely a word with two different parses. |
Perhaps the problem is still NP-complete; this reduction should work: given a planar graph $G$ and two nodes $s$ and $t$ (start and end), expand it to a new graph $G'$ in this way: for every node $u$ of $G$ add two nodes $u_1,u_2$ and two edges: $(u,u_1),(u_1,u_2)$ (informally add a *tail* made with two new nodes).
... |
A [grammar][1] is *[ambiguous][2]* if at least one of the words in the
language it defines can be parsed in more than one way. A simple example of an ambiguous grammar
$$
E \rightarrow E+E \ |\ E*E \ |\ 0 \ |\ 1 \ |\ ...
$$
because the string 1+2*3 can be parsed as (1+2)*3 and 1+(2*3). For
context free gramma... |
If you are not concerned with efficiency this trivial and *time-wasting* approach can also work (*it only shows how it can be done without taking too much care of coordinate-mappings ... in other words the bad way to do it :-)*).
Use the single tape to store a *list* of quadruples $...\#x,y,z,v\#...$.
Each quadru... |
|graph-theory|data-structures|combinatorics|binary-trees| |
null |
null |
Yes, it can be done in _amortized_ O(1) time (enqueue, dequeue, minimum). Have a look at the code and explanation given [here](http://www.keithschwarz.com/interesting/code/?dir=min-queue). |
null |
1) Breadth first search is blind search(uninformed), it just keeps expanding all the leaves and checks if one of them is the goal.
2) Best first search is informed search,i.e, it has a some information(heuristics) about the goal.For example if the information is about the distance from the current to state to the go... |
1) Breadth first search is blind search(uninformed), it just keeps expanding all the leaves and checks if one of them is the goal.
2) Best first search is informed search,i.e, it has a some information(heuristics) about the goal.For example if the information is about the distance from the current to state to the go... |
A certain political party wants to encourage women to participate in their primary elections, so they decide, that the 4th position is reserved for a woman. That is, if there is no woman in the top 4 positions, then the woman with the largest number of votes will be promoted to the 4th position, and the candidates at p... |
I am studying [best first search][1] as it compares to BFS (breadth-first search) and DFS (depth-first search), but I don't know when BFS is better than best-first search. So, my question is
> When would best-first search be worse than breadth-first search?
This question is one of the back exercises in *Artifici... |
null |
Problems comparing the time complexity of different algorithms are usually concerned with asking which algorithm takes less time (that is, less steps). So when the problem asks which one is "beats" the other or is "faster" for a given size of input $n$, it is asking which would take less steps (and hence less time); i.... |
null |
1) Breadth first search is blind search(uninformed), it just keeps expanding all the leaves and checks if one of them is the goal.
2) Best first search is informed search,i.e, it has some information(heuristics) about the goal.For example if the information is about the distance from the current to state to the goal... |
null |
Yes, it can be done in _amortized_ O(1) time (enqueue, dequeue, minimum). Have a look at the code and explanation given [here](http://www.keithschwarz.com/interesting/code/?dir=min-queue).
**UPDATE (4th Nov '12)**: Here are the most relevant parts quoted from the above link (emphasis mine; and of course, all credits... |
I'm a little bit confused about the analysis of [binary search][1].
In almost every paper, the writer assumes that the array size n is always 2^k.
Well i truly understand that the time complexity becomes log(n) (worst case) under this assumption. But what if n != 2^k ?
For example if n==24, then we have
5 iterati... |
iterative binary search analysis |
|time-complexity| |
Yes, it can be done in _amortized_ O(1) time (enqueue, dequeue, minimum). Have a look at the code and explanation given [here](http://www.keithschwarz.com/interesting/code/?dir=min-queue).
Here are the most relevant parts quoted from the above link (emphasis mine; and of course, all credits for the solution go to th... |
|data-structures|priority-queues|lower-bounds| |
I'm a little bit confused about the analysis of [binary search][1].
In almost every paper, the writer assumes that the array size $n$ is always $2^k$.
Well I truly understand that the time complexity becomes $\log(n)$ (worst case) under this assumption. But what if $n \neq 2^k$?
For example if $n=24$, then we have... |
Iterative binary search analysis |
|algorithms|time-complexity|algorithm-analysis|runtime-analysis|search-algorithms| |
$n=2^k$ is a simplifying assumption that ensures binary search "goes through" properly. If the array has a length that is not a power of two, you have to break ties when choosing middle elements, "halves" are not equally large and not all decisions lead to the same number of steps.
The worst-case number of steps on ... |
I'm a little bit confused about the analysis of [binary search][1].
In almost every paper, the writer assumes that the array size $n$ is always $2^k$.
Well I truly understand that the time complexity becomes $\log(n)$ (worst case) under this assumption. But what if $n \neq 2^k$?
For example if $n=24$, then we have... |
So here is a rather simple approach to solve this problem. You know that there are $O(n^2)$ different distances that matter. You can characterize the solution of your problem by the smallest and the largest distance ($d_\min$,$d_\max$) between your matched points. This gives you a set of $O(n^4)$ *candidates*.
So s... |
I am trying to understand summation for amortization analysis of a hashtable from a mit lecture video.
http://videolectures.net/mit6046jf05_leiserson_lec13/
At time 16:09. Although you guys don't have to go and look at the video, but I feel that the summation he does is wrong so I will attach the screenshot of... |
Summation of j=0 to ceiling(Lg(n-1)) 2^j is it equivalent to O(n) ? |
|hash-tables| |
null |
If you have a series of numbers that are consecutive power of 2s, like $1+2+4+8+16+\cdots+2^k$ you get as sum $2^{k+1}-1$. You can either see this by looking at the formula for the [geometric series](http://en.wikipedia.org/wiki/Geometric_progression#Geometric_series) or you can prove this by induction.
Then the sta... |
I am trying to understand summation for amortization analysis of a hash-table from a MIT [lecture video](http://videolectures.net/mit6046jf05_leiserson_lec13/).
At time 16:09. Although you guys don't have to go and look at the video, but I feel that the summation he does is wrong so I will attach the screenshot of t... |
Summation of j=0 to ceiling(Lg(n-1)) 2^j is in O(n)? |
|mathematical-analysis|hash-tables| |
Assuming your edges have unit capacity, but non-unit costs, you can reduce this to a maximum-weight bipartite matching, that is, the [assignment problem][1]. For this, just make a copy of each vertex. The assignment problem can be solved in $O(n^{1.5})$ time.
[1]: http://en.wikipedia.org/wiki/Assignment_problem |
I ran into the following problem:
Given a directed acyclic graph with real-valued edge weights, and two vertices s and t, compute the minimum s-t cut.
For general graphs this is NP-hard, since one can trivially reduce max-cut to it by simply reversing the edge weights (correct me if I'm wrong).
What is the sit... |
Minimum s-t cut in weighted directed acyclic graphs with possibly negative weights |
|algorithms|complexity-theory|graphs|weighted-graphs| |
[I was asking on academia.se][1], if anyone knows scientific search engines offering a [proximity operator][2] like Google Web Search does, while Google Scholar Search does not. That's sad, because this operator would be most useful for literature research offering you a nearly semantic/context-sensitive search and I'v... |
What limits the implementation of proximity operators for text indexing and searching? |
|search-algorithms| |
null |
For a list of integers, of size n, where n is exponential, will merge-sort(n), run in poly-time or psuedo poly-time? |
Exponential input and poly-time algorithm |
|algorithms|polynomial-time| |
I am trying to understand summation for amortization analysis of a hash-table from a [MIT lecture video](http://videolectures.net/mit6046jf05_leiserson_lec13/) (at time 16:09).
Although you guys don't have to go and look at the video, I feel that the summation he does is wrong so I will attach the screenshot of the... |
Why is $\sum_{j=0}^{\lceil\log (n-1)\rceil}2^j$ in $\Theta (n)$? |
null |
In the Dragon Book there are exercises for section 2.4:
Exercise 2.4.1: Construct recursive-descent parsers, starting with the following grammars:
c) $S \rightarrow 0S1\ |\ 01$
But for a constructing a feasible parser, it is required that for two productions $A \rightarrow \alpha\ |\ \beta$, their FIRST sets a... |
Recursive-Descent Predictive Parser for $S \rightarrow 0S1\ |\ 01$ |
|context-free|compilers|parsers| |
null |
I am having difficulty with one of the exercises in the *Dragon Book*:
> **Exercise 2.4.1(c):** Construct recursive-descent parsers, starting with
> the following grammars:
>
> $$S \rightarrow 0S1\ |\ 01$$
Yet, for constructing a feasible parser, it is required that for two productions $A \rightarrow \alpha\ ... |
null |
We know error correcting codes are parameterized as (n,k,d) codes. I wanted to know the values of these parameters for some commonly used error correcting codes in computer memories or in DRAMs, etc.
I just wanted to see some values for these parameters, used in real life applications.
Thanks,
Sorry if my questi... |
Commonly used Error Correcting Codes |
|computer-architecture|error-correcting-codes| |
I'm sure this greatly varies according to the application and the specific code in use.
For CDs encoding, a (28,24)-Reed Solomon code is used.
For DVDs, it is a (208,194)-Reed Solomon code.
[Symbols are over $GF(2^8)$, that is, 8 bits per symbol. The notation is $(n,k)$-ReedSolomon, which is MDS has $d=n-k+1$... |
I'm sure this greatly varies according to the application and the specific code in use.
Though not for DRAMs, maybe this will give you some insights:
>For CDs encoding, a (28,24)-Reed Solomon code is used.
>For DVDs, it is a (208,194)-Reed Solomon code.
Symbols are over $GF(2^8)$, that is, 8 bits per symbol... |
You need to modify the grammar. In general this is not necessarily possible (not every CFG is an LL(k) grammar - the class suitable for recursive descent predictive parsing). In this case we can modify the grammar to:
$$1. \; S\rightarrow 0SA$$
$$2. \; S \rightarrow \varepsilon\;\;\;\;\;$$
$$3. \;A \rightarrow 1\... |
Specifically for Memories, try google **ECC memories**. It seems that the main trend is to correct a single bitflip per memory address. For that purpose a distanse of $d=3$ is enough and a Hamming code can be used.
* [Here](https://encrypted.google.com/url?sa=t&rct=j&q=parameters%20of%20ecc%20memories&source=web&cd... |
null |
I'm sure this greatly varies according to the application and the specific code in use.
Though not for DRAMs, maybe this will give you some insights:
>For CDs encoding, a (28,24)-Reed Solomon code is used.
>For DVDs, it is a (208,194)-Reed Solomon code.
Symbols are over $GF(2^8)$, that is, 8 bits per symbol... |
You need to modify the grammar. In general this is not necessarily possible (not every CFG is an LL(k) grammar - the class suitable for recursive descent predictive parsing). In this case we can modify the grammar to:
$$1. \; S\rightarrow 0SA$$
$$2. \; S \rightarrow \varepsilon\;\;\;\;\;$$
$$3. \;A \rightarrow 1\... |
>So I've been scratching my head over this problem for a couple of days now. Given some language A and B that is regular, show that the language L which consists of all strings in A whose length is equal to some string in B is a regular language.
>In equation form:
> > >L = {x ∈ A | ∃y ∈ B s.t. |x| = |y| }
>M... |
Proving the language which consists of all strings in some language is the same length as some string in another language is regular |
|regular-languages|proof-techniques| |
So I've been scratching my head over this problem for a couple of days now. Given some language $A$ and $B$ that is regular, show that the language $L$ which consists of all strings in $A$ whose length is equal to some string in $B$ is a regular language.
In equation form:
$$L = \{x \in A \mid \exists y \in B \t... |
**Hints:** Let's assume you know all the different lengths of words in $B$, $len(B) = \{ \ell_1, \ell_2, \ell_3, ... \}$. For the time being, let's assume it is finite.
Can you use this knowledge to construct a DFA for $A$?
<sup>(hint: intersection, or "cross-product" construction)</sup>
Does the alphabet of ... |
|regular-languages|finite-automata|proof-techniques| |
|algorithms|terminology|time-complexity|polynomial-time| |
Remember (or come up with) the proof for
$\qquad \displaystyle L_1, L_2 \in \mathsf{REG} \implies L_1 \cap L_2 \in \mathsf{REG}$.
Do you see how to modify the proof for your setting?
>! Abstracting the equality of lengths thing, come up with a construction for an automaton for
>!
>! $\qquad \displaystyle... |
|formal-languages|regular-languages|finite-automata|proof-techniques|closure-properties| |
Why is $\sum_{j=0}^{\lfloor\log (n-1)\rfloor}2^j$ in $\Theta (n)$? |
null |
|search-algorithms|data-mining| |
null |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.