instruction stringlengths 0 29.8k ⌀ |
|---|
Show that P and NP are closed under Kleene star. I found possible solutions to these problems, more specifically:
1) P - finding all subwords from a giving word and looking if there is a connection between them (idea: https://louis.jachiet.com/lfcc/final_solutions.pdf)
2) NP - non-deterministically dividing word for ... |
Why does "NP is closed under Kleene star" proof reject correct word? |
null |
I have found that a problem that I'm analyzing is equivalent to the following variant of the Exact Cover problem:
> `Partition into $k$ Exact Covers`
>
> **Input**: A universe $U$ and a family $C\subseteq 2^U$ of subsets of $U$ in which each element $x\in U$ occurs in exactly $k$ subsets of $C$.
>
> **Question**... |
Exact Cover variant: partition a family of subsets into exact coverings |
|np-complete|np-hard|np|set-cover| |
Strictly speaking, a *mantissa* is part of a logarithm (specifically a common logarithm). For example, the common (base-10) logarithm of 1234 is 3.09132. From that number 3.09132 we can immediately see that we're dealing with a number between 10<sup>3</sup> = 1000 and 10<sup>4</sup> = 10000. And then the .09132 part... |
Strictly speaking, a *mantissa* is part of a logarithm (specifically a common logarithm). For example, the common (base-10) logarithm of 1234 is 3.09132. From that number 3.09132 we can immediately see that we're dealing with a number between 10<sup>3</sup> = 1000 and 10<sup>4</sup> = 10000. And then the .09132 part... |
I am trying to solve
T(n) = 4*T(n/4) + n*[log(n)]^2
I decided to use Master Theorem so I found a,b=4 and logb(a)=1.
I thought that 3rd case is the solution but I don't know actually how to solve this.
Any help appreciated.
Thanks in advance !
|
Solve Recurrence T(n) = 4T(n/4) + n*[log(n)]^2 |
|asymptotics|recurrence-relation|master-theorem| |
**Tasks:**
Input: $DFA$ $M = (Z, Σ, δ, S, E)$
T(M) := Language that M accepts.
Question: Does T(M) accept at least one word w such that $|w| = 2^n?$
**My attempt:**
Since the language $\{w\in Σ^* | |w| = 2^n \} $is not regular. You cannot create $DFA$ $M'$ which accepts this language and use it somehow.... |
Decide whether regular language contains a word w for which |w| = 2^n |
|regular-languages|decision-problem| |
Decide whether regular language contains a word w for which $|w| = 2^n$ |
**Task:**
Input: $DFA$ $M = (Z, Σ, δ, S, E)$
T(M) := Language that M accepts.
Question: Does T(M) accept at least one word w such that $|w| = 2^n?$
**My attempt:**
Since the language $\{w\in Σ^* | |w| = 2^n \} $is not regular. You cannot create $DFA$ $M'$ which accepts this language and use it somehow.
... |
Assuming we have a DAG, $G = (V, E)$, and we know that we can calculate $G$'s transitive closure in time complexity of $f(|V|, |E|)$, whereas $f$ is monotonic increasing function.\
Show that given a directed graph (not necessarily DAG) $G^{'}$, we can calculate it's transitive closure, $G^{+}=(V, E^{+})$, in time comp... |
Transitive Closure of a graph |
|graphs|dag| |
Using [Kosaraju's algorithm](https://en.wikipedia.org/wiki/Kosaraju%27s_algorithm), you can compute the strongly connected components (SCC) of $G$ in linear time.
The metagraph (or graph of the SCC) is well known to be a DAG. You can then compute the transitive closure of the metagraph.
Now to compute $G^+$:
... |
**Task:**
Input: $DFA$ $M = (Z, Σ, δ, S, E)$
T(M) := Language that M accepts.
Question: Does T(M) accept at least one word w such that $|w| = n^2$ with $n \in \mathbb{N}$$ ?$
**My attempt:**
Since the language $\{w\in Σ^* | |w| = n^2 \} $is not regular. You cannot create $DFA$ $M'$ which accepts this la... |
Given a list of positive integers with sum $s$, decide if there is a subset with sum $0.5s$. This is the well-known [PARTITION problem][1], which is NP-hard.
What about the following: Given a list of positive integers with sum $s$, decide if there is a subset with sum in the range $[0.49s, 0.51s]$. Can this problem ... |
Almost partition problem |
|algorithms|complexity-theory|partitions| |
**Task:**
Input: $DFA$ $M = (Z, Σ, δ, S, E)$
T(M) := Language that M accepts.
Question: Does T(M) contain at least one word $w$ such that $|w| = n^2$ with $n \in \mathbb{N}$$ ?$
**My attempt:**
Since the language $\{w\in Σ^* | |w| = n^2 \} $is not regular. You cannot create $DFA$ $M'$ which accepts thi... |
Decide whether regular language contains a word $w$ for which $|w| = n^2$ |
**Task:**
Input: $DFA$ $M = (Z, Σ, δ, q_S, E)$
T(M) := Language that M accepts.
Question: Does T(M) contain at least one word $w$ such that $|w| = n^2$ with $n \in \mathbb{N}$$ ?$
**My attempt:**
Since the language $\{w\in Σ^* | |w| = n^2 \} $is not regular. You cannot create $DFA$ $M'$ which accepts t... |
**Task:**
Input: $DFA$ $M = (Z, Σ, δ, q_S, E)$
T(M) := Language that M accepts.
Question: Does T(M) contain at least one word $w$ such that $|w| = n^2$ with $n \in \mathbb{N}$$ ?$
**My attempt:**
Since the language $\{w\in Σ^* | |w| = n^2 \} $is not regular. You cannot create $DFA$ $M'$ which accepts t... |
**Task:**
Input: $DFA$ $M = (Z, Σ, δ, q_S, E)$
T(M) := Language that M accepts.
Question: Does T(M) contain at least one word $w$ such that $|w| = n^2$ with $n \in \mathbb{N}$$ ?$
**My attempt:**
Since the language $\{w\in Σ^* | |w| = n^2 \} $is not regular. You cannot create $DFA$ $M'$ which accepts t... |
**Task:**
Input: DFA $M = (Z, Σ, δ, q_S, E)$
$T(M)$ := Language that $M$ accepts.
Question: Does $T(M)$ contain at least one word $w$ such that $|w| = n^2$ with $n \in \mathbb{N}$$ ?$
**My attempt:**
Since the language $\{w\in Σ^* \mid |w| = n^2 \} $is not regular. You cannot create DFA $M'$ which acce... |
Following the numbering of cases as per this [wikipedia article][1], we see that our recurrence follows the second case and hence,
$$ T(n) = \Theta\left( n \log^3n \right) $$
[1]: https://en.wikipedia.org/wiki/Master_theorem_(analysis_of_algorithms) |
The halting of one TM can be encoded by constructing another TM and asking whether it halts. That is, given TM $T_1$ and input $I_0$, we can construct a TM $T_2$ with inputs indexed by the natural numbers such that $T_2(I_n)$ halts if $T_1(I_0)$ doesn't halt after $n$ steps. Then there are inputs on which $T_2$ doesn't... |
Is there any cellular automaton on the Eisenstein integers? By this I mean that the triangles formed by the Eisenstein integers are considered as cells and each triangle has three neighbours plus itself. I programmed in python such a cellular automaton and am curious what properties it has.
Video: https://www.youtub... |
Cellular automata on the Eisenstein integers? |
|reference-request|cellular-automata| |
Convert $M$ to an NFA over $\Sigma = \{a\}$ by renaming all labels on edges to $a$. The language accepted by the NFA has the same word lengths as $T(M)$. Convert the NFA to a DFA. After removing unreachable states, the DFA is a path leading to a cycle. This implies that the set of length of words in $T(M)$ is eventuall... |
null |
null |
null |
|programming-languages|functional-programming|category-theory|haskell| |
null |
{"OriginalQuestionIds":[80563],"Voters":[{"Id":755,"DisplayName":"D.W."}]} |
null |
A quick solution for JavaScript where the variable ```source``` holds the source code.
```
const regex = /(\/\/.*?(\r?\n|\r|$)|\/\*.*?\*\/)/g;
console.log(source.replaceAll(regex, ''));
``` |
{"Voters":[{"Id":53301,"DisplayName":"clinux"}]} |
null |
{"Voters":[{"Id":53301,"DisplayName":"clinux"}]} |
You should be able to achieve it with a finite state machine / hand rolled lexer. But I will through in a quick and easy overkill solution. There is a project called "jison" which is like Bison, but for JavaScript (https://github.com/zaach/jison). It is a parser generator.
Here is a grammar you can use to strip comm... |
Is there a notation for statements like the following:
> If both operands are of type `int`, then the result is of type `int`. If either operand is of type `float`, then the result is of type `float`.
e.g. for the first case, can I say something like:
$$int \ \text{op} \ int \rightarrow int$$
where $\text{op}... |
Is there a notation for types? |
|terminology|notation|types| |
You should be able to achieve it with a finite state machine / hand rolled lexer. But I will through in a quick and easy overkill solution. There is a project called "jison" which is like Bison, but for JavaScript (https://github.com/zaach/jison). It is a parser generator.
Here is a grammar you can use to strip comm... |
You should be able to achieve it with a finite state machine, hand rolled lexer or even a regular expression (rather long regular expression). But I will through in a quick and easy overkill solution. There is a project called "jison" which is like Bison, but for JavaScript (https://github.com/zaach/jison). It is a par... |
I have implemented an indexed linked list that runs (under mild assumptions) all single-element operations in $\mathcal{O}(\sqrt{n})$ time. The description is [here](https://coderodde.github.io/weblog/#meill) and Java implementation is [here](https://github.com/coderodde/IndexedLinkedList/blob/main/src/main/java/com/gi... |
You should be able to achieve it with a finite state machine, hand rolled lexer or even a regular expression (rather long regular expression). But I will throw in a quick and easy overkill solution. There is a project called "jison" which is like Bison, but for JavaScript (https://github.com/zaach/jison). It is a parse... |
You should be able to achieve it with a finite state machine, hand rolled lexer or even a regular expression (rather long regular expression). But I will throw in a quick and easy overkill solution. There is a project called "jison" which is like Bison, but for JavaScript (https://github.com/zaach/jison). It is a parse... |
Can almost equal partition problem be solved in polynomial time? |
|algorithms|complexity-theory|time-complexity|partitions| |
>Let $C$ be a regular language. Prove that the language $D = \{x x^R : x\in C\}$ is context-free.
It's clearly important that $C$ is regular; if the hypothesis were weakened to C being context-free, then we would have the counterexample $C = \{0^n 1^n : n\ge 0\}, D = \{0^n 1^{2n} 0^n:n\ge0\},$ which isn't context-fr... |
Prove that if C is a regular language, then the language $\{x x^R : x\in C\}$ is context-free |
$\{xx^r\mid x\in L_1, x^r\in L_2\}$ is context-free if $L_1$ and $L_2$ are regular languages |
I have this problem:
> Let $L_1$ and $L_2$ be two regular languages. Show that $L_3 = \{xx^r : x \in L_1, x^r \in L_2 \}$ is a context-free language.
I am unsure how to prove that some language is context-free. Could someone please provide the steps? |
You should be able to achieve it with a finite state machine, hand rolled lexer or even a regular expression (rather long regular expression). But I will throw in a quick and easy overkill solution. There is a project called "jison" which is like Bison, but for JavaScript (https://github.com/zaach/jison). It is a parse... |
null |
One approach is to use union types: https://stackoverflow.com/q/5653678/781723.
Haskell type classes can be used to support this, but with some significant restrictions: https://www.schoolofhaskell.com/school/starting-with-haskell/introduction-to-haskell/5-type-classes. |
You can write a new union type as
$$ \mathrm{type} \; number = int \; | \; float $$
Then, you can write down your function
$$ addition : number \rightarrow number \rightarrow number $$ |
In looking at
`int op int→int`
my focus is immediately drawn to `→`.
If you have ever studied [Lambda Calculus][1] and how it forms the foundation of many functional programming languages then you will come to understand `→` which should not be confused with `→ᵦ` or `→ₐ` . Since searching for `→` is not easy... |
**Problem**:
In this problem, we discuss Data-Structures that maintain a group of ordered elements.
We must support the operations $ DecreaseKey, FindMin, Insert $ in time $ O(1) $ and the operation $ DeleteMin $ in time $ O(\log n) $. All the time-complexities are Amortized.
We'll remind that so far, Fibonac... |
Priority Queues with $DecreaseKey,FindMin,Insert$ in time $O(1)$, $DeleteMin$ in $ O(\log n)$ and $IncreaseKey$ in $O(1)$, Amortized |
|amortized-analysis|priority-queues| |
The latest development in solving the [max-flow problem][1] promises a ${\displaystyle O(E^{1+o(1)}\log U)}$ solution.
What does it mean, this $O(n^{1+o(1)})$-complexity?
[1]: https://en.wikipedia.org/wiki/Maximum_flow_problem#Algorithms |
What does O( n^{1+o(1)} ) mean |
|time-complexity|complexity-classes| |
A function $f(n)$ is $O(n^{1+o(1)})$ if there exist a constant $C > 0$ and a function $g(n)$ satisfying $\lim_{n\to\infty} g(n) = 0$ such that
$$ f(n) \leq Cn^{1+g(n)}. $$ |
We say that if an algorithm takes p time for an input size of n (here, p is a polynomial in n, and the degree of p is y), then the algorithm's complexity is O(n^y).
In the image, when n is very large it does not seem to matter much if it's x^2 or 2x^2. but, it clearly seems to matter if it's x or 2x. So, then why d... |
algorithm with linear time complexity |
|time-complexity| |
Is there any cellular automaton on the Eisenstein integers? By this I mean that the triangles formed by the Eisenstein integers are considered as cells and each triangle has three neighbours plus itself. I programmed in python such a cellular automaton and am curious what properties it has.
git: https://gist.github.... |
Yes, such cellular automata have been studied. However, you're unlikely to find much about them using terms like "Eisenstein integers", since the convention in the field is to describe cellular automata on regular lattice using the lattice symmetry (e.g. hexagonal / rectangular / triangular for 2D lattices) and the [n... |
**Problem**:
In this problem, we discuss Data-Structures that maintain a group of ordered elements.
We must support the operations $ DecreaseKey, FindMin, Insert $ in time $ O(1) $ and the operation $ DeleteMin $ in time $ O(\log n) $. All the time-complexities are Amortized.
We'll remind that so far, Fibonac... |
One approach is to use union/intersection types: https://stackoverflow.com/q/5653678/781723.
Haskell type classes can be used to support this, but with some significant restrictions: https://www.schoolofhaskell.com/school/starting-with-haskell/introduction-to-haskell/5-type-classes. |
{"Voters":[{"Id":755,"DisplayName":"D.W."}],"SiteSpecificCloseReasonIds":[]} |
I have a straightforward task that can be done in $O(n^2)$ time. I'm now wondering if the task can be done in time $O(n^{2-\epsilon})$ if we are allowed to do some pre-processing.
The problem exists of two steps. In the first (preprocessing) step, we are given an $n \times n$ array $A_{i,j}$: $n$ permutations of the... |
removing an item from n lists in $O(n^{1-\epsilon})$ amortized time |
|data-structures|polynomial-time|permutations| |
**Problem**:
In this problem, we discuss Data-Structures that maintain a group of ordered elements.
We must support the operations $ DecreaseKey, FindMin, Insert $ in time $ O(1) $ and the operation $ DeleteMin $ in time $ O(\log n) $. All the time-complexities are Amortized.
We'll remind that so far, Fibonac... |
The correct term is *Prefix Sum*. See e.g. https://en.wikipedia.org/wiki/Prefix_sum |
>Prove that the following language is context-free by giving a context-free grammar that generates the language: $A = \{a \in \{0,1\}^* : \text{ no character in an even position is a 0 or no character in an odd position is a 1}\}$, where the first position is position 1. For instance, $01110, 01010$ are both in $A.$
... |
prove $A$ is context-free |
|formal-languages|automata|finite-automata|context-free| |
I was looking for implementations of counting sort and in most of them cumulative counts are calculated and used like this:
```
public void SortArray1(int[] nums)
{
var output = new int[nums.Length];
var count = new int[nums.Max() + 1];
foreach (var num in nums)
count[... |
Compare solutions of counting sort |
|sorting| |
I was looking for implementations of counting sort and most of them are implemented with cumulative counts like this:
```
public void SortArray1(int[] nums)
{
var output = new int[nums.Length];
var count = new int[nums.Max() + 1];
foreach (var num in nums)
count[num]++... |
This language is regular and this is an NFA that describes it:
[![Image][1]][1]
Please notice that the language has nothing to do with "counting" and it doesn't need any memory so you can simply realize it's regular, CFL uses the stack for memory purposes but here it's all about determining the place of a charact... |
As n grows, o(1) eventually becomes less than 1, then less than 1/2, then less than 1/3 and so on.
So as n gets large, f(n) will be O(n ^ 3/2), O(n ^ 4/3) and so on. The factor between n and f(n) can become larger and larger, but the increase will become less. |
{"Voters":[{"Id":112114,"DisplayName":"Fred Jefferson"}]} |
{"Voters":[{"Id":112114,"DisplayName":"Fred Jefferson"}]} |
>Prove that the following language is context-free by giving a context-free grammar that generates the language: $A = \{a \in \{0,1\}^* : \text{ no character in an even position is a 0 or no character in an odd position is a 1}\}$, where the first position is position 1. For instance, $01110, 01010$ are both in $A.$
... |
null |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.