instruction stringlengths 0 29.8k ⌀ |
|---|
|algorithms|algorithm-analysis|dynamic-programming|search-algorithms|greedy-algorithms| |
There is a number of questions on this website about the reversal of regular languages:
* https://cs.stackexchange.com/questions/54934/closure-under-reversal-of-regular-languages-proof-using-automata
* https://cs.stackexchange.com/questions/52037/proving-that-the-reversal-of-a-language-reversal-is-that-language
* ... |
What is the reversal of a regular language useful for? |
|regular-languages| |
Outside computing, a *procedure* is a way of doing things. It usually has specific steps in a specific order, possibly to be executed by different parties.
In computing, an *algorithm* is a way of performing a certain computational task. For instance, [quicksort][1] is an algorithm for inline sorting. In the case of... |
Outside computing, a *procedure* is a way of doing things. It usually has specific steps in a specific order, possibly to be executed by different parties.
In computing, an *algorithm* is a way of performing a certain computational task. For instance, [quicksort][1] is an algorithm for inline sorting. In the case of... |
null |
So I need to design an algorithm for the following problem:
Suppose we need to build an optical fibre network for 20 cities. We are given a distance matrix of the cities which tells us which cities are connected so that we can make a connection between them and a cost matrix which tells us how much each connection c... |
Designing Algorithm for MST problem for a optical fiber network bounded by costs |
|algorithms|graphs|minimum-spanning-tree|heuristics| |
for example:
```
foobar + bar -> foobar
foo + bar + rfo -> barfoo
```
I guess it's related to graphs, but don't know how to solve it.
1. first check all the "substrings", for example, "bar" to "foobar". Remove "bar".
2. the more two string share head and tail, the more likely they will be joined together, ... |
How to find a shortest string which all input strings is its substring |
null |
Only MergeSort has a guaranteed $O(n\log n)$ behavior.
You may well consider Natural MergeSort, that has the extra property of adaptiveness.
----------
If you only care about swapping links (?), I guess that both StraightSelection and StraightInsertion achieve an optimal (certainly in the worst case, $O(n)$). |
null |
Over the alphabet $\Sigma=\{0,\ldots,9,/\}$, is the following language regular:
$$L=\left\{x/y/z:z=\mathrm{str}\bigl(\mathrm{int}(x)+\mathrm{int}(y)\bigr)\right\}$$
where $\mathrm{str}$ maps an integer to its decimal representation, and $\mathrm{int}$ does the opposite thing.
It contains $0/0/0$, $10/34/44$, $... |
Is the language of sums of integers regular? |
|regular-languages| |
Disregarding the context of programming languages, a procedure is an unambiguous decomposition of a task in elementary operations, such that it can be performed mechanically. It is implicit that the "operator" knows how to perform the elementary operations.
E.g. the procedure to solve the Hanoi Towers problem is a s... |
Disregarding the context of programming languages, a procedure is an unambiguous decomposition of a task in elementary operations, such that it can be performed mechanically. It is implicit that the "operator" knows how to perform the elementary operations.
E.g. the procedure to solve the Hanoi Towers problem is a ... |
Can D simulated by H terminate normally?
The x86utm operating system based on an open source x86 emulator. This system enables one C function to execute another C function in debug step mode. When H simulates D it creates a separate process context for D with its own memory, stack and virtual registers. H is able to s... |
// The following is written in C
01 int D(int (*x)())
02 {
03 int Halt_Status = H(x, x);
04 if (Halt_Status)
05 HERE: goto HERE;
06 return Halt_Status;
07 }
08
09 void main()
10 {
11 H(D,D);
12 }
**Execution Trace*... |
Disregarding the context of programming languages, a procedure is an unambiguous decomposition of a task in elementary operations, such that it can be performed mechanically. It is implicit that the "operator" knows how to perform the elementary operations.
E.g. the procedure to solve the Hanoi Towers problem is a ... |
It is not regular. Consider the strings "$1^n/0/$" which must be followed by exactly n 1's. So with a finite state machine, after processing $1^n/0/$, we must be in a state $S_n$ which ends up in an accepting state if and only if we process exactly n further 1's. So for n ≠ n', the states $S_n$ and $S_{n'}$ are differe... |
Let $A$ be a language and define $$ CYCLE(A)= \{ yx | xy \in A \} $$ I need to prove, or disprove, $ A\in LSPACE \Longrightarrow CYCLE(A)\in LSPACE $.
First I tried to prove $CYCLE(A) \le_{L} A$ which if true means that if $A\in LSPACE$ then $CYCLE(A)\in L$, hence I tried to define a log space transducer $M$ that ... |
$A\in LSPACE \Longrightarrow CYCLE(A)\in LSPACE$ |
|space-complexity| |
I'm starting to think there's no possible solution to this problem, but before jumping to conclusions I want to confirm it with collective knowledge.
Let's imagine that there's a 2D grid, where S units need to go to T points, but the caveat is that going through a known/explored path has a lower cost than going throug... |
Inverted Min Cost Max Flow |
|algorithms|shortest-path|network-flow| |
I'm starting to think there's no possible solution to this problem, but before jumping to conclusions I want to confirm it with collective knowledge.
Let's imagine that there's a 2D grid, where S units need to go to T points, but the caveat is that going through a known/explored path has a lower cost than going throug... |
> We are given an array of size $n$ (it is not specified if we have an integer array, a specific range or any other assumptions), which might be unsorted, and a real number as a
> constant $k<1$. We need to prove or disprove that it is possible to
> output the $\lfloor n^k \rfloor$ smallest elements of a sorted order... |
null |
Looks like vertex cover for comparability graphs is solvable in P-time:
1. Comparability graphs are (strongly) perfect ("Strongly Perfect Graphs", Berge & Duchet, 1984)
2. Independent set is P-time on perfect graphs (https://en.wikipedia.org/wiki/Perfect_graph)
3. The complement of an independent set is a verte... |
Given a set of input strings, how do I find a shortest string S so that all input strings appear as a substring of S?
for example:
```
foobar + bar -> foobar
foo + bar + rfo -> barfoo
```
I guess it's related to graphs, but don't know how to solve it.
1. first check all the "substrings", for example, "ba... |
Shortest string which all input strings is its substring |
{"Voters":[{"Id":755,"DisplayName":"D.W."}]} |
This is called the [shortest common superstring problem](https://en.wikipedia.org/wiki/Shortest_common_supersequence_problem#Shortest_common_superstring). It is NP-hard. Therefore, you should not expect any efficient algorithm that works for all possible inputs.
Like many NP-hard problems, I imagine you could solv... |
Several algorithms for [sparsest cut][1] (and other kinds of balanced cuts) in [planar graphs][2] have been published, like for instance:
- [Finding minimum-quotient cuts in planar graphs][3], James K. Park, Cynthia A. Phillips, 1993
- [Sparsest cut in planar graphs, maximum concurrent flows and their connections... |
Sparsest cuts of planar graphs |
|algorithms|graphs|optimization|minimum-cuts|planar-graphs| |
Create the set of intervals $[3i - 3 \, x[i] - 2, 3 \, 3i + y[i] - 4]$, i.e., the left endpoint of the $i$th interval is $3i - 3 \, x[i]+1$ and the right endpoint is $3i + y[i] - 1$. Now look for a minimal cover of all integers $1,2,3,\dots,3n-4$ using these intervals. THe solution to that will be a solution to your ... |
Notice that *for a fixed side*, the distances to the vertices are a multiple of the area formed by the side and the vertices. So comparing the areas is in fact a means to compare the distances.
In the figure, you see all antipodal pairs. You can obtain them efficiently by following the polygon edges in clockwise ord... |
null |
For people wondering why the above algorithm is not TLE (Time Limit exceeded),
The time complexity is **not O(mn*4^k)** but **O(mn*3^k)**.
Assuming m,n = 6 and k=15,
**O(36*4^15)** = 10^11 and **O(36*3^15)** = 10^8.
Anything above 10^9 is TLE which above algo doesn't exceed. |
I am studying the complexity of SAT resolution refutation. There is a useful tool named weakening rule
> T[he weakening rule][1]:
B -->B ∨ C
says that from a clause B we can derive the weaker clause B ∨ C for an arbitrary C. We say
that B ∨ C is a weakening of B.
We can add this extra rule without loss of ge... |
How should I go about creating a single-tape Turing machine for the following language:
$$
x_{1,2} = \bigl\{ (a\#b) \mid (a,b) \in \{0,1\}^* \text{and a is a substring of b or a is equal to b} \bigl\}
$$
Some strings that should be accepted are:
- 10#11011
- 1101#1011010101
- 000#1001011000
- 111#111
... |
Creating a Turing machine for Substring and Equal String |
|formal-languages|turing-machines|computation-models|substrings| |
The gray codes are designed to cover all possible bit patterns (of a given length). So 01110011 is perforce a gray code.
The purpose is to enumerate all patterns while changing a single bit at a time.
E.g. 000 001 011 010 110 111 101 100
You don't recognize a code in isolation, the sequence matters. |
The gray codes are designed to cover all possible bit patterns (of a given length). So 01110011 is perforce a gray code.
The purpose is to enumerate all patterns while changing a single bit at a time.
E.g. 000 001 011 010 110 111 101 100
You don't recognize a code in isolation, the sequence matters.
-----... |
null |
null |
I need to construct a Markov algorithm as a set of an ordered rules which will recognize a language $L = \{ww |w \in \{a,b\}*\}$ and give
$$\begin{cases}
Y, \: \text{if given word is in L} \\
N, \: otherwise.
\end{cases}$$
Is there a solution for this problem? |
Markov algorithm for words of a from ww |
|discrete-mathematics| |
I came across this problem while studying the FFT, but I have no idea how to solve it. Can anyone help? |
How to calculate FFT([a1, a2, . . . , an]) in time O(n), when you know FFT([a0, a1, . . . , an−1])? |
|algorithms|time-complexity|fast-fourier-transform| |
Refers to: https://en.wikipedia.org/wiki/One_of_These_Things_(Is_Not_Like_the_Others)
Some of the [actual games][1]
The idea is that there are four different objects, but one in particular stands out from the rest. I've always said that I didn't think AI would ever be able to
this, that this is something that ... |
Is there an AI that can play "One of these things is not like the other" (Sesame Street)? |
|artificial-intelligence| |
One of These Things (Is Not Like the Others): banana, apple, orange, shoe ?
The item that does not belong in the group is "shoe."
The other three items, banana, apple, and orange, are all fruits commonly consumed as food. On the other hand, a shoe is not a fruit; it is a type of footwear typically worn on the fee... |
One of These Things (Is Not Like the Others): banana, apple, orange, shoe ?
The item that does not belong in the group is "shoe."
The other three items, banana, apple, and orange, are all fruits commonly consumed as food. On the other hand, a shoe is not a fruit; it is a type of footwear typically worn on the fee... |
One of These Things (Is Not Like the Others): banana, apple, orange, shoe ?
*The item that does not belong in the group is "shoe."*
*The other three items, banana, apple, and orange, are all fruits commonly consumed as food. On the other hand, a shoe is not a fruit; it is a type of footwear typically worn on the ... |
null |
null |
I need to prove or disprove that for all languages in $R$ there is a reduction to all languages in $P(Sigma^*)\RE$. And I'm having trouble to figuring out the solution, especially with dealing with the trivial cases. |
proving or disproving a reduction from $R <= P(Sigma^*)\RE$ |
|turing-machines|reductions|undecidability| |
I need to prove or disprove that for all languages in $R$ there is a reduction to all languages in $P(Σ^*)\RE$. And I'm having trouble to figuring out the solution, especially with dealing with the trivial cases. |
proving or disproving a reduction from $R <= P(Σ^*)\RE$ |
When my professor introduced regular expressions, he said that the empty string is the simplest regular expression, where it matches everything. How can this be true? I would think the empty string matches nothing, but perhaps I have an incorrect Computer Science understanding of what "null" or "empty" means. |
Empty regular expression |
|formal-languages|regular-expressions| |
proving or disproving a reduction from $R \gtreqqless P(Σ^*)\RE$ |
proving or disproving a reduction from $R <= P(Σ^*)\RE$ |
proving or disproving a reduction from $R \leq P(Σ^*)\RE$ |
I need to prove or disprove that for all languages in $R$ there is a reduction to all languages in $P(Σ^*)\sim RE$. And I'm having trouble to figuring out the solution, especially with dealing with the trivial cases. |
proving or disproving a reduction from $R \leq P(Σ^*)\simRE$ |
I need to prove or disprove that for all languages in $R$ there is a reduction to all languages in $P(Σ^*)\backslash
RE$. And I'm having trouble to figuring out the solution, especially with dealing with the trivial cases. |
proving or disproving a reduction from $R \leq P(Σ^*) \backslash RE$ |
The empty regular expression matches one string: the empty string. That's not everything (most strings aren't the empty string) but it also isn't nothing (the empty string is a string, and the regular expression does match it).
In many programming languages with "regular expression" (regex) support, the default when... |
I'm trying to create a game but I am having some difficulties in coming up with a suitable algorithm for my problem.
I have elements from 1 to n and I am trying to cover all of the elements using the minimum amount of elements as possible.
Each element can cover an amount of elements to the left (x direction) and an... |
I wonder if you might be getting confused about the difference between the regular expression that matches only the empty string (often written $\varepsilon$, or sometimes written $\lambda$; it recognizes the language $\{\varepsilon\}$) vs a regular expression that does not match any string (often written $\emptyset$; ... |
null |
null |
I'm taking some college courses and they have so much math. Why is that?
I'm very good with computers already software and a little bit of hardware and I fix other laptops/Desktops Linux Boxes, Macs etc..
Is this normal or is it just a requirement to get a good job?
|
Why does Computer Science need so much math |
|operating-systems| |
null |
null |
null |
The activities you mention are not computer science but *hardware maintainance* and *system administration*. Computer science is about inventing new algorithms and data structures tailored to new unforseen situations, it is about inventing new concepts that can be built into new programming languages, inventing new com... |
null |
Computer Science is essentially about *programming* computers, how to do it rigorously, efficiently and using methods that have been proven useful by generations of scientists. (To a lesser extent, it is also about *designing* new hardware at the bit level.)
The skills that you mention have nothing to do with progra... |
I need to construct a Markov algorithm as a set of an ordered rules which will recognize a language $L = \{ww |w \in \{a,b\}*\}$ and give
$$\begin{cases}
Y, \: \text{if given word is in L} \\
N, \: otherwise.
\end{cases}$$
Is there a solution for this problem?
UPD. Omitting the formalities Markov Algorithm (... |
I need to construct a Markov algorithm as a set of an ordered rules which will recognize a language $L = \{ww |w \in \{a,b\}*\}$ and give
$$\begin{cases}
Y, \: \text{if given word is in L} \\
N, \: otherwise.
\end{cases}$$
Is there a solution for this problem?
UPD. Omitting the formalities Markov Algorithm i... |
Let $P$ be a constraint satisfaction problem with $n$ variables, each with the same finite
domain $D$, and with $m$ > 0 constraints, where each constraint is an $AllDifferent$ constraint
of arity $k$, for some fixed $k ≥ 2$
I'm trying to prove/disprove the following statements:
- If $|D|$ is equal to the tre... |
Relating the number of solutions to a CSP to the size of the domain and the width of its constraint hypergraph |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.