instruction stringlengths 0 29.8k ⌀ |
|---|
|algorithms|graphs|terminology| |
Think about what a "good" cluster is. It is a set of nodes which
* are strongly interconnected (strong cohesion) and
* weakly connected with nodes outside of the cluster (weak coupling).
In particular, the connection among the nodes should be *stronger* than the connection with the outside. And this is what th... |
If a graph $G$ is connected and has no path with a length greater than $k$, prove that every two paths in $G$ of length $k$ have at least one vertex in common.
I think that that common vertex should be in the middle of both the paths. Because if this is not the case then we can have a path of length $>k$. Am I rig... |
Prove that every two longest paths have at least one vertex in common |
Assume for contradiction that $P_{1} = \langle v_{0},\ldots,v_{k}\rangle$ and $P_{2} = \langle u_{0},\ldots,u_{k}\rangle$ are two paths in $G$ of length $k$ with no shared vertices.
As $G$ is connected, there is a path $P'$ connecting $v_{i}$ to $u_{j}$ for some $i,j \in [1,k]$ such that $P'$ shares no vertices with... |
Is the language
$$L = \{a,b\}^* \setminus \{(a^nb^n)^n\mid n \geq1 \}$$
context-free? I believe that the answer is that it is not a CFL, but I can't prove it by Ogden's lemma or Pumping lemma. |
|formal-languages|context-free|pumping-lemma| |
In *Algorithmic Randomness and Complexity* from Downey and Hirschfeldt, it is stated on page 129 that
$\qquad \displaystyle \sum_{K(\sigma)\downarrow} 2^{-K(\sigma)} \leq 1$,
where $K(\sigma)\downarrow$ means that $K$ halts on $\sigma$, $\sigma$ being a binary string. $K$ denotes the prefix-free Kolmogorov comp... |
Hint:
>! Yes
Solution:
>! $$(a^n b^n)^n = \{a^{n_1} b^{n_2} \dots a^{n_{2k-1}} b^{n_{2k}}\}: \forall i. n_i = n_{i+1} \wedge n_1 = k\}$$
>!
>! therefore the complement
>!
>! $$\{a,b\}^{\ast} - (a^n b^n)^n = \{a^{n_1} b^{n_2} \dots a^{n_{2k-1}} b^{n_{2k}}\}: \exists i. n_i \neq n_{i+1} \vee n_1 \neq k\}$$
... |
Hint:
>! Yes
Solution:
>! $$\{(a^n b^n)^n \mid n \geq 1 \} = \{a^{n_1} b^{n_2} \dots a^{n_{2k-1}} b^{n_{2k}}\}: k \geq 1 \land n_1 = k \land \forall i. n_i = n_{i+1} \}$$
>!
>! and therefore the complement is
>!
>! $$\{a,b\}^{\ast} \setminus \{(a^n b^n)^n \mid n \geq 1 \} = \{a^{n_1} b^{n_2} \dot... |
<b>EDIT</b> Updated slightly to make explicit that $P'$ may only be of length one.
Assume for contradiction that $P_{1} = \langle v_{0},\ldots,v_{k}\rangle$ and $P_{2} = \langle u_{0},\ldots,u_{k}\rangle$ are two paths in $G$ of length $k$ with no shared vertices.
As $G$ is connected, there is a path $P'$ connect... |
I have a high interest in priority-queues (E.g., see my answers on: http://cs.stackexchange.com/q/524), and was wondering if there is a priority-queue or similar data-structure where you can sort by multiple values?
For example, if I wanted to sort by `numval` and sort by `strval`, and be able to get the highest (Gö... |
Queue that can sort by multiple priorities? |
|data-structures|asymptotics|efficiency|priority-queues|memory-management| |
The problem is briefly stated below:<br>
Given an array A of _N_ integers, each element in the array can be increased by a fixed number _b_ with some probability <i>p</i>[<i>i</i>], 0 <= _i_ < _n_. I have to find the expected number of swaps that will take place to sort the array using [bubble sort][1].
I've tried ... |
Expected number of swpas in bubble sort |
|algorithms| |
Let $X$ be the number of swaps in bubble sort defined by $X = \sum_{i<j} I_{ij}$ where $I_{ij}$ is the indicator variable that $x_j < x_i$. The expectation is defined as $E[X] = E[\sum_{i<j} I_{ij}] = \sum_{i<j} E[I_{ij}]$. We now need to determine $P\{I_{ij}\}$.
When assuming any possible permutation as input, each... |
{"Voters":[{"Id":19,"DisplayName":"Nicholas Mancuso"}]} |
{"Voters":[{"Id":19,"DisplayName":"Nicholas Mancuso"}]} |
Given an array $A$ of $N$ integers, each element in the array can be increased by a fixed number $b$ with some probability $p[i]$, $0 \leq i < n$. I have to find the expected number of swaps that will take place to sort the array using [bubble sort][1].
I've tried the following:
1) The probability for an element ... |
Expected number of swaps in bubble sort |
Expected number of swpas in bubble sort |
Think about what a "good" cluster is. It is a set of nodes which
* are strongly interconnected (strong cohesion) and
* weakly connected with nodes outside of the cluster (weak coupling).
In particular, the connection among the nodes should be *stronger* than the connection with the outside. And this is what th... |
Expected number of swaps in bubble sort |
So basically, you want to know if there is any sorting algorithm which wouldn't degrade from its average case if given a compare function similar to:
int Compare(object a, object b) { return Random.Next(-1,1); }
... where Random.Next() is some method that will produce a randomly-generated integer between a sp... |
null |
null |
In "Computers and Intractability A Guide to the Theory of NP-Completeness" textbook pp 236, "Sequencing to minimize tardy tasks" is NP-complete.
To be specific the problem is as follows: For each task t in T, partial order < on T, a length l(t), and a deadline d(t) and a positive integer K <= |T|. Is there a one-pro... |
NP-Completeness |
|complexity-theory| |
Given Graphs $G=(V_1,E_1)$ and $H=(V_2,E_2)$. Can a graph isomorphic to $H$ be obtained from $G$ by a sequence of edge contractions ? We know this problem is NP-complete. What about if only a subset of edges are valid for contraction at each step of the sequence. Does this problem stay NP-complete ? |
NP-completeness or not |
|complexity-theory|computability|np-complete|np-hard| |
Given Graphs $G=(V_1,E_1)$ and $H=(V_2,E_2)$. Can a graph isomorphic to $H$ be obtained from $G$ by a sequence of edge contractions ? We know this problem is NP-complete. What about if only a subset of edges are valid for contraction at each step of the sequence. For example when deciding the first edge for contraction... |
Given Graphs $G=(V_1,E_1)$ and $H=(V_2,E_2)$. Can a graph isomorphic to $H$ be obtained from $G$ by a sequence of edge contractions ? We know this problem is NP-complete. What about if only a subset of edges are valid for contraction at each step of the sequence. For example when deciding the first edge for contraction... |
I haven't done the analysis to confirm how uniform (or not) this would be, and it could be adjusted to be a true shuffle, but could you just choose, from a starting array of the `i`th index = `i + 1`, the `(k + RandNum50() + RandNum50() - 1) mod (100 - k)` index, with removal, for `k` = 0..99?
This "pushes" the peak... |
The answer is yes. Suppose that you had a polynomial-time algorithm to solve your revised problem. Apply that algorithm to the special case where the subset of edges available at each step is the whole set. We'd then have a polynomial time algorithm for the original, known NP-complete, problem.
To have any hope o... |
Given an array $A$ of $N$ integers, each element in the array can be increased by a fixed number $b$ with some probability $p[i]$, $0 \leq i < n$. I have to find the expected number of swaps that will take place to sort the array using [bubble sort][1].
I've tried the following:
1. The probability for an element ... |
null |
null |
I thought (so it can be wrong :-) of this $O(N^2)$ solution that uses the [Fisher-Yates shuffle][1]. In order to keep uniform distribution with *good approximation* (see EDIT section below) at every iteration you can use this trick to produce a value <code>krand</code> between $0$ and $k-1$:
// return a random... |
I have asked this question at [math.stackexchange](http://math.stackexchange.com/questions/167462/historical-relation-between-computer-science-and-the-theory-of-dynamical-systems), but I have been redirected here.
My question is, if there is any historical relation between the fields of Dynamical systems (and relate... |
Historical relation between computer science and the theory of dynamical systems |
|history| |
null |
null |
Do there exist any Turing complete typed lambda calculi? If so, what are a few examples? |
Does there exist a Turing complete typed lambda calculus? |
|lambda-calculus|type-theory| |
Yes, sure. Many typed lambda calculi accept only [strongly normalizing](http://en.wikipedia.org/wiki/Normalization_property_%28lambda-calculus%29) terms, by design, so they cannot express arbitrary computations. But a type system can be anything you like; make it broad enough, and you can express all deterministic comp... |
$n^2$ processors can compare all ${n \choose 2}$ possibilities in constant depth, so yes it's in NC. |
{"Voters":[{"Id":1590,"DisplayName":"Xodarap"}]} |
null |
null |
I wanted ask If you know an algorithm to find the witness for $EU(\phi_1,\phi_2)$ using BDD.
In pratic should use the fixed point for calculate $EU(\phi_1,\phi_2)$ that is:
$EU(\phi_1,\phi_2)=\mu.Q (\phi_2 \vee (\phi_1 \wedge EX Q) $
Unwinding the recursion, we get :
$Q_0=false$
$Q_1=\phi_2$
$Q_2=\phi_2... |
Witness for the $EU(\phi_1,\phi_2)$ using BDDs |
|formal-methods|model-checking| |
I want to specify, what it means to give an algebra as input to an algorithm and didn't find very much literature about it. So first I want to ask if you can recommend a book or paper that deals with the topic of complexity analysis of algebras over fields *and clearly define the decision problem*.
After some diggin... |
An $\mathbb F$-algebra as input to an algorithm |
|complexity-theory|decision-problem| |
null |
I want to specify, what it means to give an algebra as input to an algorithm and didn't find very much literature about it. So first I want to ask if you can recommend a book or paper that deals with the topic of complexity analysis of algebras over fields *and clearly define the decision problem*.
After some diggin... |
null |
To use the bottom up method you need to be able to efficiently determine what the "bottom" is, which usually menas you need a heavily constrained problem space. If you know what lowest calculations are going to be and the dependency order going upward, it makes sense to iteratively do them in the proper order and stor... |
Is there a fundamental difference between Top down and Bottom up Dynamic programing?
Meaning, is there a problem which can be solved bottom up but not top down?
Or is the bottom up approach just an unwinding of the recurrence in the top down approach? |
Top down, Bottom up Dynamic programing |
|algorithms| |
|dynamic-programming| |
null |
To use the bottom up method you need to be able to efficiently determine what the "bottom" is, which usually means you need a heavily constrained problem space. If you know what the lowest level calculations are going to be and the dependency order going upward, it makes sense to iteratively do them in the proper orde... |
Do all sorting algorithms work with orders that are [total](http://en.wikipedia.org/wiki/Total_order) but not [well](http://en.wikipedia.org/wiki/Well_order)?
For context, this question came up from the following problem:
Find a hamiltonian path in a tournament graph.
I and a colleague noticed that a tournamen... |
Do/which sorting algorithms work with orders that are total but not well? |
|algorithms|sorting| |
Do all sorting algorithms work with orders that are [total](http://en.wikipedia.org/wiki/Total_order) but not [well](http://en.wikipedia.org/wiki/Well_order)?
For context, this question came up from the following problem:
Find a hamiltonian path in a tournament graph.
I and a colleague noticed that a tournamen... |
Do all (or if not, which) sorting algorithms work with orders that are [total](http://en.wikipedia.org/wiki/Total_order) but not [strict](http://en.wikipedia.org/wiki/Total_order#Strict_total_order)?
For context, this question came up from the following problem:
Find a hamiltonian path in a tournament graph.
I... |
Do/which sorting algorithms work with orders that are total but not strict? |
Is it possible to always construct a hamiltonian path on a [tournament graph](http://en.wikipedia.org/wiki/Tournament_(graph_theory)#Paths_and_cycles) by sorting (using any sorting algorithm) with the following total order:
* `a` <= `b` iff there is an edge from `a` to `b` or if there exists a node `c` `a` <= `c` an... |
Is it possible to always construct a hamiltonian path on a tournament graph by sorting? |
|algorithms|graphs|sorting| |
null |
I think you are right; $K$ is a specific function which can not be computed. The author likely means to use *some* (arbitrary) approximative implementation; so no, this does not seem to be well-defined, if you are pedantic. You can also call it abuse of notation.
Consider this instead:
$\qquad \displaystyle \fora... |
This seems to be consistent with the presentation in [*Equivalence of $\mathbb{F}$-algebras and cubic forms*, Agrawal & Saxena (2006)][1].
[1]: http://www.math.uni-bonn.de/~saxena/papers/stacs06.pdf |
null |
null |
null |
There are $n$ people. The $i$th person have to pay $p_i$ dollars.
Some people don't have the set of bills to pay exactly $p_i$. They come up with the following algorithm.
Everyone put all their money on the table, then each individual take away the money he overpaid.
An example:
2 people, first person have t... |
Collectively pay the bill problem |
|algorithms| |
There are $n$ people at a table. The $i$th person has to pay $p_i$ dollars.
Some people don't have the right bills to pay exactly $p_i$, so they come up with the following algorithm.
> First, everyone puts all their money on the table. Then each individual takes back the money they overpaid.
An example:
Sup... |
null |
There are $n$ people at a table. The $i$th person has to pay $p_i$ dollars.
Some people don't have the right bills to pay exactly $p_i$, so they come up with the following algorithm.
> First, everyone puts all their money on the table. Then each individual takes back the money they overpaid.
An example:
Su... |
null |
null |
i wanted to ask u if someone can help me to construct a Regular Expression over the alphabet (a,b,x), constituted by all strings containing an odd number of a's, and in which between each pair of consecutive a's there is an even number of b's (and an arbirtary number of x's).
E.g., babbxbbxabbxaabxxbax E L(A), bab E L... |
Regular expressions - Formal Languages |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.