instruction stringlengths 0 29.8k ⌀ |
|---|
Consider the following flow graph and associated residual graph:
[![G1][1]][1]
In this graph, $d(3) = 3$.
If you saturate the augmenting path $(s, 1, 2, 3, 4, t)$, then the graph and residual graph become:
[![G2][2]][2]
In this graph, $d(3) = 2$, so it decreased.
[1]: https://i.stack.imgur.com/yaIe4.png... |
null |
> In two unsorted arrays (say $A$ and $B$) such that all items of $A$ belong to $B$ ($A \subset B$), find the smallest item in $B$ that doesn't occur in $A$ in linear time.
No hashing or linear time sorting is allowed.
I can solve this question when $A$ and $B$ are sorted.
However, the question states $A$ an... |
In two unsorted arrays A and B such that all items of A belong to B (A ⊂ B), find the smallest item in B that doesn't occur in A in linear time? |
null |
There is a [classic linear algorithm](https://en.wikipedia.org/wiki/Biconnected_component#Pseudocode) to find every cut vertex (AKA articulation point) in a graph.
I have a usecase that does this computation after every time a non-articulation-point is inserted or deleted. An articulation point is never deleted (but... |
Algorithm for an incremental update to cut vertex set |
|algorithms|graphs|amortized-analysis| |
I'm going to assume that all elements in $A$ (resp. $B$) are distinct, that elements possess a linear order, and that they can be compared in constant time.
Consider the following recursive algorithm:
if $|A|=0$, return the minimum in $B$ (in time $O(|B|)$).
Otherwise, find the median $x$ of the multiset obtained ... |
I'm going to assume that all elements in $A$ and $B$ are distinct (this assumption can be removed with some care), that elements possess a linear order, and that they can be compared in constant time.
Consider the following recursive algorithm:
if $|A|=0$, return the minimum in $B$ (in time $O(|B|)$).
Otherwise, f... |
null |
Some sources state that an algorithm that solves the SAT problem does not only need to answer the question whether the given formula is satisfiable or not, but additionally in the case where the formula is satisfiable, it needs to provide a satisfying assignment.
Is this true or not? I am bit confused, since I thoug... |
Is SAT an existential question? |
|satisfiability|decision-problem| |
null |
I'm going to assume that all elements in $A$ and $B$ are distinct (this assumption can be removed with some care), that elements possess a linear order, and that they can be compared in constant time.
Consider the following recursive algorithm:
if $|A|=0$, return the minimum in $B$ (in time $O(|B|)$).
Otherwise, f... |
null |
If your codes have structure, such as a format $abbbccd$ where different letters correspond to different levels in a hierarchy (state/province/county/city/post office or whatnot) you can assign weights to the differences of the respective levels. Then inside a level, the difference could be binary (same or different), ... |
null |
Find the intersection point between the parallel to the line at distance R and the trajectory of the center of the ball.
Now notice that the sum of the incoming and outgoing direction vectors (let I and O) is parallel to the line, corresponding to a vector α.D of unknown length.
I + O = α.D
The by express... |
Suppose I have a CNF formula with clauses of size 2 and 3. It has a unique satisfying assignment.
*It was made from a binary multiplication circuit where I multiplied two primes numbers A and B such that A\*B=S where S is a semiprime number. I added the conditions that A != 1, B != 1 and A <= B, then added the value... |
the number of pairs for each number of duplicates is
|number of numbers|number of pairs|
|-|-|
|1|0|
|2|1|
|3|3|
|4|6|
|5|10|
If we have N identical numbers then the first can pair with the other N-1 values, the second with N-2 because we've counted it's pairing with the first value already and so on. So i... |
Suppose that $X\in\mathcal{X}$ is features in abstract feature space.
In GAN framework, we aim to model $P_G(X) \approx P_{real}(X)$ through implicit learning.
Now, if I want to claim that "From the adversarial learning, as $P_G(X) \approx P_{real}(X)$ is achieved, there should exist at least one sample that is ide... |
How do you prove a presence of GAN generated samples being exactly (or almost exactly) identical to real observations? |
|machine-learning|proof-assistants| |
Can I define a complexity class $\mathsf{C}$ by giving a language $L^\prime$ and stating that $L^\prime$ is $\mathsf C$-complete? Specifically, a language $L$ is in $\mathsf C$ if there is a reduction from $L$ to $L^\prime$.
If so, are there any common (i.e., well-studied) complexity classes that are usually define... |
Can you define a complexity class by giving a language and declaring that the language is complete for the class? |
|complexity-classes| |
{"Voters":[{"Id":755,"DisplayName":"D.W."}]} |
null |
Let $X=x_1,x_2,x_3,\dots,x_n$ be set of $n$ distinct keys. I read this posts about Randomly build binary search trees [like this][1] and now I encounter the following question in my mind, suppose we generate a random permutation $X'$ from $X$ and we insert first half of $X'$ in empty binary search tree $T$. Also we s... |
Randomly build a binary search trees with simple modification |
|algorithms|data-structures| |
null |
Suppose for simplicity that $n$ is even and let $S$ be the sorted list of elements. Let the elements that end up in the first half of your permutation be "red", while the others are "blue".
Consider a leaf $v$ of the tree $T$ built on the first half of the elements in the permutation, and notice that $v$ stores some... |
Suppose for simplicity that $n$ is even and let $S$ be the sorted list of elements. Let the elements that end up in the first half of your permutation be "red", while the others are "blue".
Consider a leaf $v$ of the tree $T$ built on the first half of the elements in the permutation, and notice that $v$ stores some... |
Suppose for simplicity that $n$ is even and let $S$ be the sorted list of elements. Let the elements that end up in the first half of your permutation be "red", while the others are "blue".
Consider a leaf $v$ of the tree $T$ built on the first half of the elements in the permutation, and notice that $v$ stores some... |
Suppose that $X\in\mathcal{X}$ is data in abstract space and $Z\in\mathcal{Z}$ is random noise vectors in latent space over a defined prior (e.g., Gaussian).
Then, let $G$ and $D$ denote generator and discriminator. In a generative adversarial network (GAN), we train $G$ to generate samples $G(Z)$ through adversari... |
Suppose for simplicity that $n$ is even and let $S$ be the sorted list of elements. Let the elements that end up in the first half of your permutation be "red", while the others are "blue".
Consider a leaf $v$ of the tree $T$ built on the first half of the elements in the permutation, and notice that $v$ stores some... |
Suppose for simplicity that $n$ is even and let $S$ be the sorted list of elements. Let the elements that end up in the first half of your permutation be "red", while the others are "blue".
Consider a leaf $v$ of the tree $T$ built on the first half of the elements in the permutation, and notice that $v$ stores some... |
null |
Since strings are finite by definition, then it follows that languages are enumerable because they are finite string sets and we know that finite string sets are enumerable. Turing Machines are enumerable, because each Turing Machine has a finite string description. Therefore:
1. If all languages are enumerable, ... |
Languages and Turing Machine |
|turing-machines|turing-recognizable| |
Suppose for simplicity that $n$ is even and let $S$ be the sorted list of elements. Let the elements that end up in the first half of your permutation be "red", while the others are "blue".
Consider a leaf $v$ of the tree $T$ built on the first half of the elements in the permutation, and notice that $v$ stores some... |
Your sentence "languages are enumerable" could be ambigous.
A given language is enumerable, because it is a set of finite strings, but the set of languages is not enumerable, because it is the powerset of an infinite set ($\Sigma^*$).
That means that all your 3 items are false. |
null |
I'm trying to randomly distribute N items over B indistinguishable bins. There are no constraints as to the capacities of the individual bins, and the items themselves are also all indistinguishable. I want my algorithm to generate distributions in a uniform manner, that is each distinct distribution has equal probabil... |
Is it possible to randomly distribute items over bins such that each distinct distribution has equal probability? |
|algorithms|combinatorics|probability-theory|randomized-algorithms|partitions| |
I'm trying to randomly distribute N items over B indistinguishable bins. There are no constraints as to the capacities of the individual bins, and the items themselves are also all indistinguishable. I want my algorithm to generate distributions in a uniform manner, that is each distinct distribution has equal probabil... |
|pruning| |
I'm trying to randomly allocate N items over B indistinguishable bins. There are no constraints as to the capacities of the individual bins, and the items themselves are also all indistinguishable. I want my algorithm to generate allocations in a uniform manner, that is each distinct allocation has equal probability of... |
Is it possible to randomly allocate items to bins such that each distinct allocation has equal probability? |
I am working on a project for the prediction of preeclampsia, and one of the algorithms to be used is the convolutional neural network. I am a beginner in machine learning, and I am struggling to find out "**whether is it applicable to use the convolutional neural network for numerical data. without the need to conver... |
Convolutional neural network for non-image data |
|algorithms|machine-learning|artificial-intelligence|neural-networks| |
Yes, the input to a neural network is just a bunch of numbers. An image is treated as a bunch of numbers, one number for each pixel.
That said, a convolutional neural network might or might not be the right tool, depending on the nature of your data. CNNs are good for working with 1D sequences of numbers or 2D arr... |
Yes, complexity classes can be defined this way. $GI$ is a well-studied example. From [Wikipedia][1]:
> Since the graph isomorphism problem is neither known to be $NP$-complete nor known to be tractable, researchers have sought to gain insight into the problem by defining a new class $GI$, the set of problems with a... |
Hello Folks,
I am facing hard time in understanding this, basic question which says, how many possible finite automata ( DFA ) are there with two states X and Y, where X is always initial state with alphabet a and b, that accepts everything?
What i understand is:
Number of possible inputs possible: ... |
Finite Automata Mixture Combinatorics |
|finite-automata|combinatorics| |
It appears your question is equivalent to sampling uniform at random from the integer partitions of $N$, but constrained so that your partition has $\le B$ parts.
If that is correct, there are standard methods to sample uniformly at random from the integer partitions of $N$. See, e.g., https://stackoverflow.com/q/2... |
I'm trying to randomly allocate N indistinguishable items over B indistinguishable bins. There are no constraints as to the capacities of the individual bins, and the items themselves are also all indistinguishable. I want my algorithm to generate allocations in a uniform manner, that is each distinct allocation has eq... |
It appears your question is equivalent to sampling uniform at random from the integer partitions of $N$, but constrained so that your partition has $\le B$ parts.
If that is correct, there are standard methods to sample uniformly at random from the integer partitions of $N$. See, e.g., https://stackoverflow.com/q/2... |
Notice that the question also requires the automaton to accept everything. This means that if e.g., $X$ is not accepting, then you need to discount it.
Your count of the number of transition functions is correct, $2^4$. However, it's not true that the total number is $2^4$ times the number of final states, but rathe... |
Just get a list of post codes and their locations - for example, the UK has a list of about 1,100,000 post codes and their location, basically down to street level. That way you can check if a post code is valid, and how far away it is from another post code, at least the direct distance (driving distance would be more... |
null |
I'm trying to solve this recurrence relation:
>$T(n) = T(\frac{n}{2}) + T(\frac{n}{5}) + T(\frac{n}{10}) + c_1n$ ; n > 1\
>$T(n) = c_2n$ ; n = 1
Here is my attempt at solving this through the Master Theorem:
>$T(n) = T(\frac{5n}{10}) + T(\frac{2n}{10}) + T(\frac{n}{10}) + c_1n$\
>$T(n) = T(\frac{8n}{10}) + c_1n$... |
Solving a recurrence relation using the Master Theorem |
|asymptotics|recurrence-relation|master-theorem| |
null |
My intuition is this is false, but I cant't think of an example to disprove this. |
Are all non-context-free language infinite? |
|regular-languages|regular-expressions|theory| |
|regular-languages|context-free|regular-expressions| |
Any finite language is regular, so yes. |
I'm trying to solve this recurrence relation:
>$T(n) = T(\frac{n}{2}) + T(\frac{n}{5}) + T(\frac{n}{10}) + c_1n$ ; n > 1\
>$T(n) = c_2n$ ; n = 1
My first thought was to combine the fractions and solve through the Master Theorem. Would this approach be enough to calculate a tight bound, or are there any other appro... |
Are all non-context-free language infinite? |
null |
null |
null |
null |
Suppose that $X\in\mathcal{X}$ is data in abstract space and $Z\in\mathcal{Z}$ is random noise vectors in latent space over a defined prior $P(Z)$ (e.g., Gaussian).
Then, let $G$ and $D$ denote generator and discriminator. In a generative adversarial network (GAN), we train $G$ to generate samples $G(Z)$ through ad... |
The paper originally loacted here:http://www.cs.haifa.ac.il/~golumbic/courses/seminar-2010approx/takahashi80.PDF. But the url is too often down, after too many tries, I finally downloaded it. Now I upload it to my google drive:https://drive.google.com/file/d/1hK7YzECtThnbXcp7MviXM5U7QuaMOsdx/view?usp=sharing.
I thin... |
It appears your question is equivalent to sampling uniformly at random from the integer partitions of $N$, but constrained so that your partition has $\le B$ parts.
If that is correct, there are standard methods to sample uniformly at random from the integer partitions of $N$. See, e.g., https://stackoverflow.com/q... |
null |
null |
I am looking at a problem where I have an assembly of items, `V`, and my goal is to issue an `ID` to this assembly, such that:
1. this `ID` uniquely identifies `V`, aka a change in `V` results in a change in the `ID` of
`V` (much like a hash function),
2. given `V`, I can generate the `ID` and,
3. given th... |
Reversible hash function (?) |
|algorithms| |
I am looking at a problem where I have an assembly/collection of items, `V`, and my goal is to issue an `ID` to this collection, such that:
1. this `ID` uniquely identifies `V`, aka a change in `V` results in a change in the `ID` of
`V` (much like a hash function),
2. given `V`, I can generate the `ID` and,
... |
Our professor has solved an example for us. They taught us it's incorrect to use a quantifier (`exists` or `forall`) with a variable that's already bound on the left side of the pipe (`|`, meaning "such that"). They've done that in their example solution. Can quantifiers be used on variables bound on the left side of t... |
null |
We were presented in class with an algorithm for finding the maximum in an array in parallel in $O(1)$ time complexity with $n^2$ computers.
The algorithm was:
> Given an array A of length n:
>
> 1. Make a flag array B of length n and initialize it with zeroes with $n$ computers.
> 2. Compare every 2 elements... |
null |
With the purpose of proving my problem NP-hard, I'd like to reduce from a SAT variant (which of course should remain NP-hard) in which not two parameters are present (typically $n$ clauses and $m$ variables) but only one, so $n$ clauses and $f(n)$ variables, for some function $f$.
I've tried to look up 3-SAT (SAT w... |
NP-hard SAT variant with $n$ clauses and $f(n)$ variables |
|reductions|np-hard|3-sat| |
Our test log files are stored in .asc format. Each file contains around 5000 rows of these Logging Strings as shown in the image. I would like to reduce the size of these files.They are around 4-5 MBs each bringing the total folder size for one test run around 700-900 MBs. The files are output from the system in only .... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.