instruction stringlengths 0 29.8k ⌀ |
|---|
null |
I want to give you some intuition why your language isn't CFL. We know that every CFL there exist atleast one PDA. If PDA doesn't exist that means languages definitely not CFL. So I give you intuitive proof with respect to PDA design, whether the design of PDA is possible or not:
$L_1 = \{ a^i b^j c^k | k ≥ min(i,j)... |
I frequently have to calculate this kind of function
[![enter image description here][1]][1]
Those functions have constant values on arbitrary (predefined) intervals
I wonder if there is an algorithm for fast calculation of it, so I can learn about, and implement.
My solution is to store the intervals in an... |
There is a name and/or algorithm for calculating functions which are constant on different intervals? |
|algorithms|efficiency| |
There is a problem-name and/or algorithm for calculating functions which are constant on different intervals? |
Checking if a proof is error-free can be done in linear time.
If the proof is a formal, it could be done with a computer.
Checking if a program has no bugs is Turing-hard. So it is
undecidable. |
null |
null |
$O(\log n)$ is very fast. I think it is unlikely that you will find a faster algorithm to compute such a function.
Wavelets, polynomials, data compression, and enumerating combinations/permutations do not seem relevant.
Such a function is called piecewise constant. |
as the title says:
is there a TM $T(m;n)=q$ where $\forall n \forall m \exists q\space T_q(0)=T_m(n)$?
in another words we are looking for a TM $T(m;n)$ that given a TM number $m$ and input of that TM $n$ tries to find a TM number $q$ "$T_q(0)$" that is equivalent to TM number $m$ with input $n$ "$T_m(n)$"
it ... |
> If this is wrong, can we always write a program whose CFG is planar without loss of function?
Yes, we can.
Suppose we have an arbitrary CFG $G$, which is a finite graph.
> It is known that any finite graph can be embedded into a three-dimensional space. - Wikipedia
Let's say for our CFG, we have a 3D e... |
let A=(b* a)+ ,B=(b* a) and C=(b* a)*
we have to show that whether A.B=C
here . indicates the concatenation of strings
'+' is known as Kleene plus which means all kinds of non empty strings are accepted
A.B==>{(b*a),(b*a)(b*a),(b*a)(b*a)(b*a)…………}.(b*a)
==>{(b*a)(b*a),(b*a)(b*a)(b*a),(b*a)(b*a)(b*a)(b*... |
Here's my problem: I have $N$ sets of integers $S_{i \in [1,N]} = \{1, ..., n_i\}$ each with non-uniform weights $W_i = \{w_{i,1}, ..., w_{i,n_i}\}$ such that $\sum_{j}{w_{i,j}} = 1$. I want to sample $m$ unique sets $P_{k \in [1,m]}$ of $N$ integers, with each set element taken from the different sets $S_i$. There are... |
Sample a set of N numbers without replacement, each element taken from N different weighted sets |
|algorithms|combinatorics|probability-theory|sampling| |
As a computer science student I suggest to have a look on theory of computation
because the concepts in theory of computation have useful and vital applications used by general purpose languages and this theory has useful and easy solving problems through which Logical building, analytical thinking will be improved ... |
You are looking for the [zipper](https://en.wikipedia.org/wiki/Zipper_(data_structure)) data structure. |
I have to show that given $f:\mathbb{N}\rightarrow\mathbb{N}$ the function that returns the number of times $6$ appears in the input (for example $f(436546)=2$) is primitive recursive.
The exercise says to assume that the functions $rem(m,n)$ and $div(m,n)$, which returns the remainder and the quotient, are recursive ... |
Show that the function that counts the number of occurrences of 6 in a natural number is recursive primitive |
null |
A rhetorical question to keep in mind: would anyone take you seriously if you said ZFC is "not Turing complete" and therefore insufficient to express the algorithms that we write in mainstream programming languages?
First, what is the usual argument about total languages? The reasoning is as follows:
1. In a total ... |
null |
There was a presentation on ICSE 2011, at the New Ideas and Emerging Results track, entitled ["How do programmers ask and answer questions on the web?"][1]. They only had initial results, but they sounded very interesting and promising. Maybe you could contact the authors if you need more info (they're from the Dept. o... |
null |
For all integers $n$, if $n \geq 16$ then
$$
\begin{align*}
\log(n!) \; & = \; \log(1)\hspace{.04 in}+\hspace{.04 in}...+\log(n) \\ & \geq 0\hspace{.04 in}+\hspace{.04 in}...+\hspace{.04 in}0+\log(\lfloor n\hspace{.02 in}/\hspace{.02 in}2\rfloor)\hspace{.04 in}+\hspace{.04 in}...+\log(n) \; \\
& = \; 0+\log(\lflo... |
null |
null |
There are 8 (very similiar) languages I'd like to discuss here:
- CNF SAT
- DNF SAT
- CNF No-SAT (Existence of a false assignment)
- DNF No-SAT
- CNF Tautology
- DNF Tautology
- CNF Contradiction
- DNF Contradiction
While CNF SAT is known to be $NPC$, my claim is that some of these languages are ac... |
Can these variants of SAT/Tautology be actually pretty simple? |
|complexity-theory|np-complete|satisfiability|co-np| |
I need to compute the cheapest path between to pixels in an image. The travel cost is specified by the user, and may depend on the distance between the pixels (including pixel values, which is treated as an elevation), as well as other factors. I tried Dijktra, by scaling coordinates by a factor so I can have more sear... |
Algorithm to compute cheapest path between two pixels in an image |
|optimization|shortest-path| |
null |
I have written a regex engine and it can match whole strings to a pattern without a problem, i.e.:
```match(E, w)```
and it returns ```true``` or ```false``` if the string $w$ matches the expression $E$ or not. But I was thinking of how to extend the matching function to find substrings in a string that match an expr... |
regex find substring matches in text |
|regular-expressions| |
That sounds like a variant of grid pathfinding(mostly used in game).
Generally, if your cost function has a good heuristics, [A star](https://en.wikipedia.org/wiki/A*_search_algorithm) will give you an optimal solution with least time cost. But space waste is serious, so you can try [Fringe Search](https://en.wikip... |
I need to compute the cheapest path between two pixels in an image. The travel cost is specified by the user, and may depend on the distance between the pixels (including pixel values, which is treated as an elevation), as well as other factors. I tried Dijkstra, by scaling coordinates by a factor so I can have more se... |
One approach is to match against the regexp `.* E .*`, then figure out how it matches. Whether you can figure out how that matched depends on the algorithm you are using to implement `match`. This will look for one substring that matches, not all of them. |
null |
I have a set of positive integer numbers $A = \{a_1,...,a_N\}$ and I need to find a partition of $A$ into two sets, such that the sum of their products is minimal, i.e.,
$$
\min_{X,Y : X \cup Y = A} \prod_{x \in X} x + \prod_{y \in Y} y.
$$
Is there any good approximation/heuristic algorithm to solve this problem... |
Minimize sum of products of partition |
|optimization|dynamic-programming|np-hard|partitions| |
null |
{"Voters":[{"Id":755,"DisplayName":"D.W."}],"SiteSpecificCloseReasonIds":[]} |
null |
Similar to one of the questions that was posted here roughly 4 years ago. Lets say we have two wooden planks each 1m long. And we want to have 4 pieces, 60cm 50cm 30cm and 20cm **in that order**. What kind of buttom-up implementation can be done to calculate the least waste
Formally we have N wooden planks each $L... |
Find The Least Waste When Sawing Wood Planks In A Specific Order |
|algorithms|optimization|dynamic-programming| |
Similar to one of the questions that was posted here roughly 4 years ago. Lets say we have two wooden planks each 1m long. And we want to have 4 pieces, 60cm 50cm 30cm and 20cm. What kind of bottom-up implementation can be done to calculate the least waste
Formally we have N wooden planks each $L_1$,…,$L_N$ cm lon... |
Similar to one of the questions that was posted here roughly 4 years ago. Lets say we have two wooden planks each 1m long. And we want to have 4 pieces, 60cm 50cm 30cm and 20cm. What kind of bottom-up implementation can be done to calculate the least waste
Formally we have N wooden planks each $L_1$,…,$L_N$ cm lon... |
If you look at the indices of nodes in a binary heap, left child index is always an odd number, and right is always even.
e.g.
```
# I made the values match the indices for simplicity
[0,1,2,3,4,5,6]
0
/ \
1 2
/ \ / \
3 4 5 6
```
For parent `1`, left is index `3` and right is index `4` (odd a... |
There are 8 (very similiar) languages I'd like to discuss here:
- CNF SAT
- DNF SAT
- CNF No-SAT (Existence of a false assignment)
- DNF No-SAT
- CNF Tautology
- DNF Tautology
- CNF Contradiction
- DNF Contradiction
While CNF SAT is known to be $NPC$, my claim is that some of these languages are ac... |
I'm trying to use the Pumping Lemma to prove that $L = { wsw | w ∈ {0,1}*, s ∈ {2}*, and |w| = 2 * |s| }$ is not a CFL. |
How to use Pumping Lemma $L = { wsw | w ∈ {0,1}*, s ∈ {2}*, and |w| = 2 * |s| }$? |
|turing-machines|regular-languages|context-free|proof-techniques|pumping-lemma| |
Here's my problem: I have $N$ sets of integers $S_{i \in [1,N]} = \{1, ..., n_i\}$ each with non-uniform weights $W_i = \{w_{i,1}, ..., w_{i,n_i}\}$ such that $\sum_{j}{w_{i,j}} = 1$. I want to sample $m$ unique sets $P_{k \in [1,m]} = \{p_{k,1}, ...,p_{k,i}, ...,p_{k,N}\}$ of $N$ integers, with each element $p_{k,i} \... |
null |
null |
The language $\textrm{prefix}(L) = \{0^n1^m:n \geq m\}$. It's not regular.
From the [pumping lemma][1]:
> Let $L$ be a regular language. Then there exists an integer $p \geq 1$ depending only on $L$, such that every string $w \in L$, of length at least $|w| \geq p$ ( $p$ is called the "pumping length") can be wri... |
null |
**An $\epsilon$-tester** given an input and a property, is defined as follows:
If the input holds the property then the tester should accept with probability at least $ \frac 2 3$. Otherwise if the input is more than $\epsilon$ far from holding the property then the tester should reject with probability at least $\fra... |
|algorithms|algorithm-analysis|lower-bounds|probabilistic-algorithms|property-testing| |
null |
Here's my problem: I have $N$ sets of integers $S_{i \in [1,N]} = \{1, ..., n_i\}$ each with non-uniform weights $W_i = \{w_{i,1}, ..., w_{i,n_i}\}$ such that $\sum_{j}{w_{i,j}} = 1$. I want to sample $m$ unique sets $P_{k \in [1,m]} = \{p_{k,1}, ...,p_{k,i}, ...,p_{k,N}\}$ of $N$ integers, with each element $p_{k,i} \... |
null |
|terminology|trees|functional-programming|tree-traversal| |
Arrays are generally presented as data structures with Θ(N) traversal and Θ(1) random element access. However, this seems inconsistent:
- if array access is really O(1), this means that the size of an element index is bounded (e.g., int64), since it can be processed in O(1). However, this implies that the array size... |
sArray access is O(1) implies a fixed index size, which implies O(1) array traversal? |
null |
Arrays are generally presented as data structures with $\Theta(N)$ traversal and $\Theta(1)$ random element access. However, this seems inconsistent:
- if array access is really $\Theta(1)$, this means that the size of an element index is bounded by a constant (e.g., int64), since it can be processed in $\Theta(1)$.... |
Array access is O(1) implies a fixed index size, which implies O(1) array traversal? |
|complexity-theory|terminology|arrays|computation-models| |
A computer is a large *synchronous logical system*, which means that
- it manipulates $0/1$ information in the form of electric signals using the rules of Boolean calculus,
- it operates with a (very fast) clock so that all signals are sampled at discrete moments to ensure coherence.
The $0/1$ information is re... |
First of all - the example doesn't seem well suited because you would probably use some regression or classical ML methods to solve this. Secondly - you are referring to a general problem of *feature selection* [(Kira, Rendell, 1992)][1] or *attribute selection* [(Hall, Holmes, 2003)][2] or *variable selection* [(Guyon... |
null |
First of all - the example doesn't seem well suited because you would probably use some regression or classical ML methods to solve this. Secondly - you are referring to a general problem of *feature selection* [(Kira, Rendell, 1992)][1] or *attribute selection* [(Hall, Holmes, 2003)][2] or *variable selection* [(Guyon... |
**An $\epsilon$-tester** given an input and a property, is defined as follows:
If the input holds the property then the tester should accept with probability at least $\frac 2 3$. Otherwise if the input is more than $\epsilon$ far from holding the property then the tester should reject with probability at least $\fr... |
The existing answer is good, but doesn't tackle the empty and full languages and also leaves some doubts unspecified. I'll solve the full question.
---
First, let's be clear about our definitions: $L_1 \leq_p L_2$ when there is a *polynomial-time mapping reduction* from $L_1$ to $L_2$. That is, there is a functio... |
The existing answer is good, but doesn't tackle the empty and full languages and also leaves some doubts unspecified. I'll solve the full question.
---
First, let's be clear about our definitions: $L_1 \leq_p L_2$ when there is a *polynomial-time mapping reduction* from $L_1$ to $L_2$. That is, there is a functio... |
null |
null |
[![pic 1][1]][1]
Why there is a sigma in the denominator of equation (8)? suppose we have n tasks and m fog nodes.
[1]: https://i.stack.imgur.com/4eF3R.png |
A lower bound for the makespan of heterogenous fog nodes |
|optimization|combinatorics|distributed-systems|scheduling|modelling| |
[![Pic][1]][1]
Why there is a sigma in the denominator of equation (8) in the picture? suppose we have n tasks and m fog nodes.
[1]: https://i.stack.imgur.com/TqugL.png |
Under the assumption that $EXT(N_i) = \mathit{MinMakespan}$,
$$
\sum_{k \in N_i \mathit{Tasks}} \mathit{length}(T_k) = \mathit{MinMakespan} \times \mathit{CPUrate}(N_i).
$$
Therefore
$$
\sum_k \mathit{length}(T_k) = \sum_i \sum_{k \in N_i \mathit{Tasks}} \mathit{length}(T_k) = \sum_i \mathit{MinMakespan} \times \... |
Here's my problem: I have $N$ sets of integers $S_i$ where $|S_i| = n_i \forall i \in [1,N]$ each with non-uniform weights $W_i = \{w_{i,1}, ..., w_{i,n_i}\}$ such that $\sum_{j}{w_{i,j}} = 1$. I want to sample $m$ unique **lists** $P_{k \in [1,m]} = (p_{k,1}, ...,p_{k,i}, ...,p_{k,N})$ of $N$ integers (including dupli... |
null |
Let $L_1 \subseteq \{0,1\}^{*}$ be a regular language, and let $L_2 \subseteq \{0,1\}^{*}$ be some (not necessarily regular) language.
Show that
$$L=\left\{ \sigma_{1}\#\sigma_{2}\dots\#\sigma_{n}\mid\substack{n\geq1\\
\sigma_{i}\in\left\{ 0,1\right\} \\
\exists w_{1},\dots w_{n-1}\in L_{2}\quad\sigma_{1}w_{1}\sigm... |
Exotic closure of regular languages |
|regular-languages|closure-properties| |
It is definitely possible to make a bidirectional graph search algorithm with several possible destinations. Simply add all the destination nodes to the destination-search priority queue, all of them with weight 0. The backward search will start from all the destinations at once, instead of just starting from a single ... |
null |
null |
I've come across this problem when working on a personal project of mine. I need an efficient algorithm of counting the number of overlaps between all pair combinations of n sets.
Example:
Set a = [adam, ben, charlie, ...]
Set b = [adam, john, kenny, ...]
Set c = [adam, john, eve, ...]
...
Set n
T... |
Efficient algorithm to count number of intersections of n sets |
|algorithms|graphs|sets| |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.