instruction
stringlengths
0
29.8k
⌀
If you have an alphabet A = {b,B) and you're asked to write down the **pattern** of the regular expression (I'll denote epsilon as 'e'): (e|bb|b)(B|bb)(b|e|b), what does the question actually want me to do? I'm not sure. I mean does it want me to give the possible patterns that can be formed with bB, but then surely th...
What is meant by "give pattern of a regular expression"
|finite-automata|compilers|regular-expressions|
Consider the [Chinese Postman Problem][1] on undirected graphs: Given an undirected graph $G$, find the shortest circuit of the graph that travels every edge atleast once. Now, if $G$ is Eulerian, then the Euler circuit is the shortest such circuit. If not, some edges will be traveled more than once. In other words, so...
I have an alphabet $A = \{b,B\}$ and I'm asked to write down the **pattern** of the regular expression $(\epsilon|bb|b)(B|bb)(b|\epsilon|b)$. What does the question actually want me to do? I'm not sure. Does it want me to give the possible patterns that can be formed with $b$ and $B$? But then surely the question would...
|formal-languages|regular-expressions|
null
|formal-languages|terminology|regular-languages|regular-expressions|
Is there an algorithm to solve following problem? Given two finite automata $A$ and $B$. Determine whether the language recognized by automaton $A$ is a subset of language recognized by automaton $B$ or otherwise.
Testing whether the language of one automaton is a subset of another
|finite-automata|regular-expressions|
Consider the [Chinese Postman Problem][1] on undirected graphs: Given an undirected graph $G$, find the shortest circuit of the graph that travels every edge atleast once. Now, if $G$ is Eulerian, then the Euler circuit is the shortest such circuit. If not, some edges will be traveled more than once. In other words, so...
null
An alternative way of expressing a lambda abstraction and reduction. (λmn.(λsz.ms(nsz)))(λsz.sz)(λsz.sz) [1 3 (2 3 4)][1 2][1 2] [[1 2] 2 (1 2 3)][1 2] [[1 2] 1 ([1 2] 1 2)] [1 ([1 2] 1 2)] [1 (1 2)] (λmn.m(mn))
The basic idea is to have one or more symbol that clearly indicate the end. For example: Non-ambiguous: > $ab^*c$ $(a|b)c$ > $ab^+c$ > $ab?c$ > $a(b|c)$ > $c(ab)^*ccc$ > $acc^*d$ > $abc|bcd$ Ambiguous: > $abc^*$ $abc^+$ $abc?$ $(abca)^∗bc$ $acc^*$ or $ac^*c$ An ...
|regular-languages|finite-automata|regular-expressions|ambiguity|
Is there any linear algorithm to find a root of a directed acyclic graph? Thank you very much!
Finding a root of a directed acyclic graph
|graphs|
My professor gave this assignment question, where he asks us to compare the expressive ease and the expressive range of Low Level and High Level theoretical programming languages. While in context, I could understand that "hook" seems to refer to the opposite of an abstraction, I don't understand precisely what it m...
Regarding programming languages, what is meant by "hook"?
|programming-languages|
I have a multilayer perceptron, it has an input layer, with two neurons, a hidden layer with an arbitrary number of neurons and an output layer with two neurons. Given that randomboolean and targetboolean are random boolean values, and the network operates as such: input(randomboolean); //Set the input neuron...
About the behaviour of multi-layer perceptrons
|neural-networks|
I have a multilayer perceptron, it has an input layer, with two neurons, a hidden layer with an arbitrary number of neurons and an output layer with two neurons. Given that randomboolean and targetboolean are random boolean values, and the network operates as such: input(randomboolean); //Set the input neuron...
Can someone tell me why almost in every book/website/paper authors use the following: foreach vertex v in Adjacent(u) relax(u,v) when relaxing the edges, instead of: foreach vertex v in Adjacent(u) if (v is in Q) relax(u,v) This is extremely confusing for someone when ...
Why not relax only edges in Q in Dijkstra's algorithm?
I have a multilayer perceptron, it has an input layer, with two neurons, a hidden layer with an arbitrary number of neurons and an output layer with two neurons. Given that randomboolean and targetboolean are random boolean values, and the network operates as such: input(randomboolean); //Set the input neuron...
Given a directed acyclic graph $D = (V,A)$, a vertex $v \in V$ is a _source_ if its _indegree_ is zero, meaning that it has only outgoing arcs. Does there exist a linear time algorithm to find a source in a given directed acyclic graph? Follow-up question: Can one in linear time find all sources?
Finding a source of a directed acyclic graph in linear time
null
This is a proposed solution for the case when b - a does not equal 2^k. It is supposed to work in fixed number of steps (no need to throw away candidates which are outside your expected range). However, I am not sure this correct. Please critique and help describe the exact non-uniformity in this random number gene...
This is a proposed solution for the case when b - a does not equal 2^k. It is supposed to work in fixed number of steps (no need to throw away candidates which are outside your expected range). However, I am not sure this correct. Please critique and help describe the exact non-uniformity in this random number gene...
Nobody mentioned this, so let me formally prove that if $D$ is a domain whose size is not a power of two, then finitely many fair coin tosses aren't enough to generate a uniformly random member of $D$. Suppose you use $k$ coins to generate a member of $D$. For each $d \in D$, the probability that your algorithm generat...
I am trying to learn some basic benchmarking. I have a loop in my Java program like, float a=6.5f; int b=3; for(long j=0; j<999999999; j++){ var = a*b+(a/b); }//end of for My processor takes around 0.431635 second to process this. How would I calculate proces...
Calculating Floating point Operations Per Second(FLOPS) and Integer Operations Per Second(IOPS)
|benchmarking|
I have a multilayer perceptron. It has an input layer with two neurons, a hidden layer with an arbitrary number of neurons, and an output layer with two neurons. Given that `randomboolean` and `targetboolean` are random boolean values, and the network operates as such: input(randomboolean); //Set the input ne...
null
It really depends on the optimizer. If you compile it with optimization, it might get rid of the loop, and then it will take rather less than 0.431635 seconds. Otherwise, it seems like you have four to five floating point instructions per iteration (including int to float conversion, once or twice, depending on the opt...
null
Let's consider the simpler question suppose that you know your Graph is "Tree". Then you can find the source node in linear time. Just select the random node if it is root then you find your answer if not it should be a child or parent then traverse back until you reach the root. this could be done in O(|V|-1).
In concrete mathematics, chapter 3 Integer functions.
Consider the [Chinese Postman Problem][1] on undirected graphs: Given an undirected graph $G$, find the shortest circuit of the graph that travels every edge atleast once. Now, if $G$ is Eulerian, then the Euler circuit is the shortest such circuit. If not, some edges will be traveled more than once. In other words, so...
Let's consider a simpler question. Suppose that you know your Graph is a Tree. Then you can find the source node in linear time. Just select a random node, if it is the root then you have your answer, if not it should be a child or parent then traverse back until you reach the root. This can be done in O(|V|-1).
null
null
|reference-request|recursion|
In "Concrete Mathematics" by Graham, Knuth, Patashnik. Look in Chapter 3: Integer functions.
New try at formalising, with the extra information: $L$ is non-ambiguous if $L=\bigcup_{c\in S} L_cc$ and $\forall c\in S,\exists k\in\mathbb{N}, L\subset \{\prod_{i=1}^{k}(a_icb_i)d,\text{with } a_i,b_i\in(\Sigma\backslash\{c\})^*,d\in S\}$, or in plain text: each possible ending character appears a fixed number o...
|machine-learning|artificial-intelligence|neural-networks|
|terminology|programming-languages|
|algorithms|graphs|shortest-path|
|automata|finite-automata|
I have a some objects with priority that is compound type and is only [partially ordered](http://en.wikipedia.org/wiki/Partial_ordering). I need to select the objects in order of this priority (i.e. yield _minimal_ item each time). But rather than arbitrarily completing the order, I would prefer if the queue was stable...
Priority queue for partially ordered priorities with infima
A __pattern__ (in the context of languages and automata) is a way of defining a set of strings. A string matches a pattern if it belongs in the set defined by that pattern. So, your regular expression is actually a pattern. The question, I think, would be to find the pattern given a set of strings!
The condition > min.priority + weight(min,v) < v.priority can only be true if $v$ is in the queue. If a vertex $v$ has been removed from $Q$ the invariant of Dijkstra's algorithm guarantees we've already found the shortest path to $v$. **Edit: Proof Sketch** Suppose v isn't in Q. Then we must have already fou...
It depends on how they define what is in the queue ($Q$). There are two options: 1. Initially all vertices are added in the queue, the source with distance $0$, all the other with distance $\infty$. 2. Initially only source is added with distance $0$, other vertices are added when discovered. Now in the first ...
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...
It depends on how they define what is in the queue ($Q$). There are two options: 1. Initially all vertices are added in the queue, the source with distance $0$, all the other with distance $\infty$. 2. Initially only source is added with distance $0$, other vertices are added when discovered. Now in the first ...
null
The answer is no. What you want to do is to predict randomness. The perceptron network takes randomboolean(true/false) and it outputs outputboolean(not random!!). The random generation of targetboolean is independent from the generation of outputboolean. Perceptrons generally learn functions. If you have $f(A)=B$ an...
The answer is no. What you want to do is to predict randomness. The perceptron network takes randomboolean(true/false) and it outputs outputboolean(not random!!). The random generation of targetboolean is independent from the generation of outputboolean. Perceptrons generally learn functions. If you have $f(A)=B$ an...
The basic idea is to have one or more symbol that clearly indicate the end. For example: Non-ambiguous: > $ab^*c$ $(a|b)c$ > $ab^+c$ > $ab?c$ > $a(b|c)$ > $c(ab)^*ccc$ > $acc^*d$ > $abc|bcd$ Ambiguous: > $abc^*$ $abc^+$ $abc?$ $acc^*$ or $ac^*c$ An alternative defin...
In the CLRS book 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\limits_{u \in U}\sum\limits_{v \in U}f(u, v) - \sum\limits_{u \i...
Push relabel algorithms in flow networks
|algorithms|graphs|network-flow|
Let $w \in \mathrm{PRIME}'$ with $|w| \geq 5$. Distinguish two cases. 1. $|w|$ is even -- in that case, choose $x = \varepsilon$, $y = aa$ and $z = a^{|w|-2}$. Then, for all $i\geq 0$, we have $|xy^iz|$ is even and greater than two, as $|z| \geq 3$, and therefore not prime; $xy^iz \in \mathrm{PRIME}'$. 2. $|w|$...
null
So I have a fun little problem. It will take a minute to explain, but the situation is conceptually very simple. Suppose you have a string of characters, which is interpreted as groups of one or more contiguous characters. This is for run length encoding or something. For example: > zz22344a is two z's, two 2's, one...
null
According to your alternative definition, you're looking for a language such that $u\in L\Rightarrow \forall v\neq\epsilon, uv\notin L$ (where $\epsilon$ denotes the empty string). That property defines a useful kind of language in coding, called [**prefix-free codes**](http://en.wikipedia.org/wiki/Prefix-free_code...
An alternative way of expressing a lambda abstraction and reduction. Indexes are used instead of lettered terms based on the order of input. Abstractions are surrounded by []'s m -> 1, n -> 2, s -> 3, z ->4 (λmn.(λsz.ms(nsz)))(λsz.sz)(λsz.sz) [1 3 (2 3 4)][1 2][1 2] [[1 2] 2 (1 2 3)][1 2] ...
An alternative way of expressing a lambda abstraction and reduction. Indexes are used instead of lettered terms based on the order of input. Abstractions are surrounded by []'s (λmn.(λsz.ms(nsz)))(λsz.sz)(λsz.sz) m -> 1, n -> 2, s -> 3, z -> 4 (λmn.(λsz.ms(nsz))) = [1 3 (2 3 4)] (λsz.sz) = [1 ...
An alternative way of expressing a lambda abstraction and reduction. Indexes are used instead of lettered terms based on the order of input. Abstractions are surrounded by []'s (λmn.(λsz.ms(nsz)))(λsz.sz)(λsz.sz) m -> 1, n -> 2, s -> 3, z -> 4 (λmn.(λsz.ms(nsz))) = [1 3 (2 3 4)] (λsz.sz) = [1 ...
I want to implement efficiently "streaming Knapsack" problem in java. The problem is I have a stream input of integer data coming continuously for example -1, 2, 9, 5, 5, 11, 1 -3,... The question is to find the first "k" elements in which their sum is "n>0". for example k=3 and n=12, then the solution is: ...,...
Streaming Knapsack Problem
|algorithms|optimization|
An alternative way of expressing a lambda abstraction and reduction. Indexes are used instead of lettered terms based on the order of input. Abstractions are surrounded by []'s (λmn.(λsz.ms(nsz)))(λsz.sz)(λsz.sz) m -> 1, n -> 2, s -> 3, z -> 4 (λmn.(λsz.ms(nsz))) = [1 3 (2 3 4)] (λsz.sz) = [1 ...
null
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,...
Maximal value of directed graph with constraints
|algorithms|graphs|
Supposing we have two grammars which define the same languge: regular one and LALR(1) one. Both regular and LALR(1) algorithms are O(n) where n is input length. Regexps are usually preferred for parsing regular languages. Why? Is there a formal proof (or maybe that's obvious) that they are faster?
Regular vs LALR(1): what is faster
|parsers|
Typically, a hook is an non-abstract method defined in an abstract class, that can be optionally implemented and overridden in subclasses to modify behaviour. I think this is best exemplified in the template method pattern, where the (abstract) superclass defines the overall semantics for a process, but leaves primitiv...
This was an old exam question, for which i just can't find an answer. - Sorting the points according to a pivot should not be a problem. - Detecting a Left/Right turn (or measering the inner angle) also not Then what is it ?
Why is Graham Scan not easily extensible for 3D?
|computational-geometry|
This was an old exam question, for which i just can't find an answer. - Sorting the points according to a pivot should not be a problem. - Detecting a Left/Right turn (or measering the inner angle) also not Then what is it ? [Wiki Link for Graham Scan][1] [1]: http://en.wikipedia.org/wiki/Graham_scan
l is a matrix of size [1...n, 1...n] function: rec(i,j) if (i*j == 0) return 1 else if (l[i,j] == 0) l[i,j] = 1 * rec(i-1,j) + 2 * rec(i,j-1) + 3 * rec(i-1,j-1) return l[i,j] end_function for i=1 to n for j=1 to n l[i,j] = 0 ...
Example for the analysis of a recursive function
|time-complexity|
Here's the correct recurrence for the running time of rec: $$ 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} $$ The running time of the entire program is $f(n,n) + O(n^2)$. Now it remains to solve the recurrence for $f$, which I l...
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...
relationship between computer science and analytic geometry?
|education|