instruction stringlengths 0 29.8k ⌀ |
|---|
Question about Prims algorithm where weights are between 1 and some constant W |
|graphs| |
|computational-geometry| |
When you have a *really* large file and *many* elements in it, but the most common element is very common -- occurs $> 1/k$ fraction of the time -- you can find it in linear time with space $O(k)$ words ( the constant in the $O()$ notation is very small, basically 2 if you don't count the storage for auxiliary things l... |
Given a path down a *full* binary tree to a node (for example, a sequence of $1$s and $0$s, $0$ representing "go left" and $1$ representing "go right"), how would one find the position of the node in the preorder traversal. In other words the $i$th node in the preorder traversal will end up with at this node.
Obviou... |
Calculating traversal position of a node in a full binary tree, given its path |
|binary-trees|trees|graph-traversal| |
The references you are suggesting would make a "very" theoretical computer scientist. but I honestly dont find any benefit reading all these books if you are from a non-CS degree. This of course all depends on what you need.
I find some books such as Book 14, 15, 16, 17 are not intended to computer scientists. Boo... |
null |
Essentially the algorithm is:
1. Each time you go left, you add one.
2. Each time you go right, you add the size of the left sub-tree, *and* you add one.
The size of a full binary tree can be calculated as $2^{h+1}-1$. Thus, the height of the left sub-tree can be calculated by $2^{h_{\text {subtree}}+1}-1=2^{h... |
Consider the argument made in [this question](http://cs.stackexchange.com/questions/6562/generalizing-the-comparison-sorting-lower-bound-proof) based on the comparison sorting lower-bounds proof, which runs as follows.
First, the comparison sorting lower-bounds proof was recited:
1. For $n$ distinct numbers, the... |
Proofs based on narrowing down sets of possibilities |
|proof-techniques|lower-bounds| |
Essentially the algorithm is:
1. Each time you go left, you add one.
2. Each time you go right, you add the size of the left sub-tree, *and* you add one.
The size of a full binary tree can be calculated as $2^{h+1}-1$. Thus, the height of the left sub-tree can be calculated by $2^{h_{\text {subtree}}+1}-1=2^{h... |
null |
The answer is easier as you think. As you remarked you should check if you take always CCW or CW turns. But of course, this might result in a curve that is self-intersecting. But you can detect this easily, just sum up then angles of the "turns". Since your curve is closed this angle sum is a multiple of $2\pi$. If it ... |
Does the DFS algorithm differentiate between an ancestor and a parent while computing back edges? |
Usual definitions of *back edge* and *tree edge* is that they return to a node previously visited or that they go straight to a new node, respectively. Formally speaking, these definitions result from understanding graphs as spanning trees, so that my definitions are rather informal but I hope they suffice and are unde... |
The answer is easier than you think. As you remarked you should check if you take always CCW or CW turns. But of course, this might result in a curve that is self-intersecting. But you can detect this easily, just sum up then angles of the "turns". Since your curve is closed this angle sum is a multiple of $2\pi$. If i... |
The more general argument is an example of an _adversary argument_. A nice example is a lower bound for the number of comparisons needed to find the minimum and the maximum _at the same time_. Said number is $\lceil 1.5 n \rceil - 2$. You can try to construct the algorithm and prove its optimality, or just have a look ... |
I ended up figuring it out, thanks all for the help |
Given languages $X,Y$, defines $X(X, Y)$ by
$\qquad X(L_1,L_2) = \{w \mid w \not\in L_1 \cup L_2 \}$ |
Using this grammar, over the alphabet $\Sigma=\{c b a\}$
$$
S \rightarrow a \\
S\rightarrow CD \\
BE\rightarrow Ea \\
E\rightarrow a \\
$$
Im trying to show that the working string $aaaBBAAA$ generates the word
|
How can you prove that a deterministic PDA is stronger than a FA?
Thanks |
Deterministic machines |
|automata| |
Im trying to figure out the best way to describe strings in a fa. What is the best way to start with writing the regular expression? |
null |
The algorithm you describe works on *directed graphs*. In such a graph, an edge $(u, v)$ does not imply an edge $(v, u)$. Your confusion arises because you are probably trying it for undirected graphs.
For undirected graphs, the algorithm has to be modified slightly. Again, the modification will depend on whether th... |
Your question is asking the old chestnut: "What happens when an irresistible force meets an immovable object?" The problem is in the question itself: the two entities as described cannot exist in the same logically consistent universe. Your optimal algorithm, an algorithm that always wins, cannot be played by both si... |
null |
Your question is akin to the old chestnut: "What happens when an irresistible force meets an immovable object?" The problem is in the question itself: the two entities as described cannot exist in the same logically consistent universe. Your optimal algorithm, an algorithm that always wins, cannot be played by both s... |
Using this grammar, over the alphabet $\Sigma=\{a\}$
$$
S \rightarrow a \\
S\rightarrow CD \\
C\rightarrow ACB \\
C\rightarrow AB \\
AB\rightarrow aBA \\
Aa\rightarrow aA \\
Ba\rightarrow aB \\
AD\rightarrow Da \\
BD\rightarrow Ea \\
BE\rightarrow Ea \\
E\rightarrow a \\
$$
Im trying to show that the work... |
null |
Below is the general code for DFS with logic for marking back edges and tree edges. My doubt is that back edges from a vertex go back and point to an ancestor and those which point to the parent are not back edges (lets assume undirected graph). In an undirected graph we have an edge back and forth between 2 vertices $... |
null |
will add another answer that emphasizes the massive state space, not really conceptualized in the question or pointed out in other answers. must disagree with your premise:
>Let's say that we have the computing power to develop an algorithm that predicts all possible movements of the opponent in a chess game.
see... |
will add another answer that emphasizes the massive state space, not really conceptualized in the question or pointed out in other answers. must disagree with your premise:
>Let's say that we have the computing power to develop an algorithm that predicts all possible movements of the opponent in a chess game.
see... |
will add another answer that emphasizes the massive state space, not really conceptualized in the question or pointed out in other answers. must disagree with your premise:
>Let's say that we have the computing power to develop an algorithm that predicts all possible movements of the opponent in a chess game.
see... |
will add another answer that emphasizes the massive state space, not really conceptualized in the question or pointed out in other answers. must disagree with your premise:
>Let's say that we have the computing power to develop an algorithm that predicts all possible movements of the opponent in a chess game.
see... |
null |
other answers are good, just throwing another one out there for further consideration/insight with a CS flavor/twist. one can construct an [FSM](http://en.wikipedia.org/wiki/Finite-state_machine), a finite state machine, that can compare two binary numbers of any length, starting pairwise from the most significant bits... |
other answers are good, just throwing another one out there for further consideration/insight with a CS flavor/twist. one can construct an [FSM](http://en.wikipedia.org/wiki/Finite-state_machine), a finite state machine, that can compare two binary numbers of any length, starting pairwise from the most significant bits... |
other answers are good, just throwing another one out there for further consideration/insight with a CS flavor/twist. one can construct an [FSM](http://en.wikipedia.org/wiki/Finite-state_machine), a finite state machine, that can compare two binary numbers of any length, starting pairwise from the most significant bits... |
other answers are good, just throwing another one out there for further consideration/insight with a CS flavor/twist. one can construct an [FSM](http://en.wikipedia.org/wiki/Finite-state_machine), a finite state machine, that can compare two binary numbers of any length, starting pairwise from the most significant bits... |
Given $n \in \mathbb{N}$ pairwise distinct numbers. I want to do as few comparisons per number as possible - and every number should experience roughly the same amount of comparisons as another number - and find the greatest $k \leq n$ numbers, e.g. $k = \frac{n}{10}$. In order to minimise the number of comparisons per... |
Finding the greatest $k$ numbers with a certainty of $p$ |
|algorithms| |
Consider a directed graph $G$ on which one can dynamically add edges and make some queries. Consider the following set of queries:
arrow(u, v)
equiv(u, v)
find(u)
the first one adds an arrow $u→v$ to the graph, the second one decides if $u↔^*v$, the last one finds a canonical representative of the e... |
Directed union-find |
|algorithms|graphs|search-algorithms| |
Use the [selection algorithm][1] to find the $k$th greatest element, and then run through your set of numbers to keep only the elements greater than this $k$th element.
The time complexity of this algorithm is $O(n)$. This means that there is a constant $c$ such that the number of comparisons and the number of comp... |
I propose the following algorithm. You take some random element $p$ of your input as pivot element for $k=n/10$. Next, you scan through all your data and split it into a list of elements $\le p$ and a list with elements $>p$.
*Case 1:* The list with the larger elements contains more then $k$ elements. Then take th... |
You are right that $G_{l'}$ is not necessarily a superset of $G_l$. However, you can still prove that the algorithm runs in strongly polynomial time. You have the following invariants:
* all edges in $M$ remain edges of $G_{l'}$
* we don't remove vertices from $S$ and $T$ until we increase the size of the matching ... |
The references you are suggesting would make a "very" theoretical computer scientist. but I honestly dont find any benefit reading all these books if you are from a non-CS degree. This of course all depends on what you need.
I find some books such as Book 14, 15, 16, 17 are not intended to computer scientists. Boo... |
How can you prove that multiple-cell-move instructions, for example (X, Y, 5R) and (X, Y, 17L), do not increase the power of a Turing Machine?
Thanks |
Prove multiple cell move instructions don't increase power of Turing Machines |
|turing-machines| |
Im trying to figure out how to describe fifty-six strings to test if a three state FA over the alphabet $\{a,b\}$ has a finite language.
The number fifty-six comes from a theorem that states if a machine has $N$ states and an alphabet has $m$ letters, then in total there are $m^N + m^{N + 1} + m^{N + 2} +\ldots+ m^{... |
Given languages $L_1,L_2$, defines $X(L_1,L_2)$ by
$\qquad X(L_1,L_2) = \{w \mid w \not\in L_1 \cup L_2 \}$
If $L_1$ and $L_2$ are regular, how can we show that $X(L_1,L2)$ is also regular? |
|algorithms|bipartite-matching| |
You could represent a road as a list of the two faces involved. Given a road and a hexagon, you can explicitly calculate the roads next in order clockwise or counterclockwise on the hexagon. That way you can find all the neighbours on both sides.
This suggestion is attributed to the hypermap community by [Gonthier e... |
Vertex cover has an easy $2$-approximation, so gap-VC-[$1/4,3/4$] is easy. The best unconditional hardness result is by Dinur and Safra, which gives $1.3606$ hardness. Since $(3/4)/(1/2) = 1.5 > 1.3606$, their method definitely doesn't imply gap-VC-[$1/2,3/4$]-hardness. Assuming the Unique Games Conjecture, the hardnes... |
Here's something more complicated, which performs $n + o(n)$ comparisons, and achieves an approximately correct list with high probability.
Suppose you want to partition a set $V$ of $n$ elements into a disjoint union $L \cup S$ of a set of larger elements and a set of smaller elements, where $\# L \approx \sigma n$... |
Here's something more complicated, which performs $n + o(n)$ comparisons, and achieves an approximately correct list with high probability.
Suppose you want to partition a set $V$ of $n$ elements into a disjoint union $L \cup S$ of a set of larger elements and a set of smaller elements, where every $s \in S$ is boun... |
null |
Here's something more complicated, which performs $n + o(n)$ comparisons, and achieves an approximately correct list with high probability.
Suppose you want to partition a set $V$ of $n$ elements into a disjoint union $L \cup S$ of a set of larger elements and a set of smaller elements, where every $s \in S$ is boun... |
null |
The number of `foo()` calls is the number of 1 bits in all numbers from 0 to $n$ (or all even numbers between $0$ and $2n$ - same thing). Asymptotically, it's $O(n \log n)$, because the number of 1 bits is around $\log_2(n)/2$.
I don't have an exact function. It won't be a smooth function - for example, $f(1023)-f(1... |
Look at the [Max Flow Min Cut](http://en.wikipedia.org/wiki/Max-flow_min-cut_theorem) algorithm. |
I'm designing an algorithm for a class that will determine if a directed graph is unique with respect to a vertex $v$ such that for any $u \ne v$ there is at most one path from $v$ to $u$. I've started by using BFS (breadth-first search) to find the shortest path from v to another vertex u, and then running BFS again t... |
Unique path in a directed graph |
How to define quantum Turing machines? |
Is there any "natural" language which is undecidable?
by "natural" I mean a language defined directly by properties of strings, and not via machines and their equivalent. In other words, if the language looks like
$$ L = \{ \langle M \rangle \mid \ldots \}$$
where $M$ is a TM, DFA (or regular-exp), PDA (or grammar... |
Is there a "natural" undecidable language? |
In the [Stable Matching Problem](http://en.wikipedia.org/wiki/Stable_marriage_problem), it is stated that there can exist cases where the $m$ list of men can be content with their decisions, yet the list of $f$ cannot when the algorithm is run with men's proposals.
From what I read, an unstable match occurs when $m$... |
This is a near trivial consequence of the definition of NP-completeness. If any language in NP is solvable in polynomial time (which is asserted by the premise), then they all are. Another way to look at this is to look at [Cook's theorem for NP-completeness](http://en.wikipedia.org/wiki/Cook%E2%80%93Levin_theorem) tha... |
For example, there is a neat classic reduction of factoring to SAT which is also a source of presumed "hard" SAT instances. Basically one uses EE ideas for binary multiplication encoded into the SAT circuit. Think of binary multiplication as an addition of a series of left shifted multiplicands, each "masked" (ANDed) b... |
From talking to the OP, algorithms that handle parallel matrix multiplication are apparently acceptable answers. Matrix multiplication and parallel algorithms for it are a highly studied problem in CS partly because of its widespread application e.g. in scientific computing. There are other ways to parallelize the prob... |
I'd really like your help with proving the following.
If $\mathrm{NTime}(n^{100}) \subseteq \mathrm{DTime}(n^{1000})$ then $\mathrm{P}=\mathrm{NP}$.
Here, $\mathrm{NTime}(n^{100})$ is the class of all languages which can be decided by nondeterministic Turing machine in polynomial time of $O(n^{100})$ and $\mathrm... |
Proving that if $\mathrm{NTime}(n^{100}) \subseteq \mathrm{DTime}(n^{1000})$ then $\mathrm{P}=\mathrm{NP}$ |
there is an at-times dizzying array of symbols used in math and CS papers. yet many assume basic familiarity that seems rarely taught in one place. am looking for a dictionary something like the following esp from a CS perspective.
* it would list all the basic mathematical symbols and give their meanings and examp... |
looking for dictionary of math/CS notation |
|terminology|reference-request|education| |
Let us first calculate the coordinates $C(m,n)$ of the center of hexagon $(m,n)$. We assume that the origin is at the center of hexagon $(0,0)$ and that the hexagon radius (distance from center to vertex) is $r$. A short calculation shows that hexagon $(1,0)$ has its center at $$C(1,0) = a = (\sqrt{3} r, 0)$$ and hexa... |
Let us first calculate the coordinates $C(m,n)$ of the center of hexagon $(m,n)$. We assume that the origin is at the center of hexagon $(0,0)$ and that the hexagon radius (distance from center to vertex) is $r$. A short calculation shows that hexagon $(1,0)$ has its center at $$C(1,0) = a = (\sqrt{3} r, 0)$$ and hexa... |
null |
null |
I'm trying to solve a graph problem ( it's not for homework, just to practise my skills ).
A dag $G(V,E)$ is given, where $V$ is the set of vertices and $E$ the edges. The graph is represented as an adjacency list, so $A_i$ is a set containing all the connections of $i$.
My task is to find which vertices are re... |
Finding reachable vertices |
|graphs| |
You can use [this sheet][1]. It has a lot of handy formulas and some definitions.
You can also use [Wikipedia's list of mathematical symbols][1] propsed by Kyle Jones in comments.
[1]: http://www.tug.org/texshowcase/cheat.pdf
[2]: http://en.wikipedia.org/wiki/List_of_mathematical_symbols |
You can use [this sheet][1]. It has a lot of handy formulas and some definitions.
You can also use [Wikipedia's list of mathematical symbols][1] propsed by Kyle Jones in comments.
There is also [Worfram MathWorld][3] which is a great resource, but you need to know what are you looking for.
When it comes to pri... |
when in a Parallel algorithm we say:
"This algorithm is done in O(1) time using O(nlogn) work, with n-exponential probability, or alternatively, in O(logn) time using O(n) work, with n-exponential probability."
Then Can we Implement this algorithm for a Quad-Core Computer (and just 4 threads) with n=100,000?
T... |
a question about parallel algorithm complexity |
|complexity-theory| |
Show that for $l(n) = log log n$, it holds that $DSPACE(o(l)) = DSPACE(O(1))$.
It's well known fact in Space Complexity, but how to show it explicitly? |
space complexity lower bound |
|complexity-theory|space-complexity| |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.