instruction stringlengths 0 29.8k ⌀ |
|---|
|threads| |
null |
I simple method to "visualize" what is happening, is "inserting" the procedure in the point where it is called:
CALL BY VALUE:
a := 1; b := 2;
p(a, b)
//// procedure p (x, y : integer);
x := a; y := b; // x and y are two "new" variables
//// begin
x := x + 2 ; // x = 3
... |
null |
I simple method to "visualize" what is happening, is "inserting" the procedure in the point where it is called:
CALL BY VALUE-RESULT:
a := 1; b := 2;
p(a, b)
//// procedure p (x, y : integer);
x := a; y := b; // x and y are two "new" variables
//// begin
x := x + 2 ; // x =... |
I am slightly confused. If $k$ is a constant, then you can try all $O(n^k)$ possible tours. Hence the problem is in ${\sf P}$
However, if $k$ is part of the input, the decision problem is ${\sf NP}$-complete. This can be shown by reducing $\text{HAM-CUIRCUIT}$ to the problem, by the following reduction.
Assume th... |
Let's start with the comparison sorting lower bound proof, which I'll summarize as follows:
1. For $n$ distinct numbers, there are $n!$ possible orderings.
2. There is only one correct sorted sequence of the $n$ numbers.
3. We are given that comparison ($<$) is the only operation we have that can narrow down the $... |
Generalizing the Comparison Sorting Lower Bound Proof |
|proof-techniques|sorting| |
Let's start with the comparison sorting lower bound proof, which I'll summarize as follows:
1. For $n$ distinct numbers, there are $n!$ possible orderings.
2. There is only one correct sorted sequence of the $n$ numbers.
3. We are given that comparison ($<$) is the only operation we have that can narrow down the $... |
|proof-techniques|sorting|information-theory|check-my-proof|lower-bounds| |
null |
While studying master method at recurrences topic i'm stacked at a point.It is written inm the book as:
T(n) = 3T(n/4) + n.lg n,
we have a = 3, b = 4,
f (n) = n.lg n, and
n^(logb(a) (b is base)) = n^(log4(3) (4 is base)) = O(n^793).
Since f(n) = Ω(n^(log4(3)+ε (4 is base) )), wher... |
big omega of n.lgn |
|untagged| |
While studying master method at recurrences topic I'm stacked at a point. It is written in the book as:
> $T(n) = 3T(n/4) + n \log n$,
> we have $a = 3, b = 4$,
> $f(n) = n \log n$, and
> $n^{\log_b(a)} = n^{\log_4 3} = O(n^{0.793})$.
> Since $f(n) = \Omega(n^{\log_4( 3)+\varepsilon} )... |
|asymptotics|landau-notation|master-theorem| |
Big Omega of $n \log n$ |
**EDIT:**<br>
An addendum: if you want to "simulate" call by value-result in Pascal (or in another language that supports only call by reference); you can use this trick:
procedure p(var x, y : Integer); // simulates call by value-result
var
xtmp, ytmp : Integer;
procedure p_hidden(var x,... |
processes and threads have altogether a different execution cycle ...
threads will execute and die but still process will continue to run until it gets a exit ,truncate or die call due to normal execution or in case of deadlock handling.
If process contains only 1 thread.(assumption which is actually naive )
... |
null |
Yes, $ nlogn = \Omega(n) $ is true. To see why, note that for this to be true, we have to show that $ nlogn \ge cn \forall n \gt n_0 $ and $ \exists c \gt 1 $. If we take $ c = 1 $ then, we get $nlogn \ge n \forall n \ge 2$. This shows that $ nlogn = \Omega(n) $ is true. |
null |
In short, **the lifecycle of thread does not interfere with the lifecycle of a process**.
Processes and threads have different execution cycles; threads will execute and die while their process will continue to run until it gets a exit, truncate or die call due to normal execution (or in case of deadlock handling).... |
null |
null |
Insertion-Sort (A) [where A is an array of numbers to be sorted]
(1) for j = 2 to A.length
(2) key = A[j]
(3) i = j -1
(4) while i > 0 and A[i] > key
(5) A[i+1] = A[i]
(6) i = i - 1
(7) A[i + 1] = key
CLRS proves the correctio... |
Loop invariants? |
|algorithms|algorithm-analysis|correctness-proof| |
Is there is a study or classification available on different types of databases? (Examples include structured, unstructured, semi structured relational, object oriented, folksonomies, etc.) |
null |
I am confused. If $k$ is a constant, then you can try all $O(n^k)$ possible tours. Hence the problem is in ${\sf P}$.
However, if $k$ is part of the input, the decision problem is ${\sf NP}$-complete. This can be shown by reducing $\text{HAM-CIRCUIT}$ to the problem, by the following reduction.
Assume that we wan... |
null |
I am slightly confused. If $k$ is a constant, then you can try all $O(n^k)$ possible tours. Hence the problem is in ${\sf P}$.
However, if $k$ is part of the input, the decision problem is ${\sf NP}$-complete. This can be shown by reducing $\text{HAM-CIRCUIT}$ to the problem, by the following reduction.
Assume th... |
I went through a question asking me to choose the ambiguous language among a set of options.
$$L_1 = \{a^nb^mc^md^n \;|\; m,n \geq 1\}\cup \{a^nb^nc^md^m \;|\; m,n \geq 1\}$$
$$and$$
$$L_2 = \{a^nb^mc^m \;|\; m,n \geq 1\}\cup \{a^nb^nc^m \;|\; m,n \geq 1\}$$
The solution said that $L_1$ is ambiguous while $L_... |
Ambiguity of the language $L_2 = \{a^nb^mc^m \;|\; m,n \geq 1\}\cup \{a^nb^nc^m \;|\; m,n \geq 1\}$ |
|formal-languages|formal-grammars|context-free|ambiguity| |
null |
I went through a question asking me to choose the inherently ambiguous language among a set of options.
$$L_1 = \{a^nb^mc^md^n \;|\; m,n \geq 1\}\cup \{a^nb^nc^md^m \;|\; m,n \geq 1\}$$
$$and$$
$$L_2 = \{a^nb^mc^m \;|\; m,n \geq 1\}\cup \{a^nb^nc^m \;|\; m,n \geq 1\}$$
The solution said that $L_1$ is ambiguou... |
Inherent ambiguity of the language $L_2 = \{a^nb^mc^m \;|\; m,n \geq 1\}\cup \{a^nb^nc^m \;|\; m,n \geq 1\}$ |
I am getting confused in regular expression (a/b)* as its for sure it would contain (aab),(ab)... as its sub-strings.
Can (a/b)* also contain sub strings as (aa),(aaaa),(bb),(bbb) i.e only a's and b's alone?
Please clear my doubt? |
Can (a/b)* can also contain its sub strings as only a's and b's? |
|regular-expressions| |
I went through a question asking me to choose the inherently ambiguous language among a set of options.
$$L_1 = \{a^nb^mc^md^n \;|\; m,n \geq 1\}\cup \{a^nb^nc^md^m \;|\; m,n \geq 1\}$$
$$and$$
$$L_2 = \{a^nb^mc^m \;|\; m,n \geq 1\}\cup \{a^nb^nc^m \;|\; m,n \geq 1\}$$
The solution said that $L_1$ is ambiguou... |
$(a|b)*$ can be written as
$(a|b)(a|b)(a|b)(a|b)...$
You can select any of $a$ or $b$ from every term. So strings like $aa$, $aaaa$, $bb$, $bbb$ are possible.
Moreover, this expression will contain every possible combination of $a$ and $b$ including 0 $a$s and 0 $b$s (ie empty string or $\epsilon$) |
I've got two log-space programs F and G.
- Program F will get input in array A[1..n] and he will create the output array B[1..n].
- Program G will get the input array B which has the program F created and create from him the output array C[1..n]
I have to write a proof that there exist log-space program H,... |
Log-space program proof |
|untagged| |
You're quite right to be dubious, $L_{2}$ is also inherently ambiguous. It's even been used as a "prototype of an inherently ambiguous language" by [Flajolet][1] (right at the start of section 2).
[1]: http://algo.inria.fr/flajolet/Publications/Flajolet87b.pdf |
The question is wrong. The second language is also inherently ambiguous. The usual way this is proved is as follows. Suppose $L_2$ had an unambiguous grammar. Let $p$ be the constant promised by [Ogden's lemma][1], and consider the word $a^{p!+p} b^p c^p$. Mark the positions of $b^p c^p$ and apply Ogden's lemma to pump... |
I went through a question asking me to choose the inherently ambiguous language among a set of options.
$$L_1 = \{a^nb^mc^md^n \;|\; m,n \geq 1\}\cup \{a^nb^nc^md^m \;|\; m,n \geq 1\}$$
$$and$$
$$L_2 = \{a^nb^mc^m \;|\; m,n \geq 1\}\cup \{a^nb^nc^m \;|\; m,n \geq 1\}$$
The solution said that $L_1$ is ambiguou... |
The invariant for the outer loop is sufficient, but first you need to prove that it's actually an invariant. For that, you need to provide and prove a precondition and postcondition for every statement inside the loop. And to prove a precondition and postcondition for the inner loop, you need another invariant.
To a... |
null |
I've got two log-space programs $F$ and $G$.
- Program $F$ will get input in array $A[1..n]$ and will create the output array $B[1..n]$.
- Program $G$ will get as input $B$ as created by $F$ and create from it the output array $C[1..n]$.
I have to write a proof that there exist a log-space program $H$, whi... |
|algorithms|complexity-theory|simulation|space-complexity| |
Simulate the concatenation of two log-space programs in log-space |
I am getting confused by the regular expression $(a\mid b)^*$ as it for sure matches $aab$ and $ab$.
Does $(a\mid b)^*$ also match strings like $aa$, $aaaa$, $bb$ or $bbb$, that is those that use only $a$ or $b$? |
Does $(a \mid b)^*$ match $a^n$ and $b^n$? |
|formal-languages|terminology|regular-expressions| |
|terminology|operating-systems|process-scheduling|threads| |
|terminology|programming-languages|semantics| |
From my Googling, it appears that call by value-result is similar to call by reference in that it changes values in the caller, but it's different in that the changes don't take place until the callee exits, and that if the same variable is passed as more than one argument, it'll be treated as separate values in the ca... |
|complexity-theory|np-complete|computational-geometry| |
|algorithms|reference-request|dynamic-programming| |
|logic|linear-temporal-logic| |
Yes, $ n\log n = \Omega(n) $ is true.
To see why, note that for this to be true, we have to show that $ n\log n \ge cn$ for all $n \gt n_0 $ and $ \exists c \gt 1 $. If we take $ c = 1 $ then, we get $n\log n \ge n$ for all $n \ge 2$. This shows that $ n\log n = \Omega(n) $ is true. |
You would also want to keep in mind that the state of an object is an "abstract" entity, as determined by what is observable by the methods. For instance, an object that implements a hash table has as its state, the *collection of values* stored in the hash table, not all the internal representation details. |
**Yes**: $(a\mid b)^*$ is the concatenation of any number of $a$ and $b$, so the expression matches $a^n$ and $b^n$.
As you can read more about on [Wikipedia][1], the vertical bar $\mid$ is the boolean "or" relation (one or the other must be included in the regular expression), while the asterisk $^*$ indicates that... |
null |
Call the two partitions of the nodes $A$ and $B$. Add two new nodes, a source $s$ and a sink $t$. Connect the start node to all nodes in $A$ with an edge with max capacity of one. Connect all the nodes in $B$ to the sink with edges with a max capacity of one. And lastly give all the original edges in the graph a max ca... |
|complexity-theory|graphs|reductions|network-flow| |
Most of the below is from [Parsing Theory][1] by Sippu and Soisalon-Soininen.
Let $Q$ be the set of states of the DFA. Let $T$ be the input alphabet. Let $|M|=O(|T| \cdot |Q|)$ be the size of the machine. Exercise 3.40 gives a $O(|T|\cdot|Q|^2)$ algorithm for state minimization. As [Wikipedia describes][2], Hopcroft... |
Hollywood. A film producer is seeking actors and investors for his new movie. There are n available actors; actor i charges si dollars. For funding, there are m available investors. Investor j will provide pj dollars, but only on the condition that certain actors Lj µ {1,2,...n) are included in the cast (all of these a... |
Linear programming/optimal solution |
|linear-programming| |
null |
A film producer is seeking actors and investors for his new movie. There are n available actors; actor i charges si dollars. For funding, there are m available investors. Investor j will provide pj dollars, but only on the condition that certain actors Lj⊆{1,2,...,n}, are included in the cast (all of these actors Lj mu... |
Using the *variables are boxes* analogy.
//a := 1
| 1 | <-- Variable a, with holding the value 1
|_______|
procedure f(x: Integer)...
**Call by value**: On a call `f(a)`, the value of `a` is loaded (*copied* into the function `f`'s *very own* box `x`. It receives a **copy** of the valu... |
Using the *variables are boxes* analogy.
//a := 1
| 1 | <-- Variable a, with holding the value 1
|_______|
procedure f(x: Integer)...
**Call by value**: On a call `f(a)`, the value of `a` is loaded (*copied* into the function `f`'s *very own* box `x`. It receives a **copy** of the valu... |
**Yes**: $(a\mid b)^*$ is the concatenation of any number of $a$'s and $b$'s, so the expression matches $a^n$ and $b^n$.
As you can read more about on [Wikipedia][1], the vertical bar $\mid$ is the boolean "or" relation (one or the other must be included in the regular expression), while the asterisk $^*$ indicates ... |
**Yes**: $(a\mid b)^*$ is the concatenation of any number of $a$'s and $b$'s, so the expression matches $a^n$ and $b^n$.
As you can read more about on [Wikipedia][1], the vertical bar $\mid$ is the boolean "or" relation (one or the other must be included in the regular expression), while the asterisk $^*$ indicates ... |
After some digging around thanks to mhum's pointer to OEIS, I've finally found an excellent analysis and a nice (relatively) elementary argument (due, as far as I can tell, to Goldstein and Moews [1]) that $M(n)$ grows superexponentially fast in $n$:
Any involution $\iota$ of $\{1\ldots n\}$ corresponds to a run of ... |
null |
> Express this problem as an integer linear program in which the variables take on values on [0,1]
$$\begin{align}
\text{max: } &\sum_i^m y_i \cdot p_i - \sum_j^n x_j \cdot s_j &\\
\text{subject to: } &x_i \geq y_j &\forall i \in L_j \\
&0 \leq x_i \leq 1 &\forall i \\
&0 \leq y_j \leq 1 &\forall j
\end{alig... |
> Express this problem as an integer linear program in which the variables take on values on [0,1]
$$\begin{align}
\text{max: } &\sum_i^m y_i \cdot p_i - \sum_j^n x_j \cdot s_j &\\
\text{subject to: } &x_i \geq y_j &\forall i \in L_j \\
&0 \leq x_i \leq 1 &\forall i \\
&0 \leq y_j \leq 1 &\forall j
\end{alig... |
|optimization|linear-programming| |
> Express this problem as an integer linear program in which the variables take on values on [0,1]
$$\begin{align}
\text{max: } &\sum_i^m y_i \cdot p_i - \sum_j^n x_j \cdot s_j &\\
\text{subject to: } &x_i \geq y_j &\forall i \in L_j \\
&0 \leq x_i \leq 1 &\forall i \\
&0 \leq y_j \leq 1 &\forall j
\end{alig... |
A film producer is seeking actors and investors for his new movie. There are $n$ available actors; actor $i$ charges $s_i$ dollars. For funding, there are $m$ available investors. Investor $j$ will provide $p_j$ dollars, but only on the condition that certain actors $L_j \subseteq \{1,2,...,n\}$, are included in the ca... |
> Express this problem as an integer linear program in which the variables take on values on [0,1]
$$\begin{align}
\text{max: } &\sum_i^m y_i \cdot p_i - \sum_j^n x_j \cdot s_j &\\
\text{subject to: } &x_i \geq y_j &\forall i \in L_j \\
&0 \leq x_i \leq 1 &\forall i \\
&0 \leq y_j \leq 1 &\forall j
\end{alig... |
I'm struggling to understand the relationship between NP-Intermediate and NP-Complete. I know that if P != NP based on Lander's Theorem there exists a class of languages in NP but not in P or in NP-Complete. Every problem in NP can be reduced to an NP-Complete problem, however I haven't seen any examples for reducing a... |
Reducing the integer factorization problem to an NP-Complete problem |
|np-complete|reductions|factoring| |
I have difficulties understanding the definition of of Max-SNP, thus I have to following basic question:
If a problem is known to be Max-SNP hard, does this imply NP-hardness of the problem? |
Does Max-SNP hard imply NP-hard |
|complexity-theory| |
1. Express this problem as an integer linear program in which the variables take on values on [2,3]
2. Show that there must in fact be an optimal solutionz
I am lost on both parts for this problem. |
solution LP algo |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.