instruction stringlengths 0 29.8k ⌀ |
|---|
The below text is taken from the book : Operating Systems: Internals and Design Principles by William Stallings, 8th edition, page 68.
> Scheduling and Resource Management
>
> A key responsibility of the OS is to manage the various resources
> available to it (main memory space, I/O devices, processors) and to
... |
few weeks ago I had an exam in automata theory course and I've been asked to write the following non-deterministic finite automata
> Write a NFA which accepts the following language - the language contains all the words (above `{a, b, c}`) with at least 1 appearance of the letter c, **or** the parity of the count of... |
Understanding why a finite state machine is incorrect |
|automata|finite-automata| |
few weeks ago I had an exam in automata theory course and I've been asked to write the following non-deterministic finite automata
> Write a NFA which accepts the following language - the language contains all the words (above `{a, b, c}`) with at least 1 appearance of the letter c, **or** the parity of the count of... |
Finite state machine that accepts every word with at least one c, or different value of parity of the counts of a's and c's |
null |
You can solve the second clause with two states with meanings "same parity" vs. "different parities", both $a$ and $c$ switching between both.
But I don't see how to avoid two additional states to handle the "at least one $c$" clause.
|
You can solve the second clause with two states with meanings "same parity" vs. "different parities", both $a$ and $c$ switching between both.
But I don't see how to avoid two additional states ("odd $a$, no $c$" and "even $a$, no $c$") to handle the "at least one $c$" clause.
|
When you want to prove a reduction is true (such as this from 3-Dimensional Matching to Subset Sum), what you want to show is that you can take any input for 3-Dimensional Matching and turn it into an input for Subset Sum - not the other way around, as you seem to want.
So, to explain (as it seemed as though you wer... |
null |
I have a problem to solve, but I am having some issues with it...
Find an algorithm with time complexity O(V+E), where V and E stand for vertices and edges respectively. The algorithm searches a tree graph for a subgraph. The subgraph is supposed to be the so called [caterpillar graph][1], i.e. a path with "legs" or... |
Find the largest caterpillar subtree |
null |
null |
Consider [Merge-sort][1] algorithm that we modify as follow:
Suppose we extend it to divide the input array into $m$ not necessary equal and after sorting each of them, merge them. Now can we conclude that the running time will be $O(n\log n)$?
I think the running time should be $O(n^2)$ as follow:
If the alg... |
$m-$way merge sort, extended merge sort |
|algorithms| |
Not every job that a computer has to do has equal importance or urgency.
An example is different I/O devices which work at different speeds. A network interface, for example, generally runs at a much higher bandwidth than a keyboard or mouse, so servicing the network interface would typically be a higher priority ta... |
null |
null |
If there is a function `f` that has a `while loop` or `for loop`, can I compile this function into an `acyclic boolean circuit` that ensures that each gate is topologically ordered, i.e. there is no feedback? If so, how exactly is that done, by loop expansion? And if it is allowed to compile the function as a `cyclic b... |
Acyclic boolean circuit (DAG) |
|circuits|boolean-complexity| |
Observe that the language can alternatively defined as the set of strings where the count of $a$ is odd or there is at least one $c$. If we have any $c$ in the string, the parity of $a$ doesn't matter – hence the parity of $a$ matters only when there are no $c$ in the string so the parity of $c$ is even. You can constr... |
If your circuit can contain registers (or some other form of memory or state) (e.g., [sequential logic](https://en.wikipedia.org/wiki/Sequential_logic)), then yes, you can. You store the value of all variables in the registers, and you build a circuit that computes the next value of those variables after one iteration... |
If a function `f` has a `while loop` or `for loop`, can I compile this function into an `acyclic boolean circuit` that ensures that each gate is topologically ordered, i.e. there is no feedback? If so, how exactly is that done, by loop expansion? And if compiling the function as a `cyclic boolean circuit` is allowed, d... |
null |
The linlogarithmic behavior of MergeSort is due to the fact that the size of the subsets decreases geometrically, so that the number of passes over the whole data is logarithmic.
You might very well roll a modified MergeSort that subdivides in fractions $\frac12,\frac13,\frac16$ and keep the same complexity.
But ... |
Observe that the language can alternatively defined as the set of strings where the count of $a$ is odd or there is at least one $c$. If we have any $c$ in the string, the parity of $a$ doesn't matter – hence the parity of $a$ matters only when there are no $c$ in the string so the parity of $c$ is even. You can constr... |
null |
The linlogarithmic behavior of MergeSort is due to the fact that the size of the subsets decreases geometrically rather than arithmetically, so that the number of passes over the whole data is logarithmic.
You might very well roll a modified MergeSort that subdivides in fractions $\frac12,\frac13,\frac16$ and keep t... |
I will show how to find the size of the largest caterpillar subtree, finding a caterpillar of that size can be done by keeping track of the decisions made in the formulas, similar to dynamic programming.
Select a vertex $r$ as the root of the tree. Let $C(v)$ be the size of the largest caterpillar in the subtree of ... |
null |
The usual method is: You prove that there is an optimal solution. (If you want to minimise X and find that X = 1 + epsilon for some epsilon, there might be no optimal solution, or a value that you want to maximise might be arbitrarily large.) Usually there is an optimal solution.
Then you assume that you have any o... |
With a 2-D [orthogonal range](https://en.wikipedia.org/wiki/Range_searching#Orthogonal_range_searching) counting query data structure, you can calculate how many points have a distance less than a specified value from a given point. Here, the query range is a square centered at the source point.
By performing binary... |
[Wikipedia][1] states the time complexity of the General Number Field Sieve is
$$\exp\left( \left(\sqrt[3]{\frac{64}{9}} + o(1)\right)(\ln N)^{\frac{1}{3}}(\ln \ln N)^{\frac{2}{3}}\right),$$
where $N$ is the number to be factored, not the length of the input.
The same site also mentions [quasi-polynomial time][2] ... |
Is GNFS in quasi-polynomial time? |
[Wikipedia][1] states the time complexity of the General Number Field Sieve (GNFS) is
$$\exp\left( \left(\sqrt[3]{\frac{64}{9}} + o(1)\right)(\ln N)^{\frac{1}{3}}(\ln \ln N)^{\frac{2}{3}}\right),$$
where $N$ is the number to be factored, not the length of the input.
The same site also mentions [quasi-polynomial ti... |
[Wikipedia][1] states the time complexity of the General Number Field Sieve (GNFS) is
$$\exp\left( \left(\sqrt[3]{\frac{64}{9}} + o(1)\right)(\ln N)^{\frac{1}{3}}(\ln \ln N)^{\frac{2}{3}}\right),$$
where $N$ is the number to be factored, not the length of the input.
The same site also mentions [quasi-polynomial ti... |
[Wikipedia][1] states the time complexity of the General Number Field Sieve (GNFS) is
$$\exp\left( \left(\sqrt[3]{\frac{64}{9}} + o(1)\right)(\ln N)^{\frac{1}{3}}(\ln \ln N)^{\frac{2}{3}}\right),$$
where $N$ is the number to be factored, not the length of the input.
The same site also mentions [quasi-polynomial ti... |
[Wikipedia][1] states the time complexity of the General Number Field Sieve (GNFS) is
$$\exp\left( \left(\sqrt[3]{\frac{64}{9}} + o(1)\right)(\ln N)^{\frac{1}{3}}(\ln \ln N)^{\frac{2}{3}}\right),$$
where $N$ is the number to be factored, not the length of the input.
The same site also mentions [quasi-polynomial ti... |
[Wikipedia][1] states the time complexity of the General Number Field Sieve (GNFS) is
$$\exp\left( \left(\sqrt[3]{\frac{64}{9}} + o(1)\right)(\log N)^{\frac{1}{3}}(\log \log N)^{\frac{2}{3}}\right),$$
where $N$ is the number to be factored, not the length of the input.
The same site also mentions [quasi-polynomial... |
[Wikipedia][1] states the time complexity of the General Number Field Sieve (GNFS) is
$$\exp\left( \left(\sqrt[3]{\frac{64}{9}} + o(1)\right)(\log N)^{\frac{1}{3}}(\log \log N)^{\frac{2}{3}}\right),$$
where $N$ is the number to be factored, not the length of the input.
The same site also mentions [quasi-polynomial... |
Problem is "Constructing a Dfa accepting set of all strings whose 10th symbol from the right end is 1 over {0,1}"
The NFA is easy
> (0+1)*1(0+1)^9
, but DFA has to have minimum 2^10 states.
I've tried to see the pattern by constructing 2nd and 3rd symbol from the right.
I mean, when it is the 2nd from th... |
DFA- Set of all strings whose 10th symbol from the right end is 1 |
|automata|finite-automata| |
Wikipedia states that the time complexity of the [General Number Field Sieve][1] (GNFS) is
$$\exp\left( \left(\sqrt[3]{\frac{64}{9}} + o(1)\right)(\log N)^{\frac{1}{3}}(\log \log N)^{\frac{2}{3}}\right),$$
where $N$ is the number to be factored.
The same site also mentions [quasi-polynomial time][2] is
$$\mbox{QP... |
In many academic papers algorithms are described. They seem to use similar "syntax".
Is there a standard for this language? If I want to describe an algorithm, would I improvise my description?
For example, note that papers in general use
a <-- b
to assign a, not a = b. But where is that standard? |
Is there a "Standard Algorithm" language, as used in academic papers? |
|algorithms| |
Wikipedia states that the time complexity of the [General Number Field Sieve (GNFS)][1] is
$$\exp\left( \left(\sqrt[3]{\frac{64}{9}} + o(1)\right)(\log N)^{\frac{1}{3}}(\log \log N)^{\frac{2}{3}}\right),$$
where $N$ is the number to be factored.
The same site also mentions that [quasi-polynomial time][2] is
$$\mb... |
Wikipedia states that the time complexity of the [General Number Field Sieve (GNFS)][1] is
$$\exp\left( \left(\sqrt[3]{\frac{64}{9}} + o(1)\right)(\log N)^{\frac{1}{3}}(\log \log N)^{\frac{2}{3}}\right),$$
where $N$ is the number to be factored.
The same site also mentions that [quasi-polynomial time][2] is
$$\mb... |
Let me comment on your description. To make notation more definite, I will talk about types `T` and `E(T)`, where `E` stands for your "enhanced context". For example, `E` could be `List` or `Promise` or something else.
> The combination of unit and fmap constitute a functor
Usually `unit` is not required for a fu... |
No. There is no universal standard. There are some conventions that have become more popular over time, through gradual evolution.
A good starting place to look would be to look at the pseudocode notation used in a few common algorithms textbooks, pick one you like, and try to emulate it. Probably anything done i... |
Is there an algorithm to multiply two polynomials with coefficients in the max-plus semiring $(\mathbb{Z}\cup\{-\infty\}, \max, +)$ which is faster than the trivial one? I'm interested in the coefficient of the product, so I can't ignore the differences between to polynomials which specify the same function. This makes... |
Subquadratic multiplication of polynomials in the max-plus/tropical semiring |
|algorithms|complexity-theory|time-complexity|polynomials| |
Is there an algorithm to multiply two polynomials with coefficients in the max-plus semiring $(\mathbb{Z}\cup\{-\infty\}, \max, +)$ which is faster than the trivial one? I'm interested in the coefficients of the product, so I can't ignore the differences between to polynomials which specify the same function. This make... |
Is there an algorithm to multiply two polynomials with coefficients in the max-plus semiring $(\mathbb{Z}\cup\{-\infty\}, \max, +)$ which is faster than the trivial one? I'm interested in the coefficients of the product, so I can't ignore the differences between two polynomials which specify the same function. This mak... |
Problem is "Constructing a DFA accepting set of all strings whose 10th symbol from the right end is $1$ over $\{0,1\}$"
The NFA is easy
$$(0+1)^*1(0+1)^9$$
but DFA has to have minimum $2^{10}$ states.
I've tried to see the pattern by constructing 2nd and 3rd symbol from the right.
I mean, when it is the... |
DFA that accepts strings whose 10th symbol from the right end is 1 |
|automata|finite-automata|arithmetic| |
> I cannot see a way to visualize it graphically as it is asked in the question.
It is not necessary nor required of you to visualize or draw a wanted dfa. The exercise only asks you to "construct a DFA accepting ...". The meaning of constructing a DFA is specifying/describing/defining the 5-tuple, $(Q,\Sigma, \delt... |
So the problem is: There is a group of n people that want to meet each other and everyone is divided into pairs, so everyone has a partner that they know. Now there will be parties at which they can get to know each other. At every party there can be as many round tables as needed, at which people can sit. When they si... |
Minimum amount of parties containing round tables for everyone to meet each other |
|divide-and-conquer| |
Those state diagrams can be constructed inductively, so it seems. Their structure is (in another context) known as [De Bruijn graph][1].
I sincerely hope you are not actually forced to draw some thousand states though.
Picture below is part of a diagram from the wikipedia page mentioned above (David Eppstein, pub... |
The word you are looking for is **pseudocode.** :) There is no official standard, but as you have observed, there are general conventions that most people follow. Partly this is dictated by popular LaTeX packages (see, for example, [this guide](https://www.overleaf.com/learn/latex/Algorithms)).
It's worth noting tha... |
|algorithms|pseudocode| |
null |
As D.W.'s answer points out, there are a few places where the "proof" in the question is not satisfactory. It is not that straightforward to "justify that stopping at an earlier station does not decrease the minimum number of stops" rigorously, even though it might look obvious.
------
A clearer and easier approa... |
It is easy to prove that you need at least $2^{10}$ states. Suppose you need fewer states. Then after feeding $2^{10}$ different sequences of length ten, there exist two sequences ending in the same state. But these two sequences differ at some point, so if you feed the same further symbols to the two sequences, the st... |
Wikipedia states that the time complexity of the [General Number Field Sieve (GNFS)][1] is
$$\exp\left( \left(\sqrt[3]{\frac{64}{9}} + o(1)\right)(\log N)^{\frac{1}{3}}(\log \log N)^{\frac{2}{3}}\right),$$
where $N$ is the number to be factored.
The same site also mentions that [quasi-polynomial time][2] is
$$\mb... |
Is GNFS quasi-polynomial-time? |
32bits might be a stretch for Manchester Magnitude Comparator chain, but a repeater or three might get you there.
At each slice, let A vs B select 00 EQ, 01 LT, 10 GT, 11 EQ. Let output EQn+1 propagate to the next slice's pair of EQ inputs.
Setup a magnitude comparison < = > using controls LT EQo GT. Or use EQ as... |
32bits might be a stretch for Manchester Magnitude Comparator chain, but a repeater or three might get you there.
At each slice, let A vs B select 00 EQ, 01 LT, 10 GT, 11 EQ. Let output EQn+1 propagate to the next slice's pair of EQ inputs.
Setup a magnitude comparison < = > using controls LT EQo GT. Or use EQ as... |
32bits might be a stretch for Manchester Magnitude Comparator chain, but a repeater or three might get you there.
At each slice, let A vs B select 00 EQ, 01 LT, 10 GT, 11 EQ. Let output EQn+1 propagate to the next slice's pair of EQ inputs.
Setup any magnitude comparison < = > using controls LT EQo GT. Or use EQ ... |
32bits might be a stretch for Manchester Magnitude Comparator chain, but a repeater or three might get you there.
At each slice, let A vs B select 00 EQ, 01 LT, 10 GT, 11 EQ. Let output EQn+1 propagate to the next slice's pair of EQ inputs.
Setup any magnitude comparison < = > using controls LT EQo GT. Or use EQ ... |
null |
32bits might be a stretch for Manchester Magnitude Comparator chain, but a repeater or three won't add much delay.
At each slice, let A vs B select 00 EQ, 01 LT, 10 GT, 11 EQ. Let output EQn+1 propagate to the next slice's pair of EQ inputs.
Setup any magnitude comparison < = > using controls LT EQo GT. Or use EQ... |
32bits might be a stretch for Manchester Magnitude Comparator chain, but a repeater or three won't add much delay.
At each slice, let A vs B select 00 EQ, 01 LT, 10 GT, 11 EQ. Let output EQn+1 propagate to the next slice's pair of EQ inputs.
Setup any magnitude comparison < = > using controls LT EQo GT. Or use EQ... |
32bits might be a stretch for Manchester Magnitude Comparator chain, but a repeater or three won't add much delay.
At each slice, let A vs B select 00 EQ, 01 LT, 10 GT, 11 EQ. Let output EQn+1 propagate to the next slice's pair of EQ inputs.
Setup any magnitude comparison < = > using controls LT EQo GT. Or use EQ... |
null |
null |
Category theory is an abstract branch of mathematics and you do not need to learn it before you start writing Haskell code. Similarly, you do not need to learn Haskell before you start learning category theory.
Haskell has a beautiful relationship with category theory. For example, consider polymorphic functions. Wh... |
null |
The problem is computing the array $C$ defined as $C_i = \max_{j+k=i} (A_j + B_k)$ given arrays $A$ and $B$. It is called the *max-plus convolution*, or *MaxConv* problem. Note that the equivalent *min-plus convolution* problem is also used in literature.
There is a sub-quadratic time reduction from the 3SUM problem... |
No. There is no universal standard. There are some conventions that have become more popular over time, through gradual evolution.
A good starting place to look would be to look at the [pseudocode](https://en.wikipedia.org/wiki/Pseudocode) notation used in a few common algorithms textbooks, pick one you like, and ... |
**More rigorously:**
First not that the recurrence only involves terms that are two units apart, so there will be a solution for the even $n$ and an independent one for the odd.
Let first $n:=2m$. We have
$$T(2m)=3T(2m-2)=3^2T(2m-2\cdot2)=\cdots3^mT(0)$$
or
$$T(n)=(\sqrt3)^nT(0).$$ And similarly for odd ... |
Suppose $n=2^k$.
Each person should get to know $2^k-1-1=2^k-2$ unknown people. At each party, each person get to know at most two unknown people. Hence, each person must join at least $\frac{2^k-2}2=2^{k-1}-1$ parties. So there must be at least that many parties.
------
The question is then whether that many... |
**More rigorously:**
First note that the recurrence only involves terms that are two units apart, so there will be a solution for the even $n$ and an independent one for the odd.
Let first $n:=2m$. We have
$$T(2m)=3T(2m-2)=3^2T(2m-2\cdot2)=\cdots3^mT(0)$$
or
$$T(n)=3^{n/2}T(0)=(3^{1/2})^nT(0)=\sqrt3^nT(0... |
**More rigorously:**
First note that the recurrence only involves terms that are two units apart, so there will be a solution for the even $n$ and an independent one for the odd.
Let first $n:=2m$. We have
$$T(2m)=3T(2m-2)=3^2T(2m-2\cdot2)=\cdots3^mT(0)$$
or
$$T(n)=3^{n/2}T(0)=(3^{1/2})^nT(0)=\sqrt3^nT(0... |
Given the following code:
void aux(int n){
while (n > 0) {
printf("%d", n);
n--;
}
}
long f1(int n)
{
long sum = 0;
for (int i = 1; i * i <= n; i++) {
for (int j = 1; j <= i; j++) {
aux(i * j);
sum += i * j;
}
... |
Help with time complexity of a given code |
|time-complexity|c| |
Let $n=m^2$.
$$
\sum_{j=1}^1 j + 2\sum_{j=1}^2j + 3\sum_{j=1}^3 j +...+ m \sum_{j=1}^{m} j
\\=1 + 2\cdot3 + 3\cdot6 +...+ m \frac{m(m+1)}2\\\sim\frac{m^4}8=\Theta(m^4)
$$
by Faulhaber. |
It is easy to prove that you need at least $2^{10}$ states. Suppose you need fewer states. Then after feeding $2^{10}$ different sequences of length ten, there exist two sequences ending in the same state. But these two sequences differ at some point, so if you feed the same further symbols (possibly none) to the two s... |
Let $n=m^2$.
$$
\sum_{j=1}^1 j + 2\sum_{j=1}^2j + 3\sum_{j=1}^3 j +...+ m \sum_{j=1}^{m} j
\\=1 + 2\cdot3 + 3\cdot6 +...+ m \frac{m(m+1)}2\\\sim\frac{m^4}8=\Theta(m^4)=\Theta(n^2)
$$
by Faulhaber. |
null |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.