instruction stringlengths 0 29.8k ⌀ |
|---|
Your point 2, is obviously correct.
As for the point 1, we construct the automaton: let's remember how much more 0's we've read than 1's. Then we have transitions:
S0 by 0 to S1
S0 by 1 to S-1
S1 by 0 to S2
S1 by 1 to S0
S-1 by 0 to S0
S-1 by 1 to S-2
S2 by 1 to S1
S-2 ... |
1.
L2 = E{0,1)
All the words in L2 with equal number of 0's and 1's and every prex of w has at most two more of either
0's or 1's.
2.
All words that does not contain “bbb” as substring.
i think this is :( e + b + bb)(a + ab + abb)*
Thanks in advance! |
I need to present a regular expression for the following languages: |
|regular-expressions| |
The $n$ where the two expressions are equal isn't all **that** huge. Here's how to calculate it.
We want
$$ 1.00001^n \approx n^{100001}.$$
This is the same as
$$e^{n \log 1.00001} \approx e^{100001 \log n}.$$
Now, taking the $\log$ of both sides, and using Taylor's formula to approximate the left-hand side, w... |
The $n$ where the two expressions are equal isn't all **that** huge. Here's how to calculate it.
We want
$$ 1.000001^n \approx n^{1000001}.$$
This is the same as
$$e^{n \log 1.000001} \approx e^{1000001 \log n}.$$
Now, taking the $\log$ of both sides, and using Taylor's formula to approximate the left-hand sid... |
So, I was trying to learn machine learning, and, after watching a couple of Andrew Ng's lectures decided to try and write a simple piece of code to determine what someone's salary would be based on the number of years they worked at a company by this simple linear function:
salary = w1 * numberOfYears + w0
I then... |
Machine Learning: how to correctly calculate gradient descent for simple linear problem |
|machine-learning|linear-algebra| |
I am learning about software design patterns by reading Wikipedia pages about them. A lot of the patterns such as the bridge pattern have diagrams with boxes and different kinds of arrows:
http://upload.wikimedia.org/wikipedia/commons/thumb/c/cf/Bridge_UML_class_diagram.svg/500px-Bridge_UML_class_diagram.svg.png
... |
What do these arrows in design pattern diagrams mean? |
null |
ConcreteImplementer inherits from Implementer,
Same for RefinedAbstraction and Abstraction
The other arrow: these classes composes without belonging to each other.
See reference:
http://www.ivencia.com/softwarearchitect/chapter1/chapter1_6.htm
The paper-like box is a note (a comment). |
The arrows mean distinct things. This is a UML (unified modeling language) diagram. Rules for reading and writing these diagrams are pretty well-established, and you should be able to look up some references.
In that diagram, the hollow arrow means generalization (i.e., inheritance, IS_A), and the hollow diamond mea... |
Lets break the loop as
j = 0;
for ( i = n ; i > 0 ; i = i/2 )
j = j + i ;
Since the input size decreases by half, the total number of iterations would be $\log(n)+1 $
As $i$ becomes $n, n/2 , n/4 \ldots$ up to $\log(n)+1 $ terms, the corresponding $j$ value gets added. <br><br>
So, $val(... |
null |
Lets break the loop as
j = 0;
for ( i = n ; i > 0 ; i = i/2 )
j = j + i ;
Since the input size decreases by half, the total number of iterations would be $\log(n)+1 $
As $i$ becomes $n, n/2 , n/4 \ldots$ up to $\log(n)+1 $ terms, the corresponding $j$ value gets added. <br><br>
So, $val(... |
Lets break the loop as
j = 0;
for ( i = n ; i > 0 ; i = i/2 )
j = j + i ;
Since the input size decreases by half, the total number of iterations would be $\log(n)+1 $
As $i$ becomes $n, n/2 , n/4 \ldots$ up to $\log(n)+1 $ terms, the corresponding $j$ value gets added. <br><br>
So, $val(... |
null |
I'm reading a book about computer network theory, and one topic is discusses is routing algorithms. It only mentions (probably not intentionally) how routers participate in forming the understood network topology stored in each routers memory - the routing tables.
So this brings me to my question, do Host acts lik... |
Routing Algorithms and Hosts |
|computer-networks| |
I'm reading a book about computer network theory, and one topic is discusses is routing algorithms. It only mentions (probably not intentionally) how routers participate in forming the understood network topology stored in each routers memory - the routing tables.
So this brings me to my question, do Host acts lik... |
EDIT: corrected $r$ to add edges just like $f$ does in paragraph 8 per the first comment below.
Having received no response to this question on math.SE, I'm asking it here. Thanks for your help.
In [the Wikipedia article on the Clique problem](http://en.wikipedia.org/wiki/Clique_problem), we are told that under t... |
EDITS: corrected $r$ to add edges just like $f$ does in paragraph 8 per the first comment below. Also specified the Clique problem of interest in paragraph 2.
Having received no response to this question on math.SE, I'm asking it here. Thanks for your help.
In [the Wikipedia article on the Clique problem](http://... |
Let $M$ be any computably enumerable set and define the set $$J_M = \lbrace n \in \mathbb{N} \mid W_n \cap M \neq \emptyset\rbrace,$$
where $W_n$ is the $n$-th computably enumerable set. Then $J_M$ is a computably enumerable set because
$$m \in J_m \iff W_n \cap M \neq \emptyset \iff \exists m . m \in W_n \land m \in... |
I believe you are talking about the Internet and the IP. Here are answers of your questions:
First note the internet is a network of networks. Networks communicate with each other through routers. These big networks are like the ISP, your university or a big organization. Your computer belong to a small network in ... |
Data structures are seen as important, equal to algorithms. This view is especially encouraged in situations, where appropriate data structure is the main factor that allows an algorithm to exist and to perform at satisfying complexity.
However, despite the additional features of data structures (e.g. organization, ... |
Generalized data structure |
|algorithms|data-structures|information-theory| |
$\newcommand{\P}{\mathsf{P}}\newcommand{\PH}{\mathsf{PH}}$
$\newcommand{\SUM}[1]{\Sigma_{#1}^{\P}}\newcommand{\PROD}[1]{\Pi_{#1}^{\P}}$
$\newcommand{\DELTA}[1]{\Delta_{#1}^{\P}}$
$\newcommand{\NP}{\mathsf{NP}}\newcommand{\coNP}{\mathsf{coNP}}$
From the comments:
>Why is $\SUM{1} = \NP$?
Recall the definition of... |
For Shamir's secret sharing scheme (doi>10.1145/359168.359176), one obtains a random polynomial $q$ of degree at most $n-1$ (over $\mathbb{Z}_p[x]$). The constant coefficient of this polynomial is defined to be the key. Then the scheme sends to player $i$ the value $q(i)$ (for $i \leq k$ for some fixed $k$). The inte... |
Condition in Shamir Secret Sharing Scheme |
|probability-theory|information-theory|security| |
For Shamir's secret sharing scheme ([doi 10.1145/359168.359176](http://dx.doi.org/10.1145/359168.359176)), one obtains a random polynomial $q$ of degree at most $n-1$ (over $\mathbb{Z}_p[x]$). The constant coefficient of this polynomial is defined to be the key. Then the scheme sends to player $i$ the value $q(i)$ (f... |
|probability-theory|cryptography| |
There is no problem. True, if the polynomial you pick is of degree 1, then two parties can find the secret. However, they don't know that fact (without learning the other shares).
For instance, assume that the secret is 0, and you picked the polynomial $x$.
Thus party 1 gets $q(1)=1$ and party 2 gets $q(2)=2$.
H... |
I am not sure if this will completely answer the question, but I have a couple observations that might help.
First, note that for the random polynomial $q$, $q(0) = a_0$ is the key -- this is from the way that polynomial interpolation works. So it is important that the value $q(0)$ is never sent to a participant;... |
First off, your gradient is `error*x1` with respect to w1, but not to w0. The gradient for w0 is just `error`.
Second, you're computing `error` with the wrong sign. It should be `predicted - actual`, not the other way around. What you're doing is essentially *adding* the gradient at every step. |
null |
I see two possible flaws in your reasoning. 1) At least the first level of the page table is typically pinned in memory (so it could never cause a page fault). 2) The page fault rate is presumably independent of the TLB miss rate (i.e., it is page faults per access not page faults per TLB miss).
This still will no... |
Notice that a data structure stores more than just it's accessible elements. This is probably what mean by *additional feature*, but I would consider it the *essential feature*. Take for example a binary search tree. This tree stores information on the order of its elements. In particular, by a traversal you can output... |
It looks like [subset-sum problem](https://en.wikipedia.org/wiki/Subset_sum). It should be possible to adapt the pseudopolynomial algorithm. |
I think I'm confused about deletion in heaps, and since I have an exam today, I'm looking for your help to correct me.
I will post photos since it will makes it a bit more clear.
Note(forget about deleting the root)
![enter image description here][1]
What I understand is that , heaps only deletes the root e... |
Deletion in min/max heaps |
|data-structures|heaps| |
In class this week we've been learning about the CFLs and their closure properties. I've seen proofs for union, intersection and compliment but for reversal my lecturer just said its closed. I wanted to see the proof so I've been searching for the past few days but all I've found is most people just say that to reverse... |
Context-free Languages closed under Reversal |
|context-free|closure-properties| |
Given $n \in \mathbb{N}$ and $p,q \in \mathbb{N}[x_1,\ldots,x_n]$ one can define the following formula in the language of formal arithmetics
$$\varphi(n,p,q) = \forall x_1 \cdots \forall x_n : \neg (p(x_1,\ldots,x_n) = q(x_1,\ldots,x_n))$$
I would like to show that there are infinitely many triples $(n,p,q)$ su... |
Question related to Hilbert's 10th problem |
|computability|logic|undecidability| |
Given $n \in \mathbb{N}$ and $p,q \in \mathbb{N}[x_1,\ldots,x_n]$ one can define the following formula in the language of formal arithmetics
$$\varphi(n,p,q) = \forall x_1 \cdots \forall x_n : \neg (p(x_1,\ldots,x_n) = q(x_1,\ldots,x_n))$$
I would like to show that there are infinitely many triples $(n,p,q)$ su... |
Your sources are right, and I am afraid there is only little to add, except formalisms.
I denote the reverse (mirror) of string $w$ by $W^R$.
If $G$ is a grammar, let $H$ be its reversed, so for production $A\to w$ in $G$ we have $A\to w^R$ in $H$. Then by induction we show that $A\Rightarrow_G^*w$ iff $A\Rightarro... |
Your sources are right, and I am afraid there is only little to add, except formalisms.
I denote the reverse (mirror) of string $w$ by $w^R$.
If $G$ is a grammar, let $H$ be its reversed, so for production $A\to w$ in $G$ we have $A\to w^R$ in $H$. Then by induction we show that $A\Rightarrow_G^*w$ iff $A\Rightarro... |
I'm constructing a [deterministic finite automata][1] (DFA) for a language of all strings defined over $\{0,1\}$ whose length is even and number of $1$s is odd. I constructed each DFA separately and then combined:
![dfas and their union][2]
- Is the given procedure for combining DFAs correct?
**EDIT:** Orig... |
here a question, and after my arguments:
V is an AVL of N elements, after N^2 entries how will be its height?
my idea:
the height of an AVL is $O(log(n))$ where $n$ is the number of elements.
So the height will be $O(log(n+n^2))=O(log(n^2))=O(2log(n))=O(log(n))$.
Based of that my answer to this qu... |
Height of AVL after entries |
|algorithms| |
here a question, and after my arguments:
V is an AVL of N elements, after the insertion of N^2 elements how will be its height?
my idea:
the height of an AVL is $O(log(n))$ where $n$ is the number of elements.
So the height will be $O(log(n+n^2))=O(log(n^2))=O(2log(n))=O(log(n))$.
Based of that my... |
So, I was trying to learn machine learning, and, after watching a couple of Andrew Ng's lectures decided to try and write a simple piece of code to determine what someone's salary would be based on the number of years they worked at a company by this simple linear function:
salary = w1 * numberOfYears + w0
I then... |
null |
I am trying to understand how a `OUTER UNION` works, and why it is only partially compatible.
I am aware this operation was created to take union of tuples from two relations if the relation are not type compatible (which I understand).
Examples of this operation will be great! |
What is OUTER UNION and why is it partially compatible |
|relational-algebra| |
first the Bell-LaPadula Model cannot capture changes over time. second, more serious problem arises when one considers that subjects in the Chinese Wall model may choose which CDs(company dataset) to access; in other words, initially a subject is free to access all objects. the Bell-LaPadula Model cannot emulate the Ch... |
I am trying to understand how a `OUTER UNION` $∪^✳$ works, and why it is only partially compatible.
I am aware this operation was created to take union of tuples from two relations if the relation are not type compatible (which I understand).
Examples of this operation will be great!
|
There are two flavors of outer union: with and without `NULL`s. Google search readily exibits [an example][1] for `NULL`s version. The cleaner version of relational algebra desn't allow `NULL`s, and outer union is defined via De Morgan's law:
$ X \bigcup Y = \overline {\overline X \Join \overline Y} $
Date&Da... |
A min-heap typically only supports a delete-min operation, not an arbitrary delete(x) operation. I would implement delete(x) as a composition of decrease-key(x, $-\infty$), and delete-min. Recall, that to implement decrease-key, you would bubble up the element to maintain the heap property (in this case all the way to ... |
I experience a difficulty in solving exercises in distributed algorithm. Below is the the exercise I try to solve, it looks like I miss basic idea.
**Exercise.** Consider a 15-processor asynchronous network with processors 0,…,14. The processors constantly run a synchronizer. Let $v$ and $v'$ be two processors in t... |
Dictributed algorithms - $\alpha, \beta$ synchronizers |
|algorithms|distributed-systems|synchronization| |
|optimization|binary-trees|dynamic-programming|efficiency|arithmetic| |
null |
For the first case ($\alpha$-synchronizer), the pulse at a node can either be more, equal, or less by one (therefore, {26,27,28}). This is because a node must inform its neighbors about its safeness and not all the other nodes (according to your question).
You can see the rules in the following (copy-pasted from th... |
Please find solutions of all cases:
For case A ($\alpha$-synchronizer), the pulse at a node can either be more, equal, or less by one (therefore, $\{26,27,28\}$). This is because a node must inform its neighbors about its safeness and not all the other nodes (according to your question).
You can see the rules in... |
I'm trying to figure out how a Pushdown automata (PDA), which we know uses a stack (LIFO) can be simulated by a queue (FIFO). I understand that in a regular PDA, we only have access to the top most element which can be popped. When we push something, it goes to the top of the stack.
In a queue, as I understand, ele... |
Pushdown automata |
|pushdown-automata| |
Please find solutions of all cases:
For case A ($\alpha$-synchronizer), the pulse at a node can either be more, equal, or less by one (therefore, $\{26,27,28\}$). This is because a node must inform its neighbors about its safeness and not all the other nodes (according to your question).
You can see the rules in... |
How can one simulate a PDA with a FIFO queue PDA? |
I'm trying to figure out how a pushdown automata (PDA), which we know uses a stack (LIFO) can be simulated by a queue (FIFO). I understand that in a regular PDA, we only have access to the top most element which can be popped. When we push something, it goes to the top of the stack.
In a queue, as I understand, ele... |
The answer is: "rotate".
Consider the stack like (*bottom*) `ABCD` (*top*). stack-pop is from top, queue-pop is from bottom (this is directed to myself, I am easily confused). Pushes are from top.
Now, if we want to stack-pop, we push a marker `#` (to top) then repeatedly queue-pop and push, essentially moving ev... |
null |
I don't understand the word instance used? Quoting from the CLRS book on page 1054 on abstract problems:we define an abstract problem Q to be a binary relation on a set I of problem instance and set S of problem solution. |
What does it mean an instance of NP complete problem? |
|np-complete| |
A problem instance is the actual case you're trying to solve.
For example, the problem "can this set of numbers be divided into two sets which have the same sum" is an NP-hard problem. An instance of this problem would be an actual set of numbers, for example 87, 58, 62, 104, 29, 78. |
I don't understand this definition of an "instance" of a problem. Quoting from the CLRS book on page 1054 on abstract problems (Chapter 34.1):
> We define an abstract problem $Q$ to be a binary relation on a set $I$ of problem **instances** and set $S$ of problem **solutions**. |
What is an instance of NP complete problem? |
null |
Distributed algorithms - $\alpha, \beta$ synchronizers |
null |
> **Shameless Advertisement:** [Game Theory proposal][1]
> on Area 51 that you should totally follow!
**No**. The easiest way to prove this is by counterexample. Expanding [matching pennies][1], we can create a game with two mixed strategies (players either mix between A and B or between C and D):

> on Area 51 that you should totally follow!
**No**. The easiest way to prove this is by counterexample. Expanding [matching pennies][1], we can create a game with two ... |
> **Problem:** Suppose $V$ is an [AVL tree][1] (a self-balancing binary search tree) of $n$
> elements. After the insertion of $n^2$ elements, what would be its
> height?
**My idea:** the height of an AVL tree is originally $O(\log(n))$ where $n$ is the number of elements. After insertion of $n^2$ elements, its he... |
|algorithms|asymptotics|binary-trees|search-trees| |
null |
To show that this isn't always the case, imagine you added $e^n$ elements, then it would take
$$O(\log(n+e^n))=O(\log(e^n))=O(n)$$
But what does that really mean? It's not that your binary tree takes $O(n)$ time on $n$ elements to find something. Rather, it takes $O(\log(m))$ time for $m=n+e^n$ elements.
I can... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.