instruction
stringlengths
0
29.8k
⌀
Of course it is regular, because it contains the complete set {0,1}*. Note: This was the correct answer to the question before it was edited.
null
To simplify it, it seems that we can do $(L+M^*)^* = (L+M)^*$, but I also need to prove it.$(L+M)^* ⊆ (L+M^*)^*$ seems straight forward. However, $(L+M^*)^* ⊆ (L+M)^*$ is what I couldn't figure out. Should I use $ (L^*M^*)^*$ instead of $( L+M)^*$? If I use it and do induction on k, $ u ∈ (L+M^*)^*$ and u = (v1+m1)...(...
Simplifying regex expression (L+M*)*
|automata|finite-automata|regular-expressions|
null
After a lot of thought and trial and error, this is the solution that I believe solves my problem: 1. Get list of processors that are selected to get files with the limit they are allowed to receive, and their current count initialized at 0. 2. Get a list of all designated processors and file sources. 3. Loop t...
null
What is the complexity of the following (Python) code, that builds the list L of all subsets of size $k$ of a given set? ```python # arr: input array # k : size of subsets # tmp : current subset # idx : current index in tmp # i : current array element # L : list of all subsets of size k def subsets(arr, k, i...
Complexity of generating all subsets of size $k$ using recursion
|complexity-theory|time-complexity|recursion|
null
null
null
Operating systems don't always let a user control thread priority in the way that a programmer would like, and certainly not without extra privileges. General-purpose operating systems have multiple classes of task priority. For example, you may find (in decreasing order of "priority"): * A few very high priority...
null
I am looking for a formula or program to help place people in classes based on their preferences. The elements of the problem are: There are 30 class choices a student can pick from. There are 400 students that are asked to rank their top five class preferences. Each class (specialty subject, but a clas...
Is there a sorting program or formula to sort and place individuals in classes based on preferences
|algorithms|dynamic-programming|sorting|databases|data-sets|
How should datatypes be organised in a computer programme? Is it better to utilise arrays or linked lists? I'm not sure what the difference is, but I seem to recall hearing that arrays are quicker. Or perhaps it was connected lists? So, which one should I go with?
Is it better to arrange datatypes in a computer programme using arrays or linked lists?
|data-structures|
Whether to use arrays or linked lists to arrange data types in a computer program depends on the specific requirements and characteristics of the program. Arrays are a good choice when the data size is fixed and known in advance, and when random access to elements is required. They are also more memory efficient tha...
So i'm taking this class automata and complexity at georgia tech and we were given practice material for our exam. one of the question is to give context free grammar for these two languages ![enter image description here][1] ![enter image description here][2] and the answers are: L1 ![enter image de...
How to develop intuition to come up with Context Free Grammar?
|complexity-theory|automata|context-free|formal-grammars|lexical-analysis|
Let $\mathcal{A}$ be a family of integer matrices, $\mathcal{B}$ a family of integer vectors, and $k$ an integer. Define $L(\mathcal{A}, \mathcal{B}, k)$ to be the following family of decision problems. > INPUT: a matrix $A\in \mathcal{A}$ and a vector $b\in \mathcal{B}$, > > OUTPUT: "True" if there exists a real ...
Let $\mathcal{A}$ be a family of integer matrices, $\mathcal{B}$ a family of integer vectors, and $k$ an integer. Define $L(\mathcal{A}, \mathcal{B}, k)$ to be the following family of decision problems. > INPUT: a matrix $A\in \mathcal{A}$ and a vector $b\in \mathcal{B}$, > > OUTPUT: "True" if there exists a real ...
null
You know how many results are produced. If you can determine how many operations each result takes, then you just multiply.
null
This problem, or at least one interesting variant of it, is **NP-complete** even for binary alphabets and word lengths at most logarithmic in the total number $p$ of partition parts, so it's very unlikely that a polynomial-time algorithm can be found. I have some ideas about ways to reduce the $O(p!)$ time complexity o...
null
null
I do not understand the "execution graph" (I think that's what it's called) of the following Non-Deterministic Finite Automata, given on pg 48-49 of Sipser's *Intro to TCS (3rd edition)*: [![enter image description here][1]][1] And here is the execution graph: [![enter image description here][2]][2] Why after...
Confusion with Execution of NDFA
|computability|finite-automata|
null
Oh okay, I think I see the point. Whenever an $\epsilon$ transition is encountered, it puts the resulting state on the same level as the state it came from, in order to have each row of the tree be in the same execution stage (as in they have read the same number of symbols).
The SAT problem is often explained in terms of truth tables. Given some random boolean circuit, calculate its truth table; does there exist an output of $1$ in the truth table? But how about going the other way? A function problem that inputs a truth table, and asks you to construct a boolean circuit that computes t...
Time complexity to convert a truth table to a boolean circuit
|np-complete|np|satisfiability|search-problem|
Let $n$ and $r$ be positive integers. For i = 1,2,...,n, let $f_i$ be a univariate real-valued function defined in the integer domain and let $f_i(x_i)$ be $-\infty$ for negative integer $x_i$. Any non-negative integer solution $(x1,...,x_n)$ that satisfies $\sum_{i=1}^n x_i = r$ is called a feasible solution. In ad...
prove the correctness of greedy algorithm on interger optimize
|optimization|greedy-algorithms|
Data structures (not types) are not chosen "randomly" and there is no absolute preference order. For a given application, different data structure options can be compared. In particular, for containers or associative containers, one looks at the time and space complexities of insertions, deletions, lookups..., put i...
Informally, $(L+M)^*$ represents any sequence made of $L$s and/or $M$s, you can't make it more general. $(L+M^*)^*$ of course includes $(L+M)^*$, but the latter cannot be a proper subset.
Informally, $(L+M)^*$ represents any sequence made of $L$s and/or $M$s, you can't make it more general. $(L+M^*)^*$ of course includes $(L+M)^*$, but the latter cannot be a proper subset. ---------- More rigorously, $$L+M^*⊆(L+M)^*$$ so that $$(L+M^*)^*⊆((L+M)^*)^*=(L+M)^*$$
## Case 1: Union of selected intervals might not be a single interval First of all, sort the intervals in increasing order of $I_i.start$ Use the following Dynamic Programming solution: $$ \mathrm dp(i, j, k) = max( \text{extend_union} + dp(i + 1, j’, k - 1), dp(i + 1, j, k) ) $$ where $$ \mathrm j...
I have heard DNA being refered to as "code", this is because it is an instruction set which dictates the boddie's properties. However, DNA (as far as I have learned), has no conditional jumps or normal jumps. Please state why DNA is or in not turing complete and why.
Is DNA turing complete
|turing-completeness|
In type checking systems, the ($\vdash$) represents the ternary relation over type environments, expressions and types: $\vdash \texttt Env \times \texttt Exp \times \texttt Typ$. In your example, the expression $t_2$ is typed at type $T_2$ *wrt* a type environment having a type assumption mapping $T_1$ to some ty...
My goal is to create a strict partial order from a strict total order with the help of a concurrency oracle. The elements of the two orderes are the same, I just need to transform the order relation based on the information provided by the oracle. The concurrency orracle is a function, that tells me which pairs o...
I am looking for a map-like data structure with the following properties: - it uses subsets of some set S as keys. The size of S is potentially unbounded, but does not change during the runtime - the size of the subsets, used as keys, can vary between keys, i.e. one key can be a 3 element subset, while another migh...
I am looking for a map-like data structure with the following properties: - it uses subsets of some set S as keys. The size of S is potentially unbounded, but does not change during the runtime - the values associated with the keys are generic objects - poiters/references. Their properties are not important for the...
A BST traversal will output the keys in sorted order in linear time, so no comparison-based tree building algorithm can work faster than in $O(n\log n)$ time. As said at other places, this bound can be reached by filling a balanced BST one key at a time, and this is optimal. If the *balance* condition is not enforce...
A BST traversal will output the keys in sorted order in linear time, so no comparison-based tree building algorithm can work faster than in $O(n\log n)$ time. As said at other places, this bound can be reached by filling a balanced BST one key at a time, and this is optimal. If the *balance* condition is not enforce...
A truth table for $m$ variables has $n=2^m$ entries. A corresponding sum-of-products expression is made of at most $2^m$ terms, each of length $m$. So the total complexity of outputting them is $O(m2^m)=O(n\log n)$, in terms of the input size. This is polynomial.
A truth table for $m$ variables has $n=2^m$ entries. A corresponding sum-of-products expression is made of at most $2^m$ terms, each of length $m$. So the total complexity of outputting them is $O(m2^m)=O(n\log n)$, in terms of the input size. This is polynomial. ---------- As regards minimization of the expr...
Data structures are not chosen "randomly" and there is no absolute preference order. For a given application, different data structure options can be compared. In particular, for containers or associative containers, one looks at the time and space complexities of insertions, deletions, lookups..., put in relation t...
Let a small cube be centered at the coordinates $(x,y,z)$, where $x,y,z\in\{-1,0,1\}$. By a rotation of a quater turn around the $X$ axis, $(x,y,z)$ moves to $(x,-z,y)$. By composition, a rotation by a half turn goes to $(x,-y,-z)$ and so on. You can easily generalize to all three axis. In the Rubik's Cube, a face h...
Let a small cube be centered at the coordinates $(x,y,z)$, where $x,y,z\in\{-1,0,1\}$. By a rotation of a quater turn around the $X$ axis, $(x,y,z)$ moves to $(x,-z,y)$. By composition, a rotation by a half turn goes to $(x,-y,-z)$ and so on. You can easily generalize to all three axis. In the Rubik's Cube, a face h...
Let a small cube be centered at the coordinates $(x,y,z)$, where $x,y,z\in\{-1,0,1\}$. By a rotation of a quater turn around the $X$ axis, $(x,y,z)$ moves to $(x,-z,y)$. By composition, a rotation by a half turn goes to $(x,-y,-z)$ and so on. You can easily generalize to all three axis. In the Rubik's Cube, a face h...
Let a small cube be centered at the coordinates $(x,y,z)$, where $x,y,z\in\{-1,0,1\}$. By a rotation of a quater turn around the $X$ axis, $(x,y,z)$ moves to $(x,-z,y)$. By composition, a rotation by a half turn goes to $(x,-y,-z)$ and so on. You can easily generalize to all three axis. In the Rubik's Cube, a face h...
After a lot of thought and trial and error, this is the solution that I believe solves my problem: 1. Get list of processors that are selected to get files with the limit they are allowed to receive, and their current count initialized at 0. 2. Get a list of all designated processors and file sources. 3. Loop t...
null
This approach has been on my mind for quite some time. I did come up with it myself, I searched some methods for determining prime numbers but never came across anything similar to this. import math n = int(input()) def is_prime(n): x=n i= 2 while(x>i): if n%i==0...
A new algorithm for determining if a number is prime or not
|algorithms|number-theory|primes|
Very sorry, but this is just a variant of the successive divisions method, the most basic of all, that a simple Web search would have shown you. Nothing new. Note that trying all integers instead of the odd numbers is a little waste. Also, divisions are more costly than multiplies, so the test $i^2<n$ would be bette...
Very sorry, but this is just a variant of the successive divisions method, the most basic of all, that a simple Web search would have shown you. Nothing new. Note that trying all integers instead of the odd numbers is a little waste. Also, divisions are more costly than multiplies, so the test $i^2<n$ would be bette...
null
You seem to confuse a code understood as a way to encode information (such as the Gray code) and as a piece of program written in some programming language (such as *source* code and *binary* code). *DNA code* belongs to the first meaning.
You seem to confuse a code understood as a way to encode information (such as the Gray code) and as a piece of program written in some programming language (such as *source* code and *binary* code). *DNA code* belongs to the first meaning. The DNA code is similar to a mixed base $4^3=64$ numeration (I don't mean htt...
null
Here is my LC-3 Assembly code. It is designed to add up the 10 values in x3100 through x3109 and store them in x310A. It correctly adds the values, storing the total in R0, however I cannot seem to get it to properly store that value in x310A. .ORIG x3000 AND R0, R0, #0 ; use R0 ...
I'm having trouble storing the value in R0 into the correct memory location (LC-3 Assembly)
|assembly|
I am looking for a formula or program to help place people in classes based on their preferences. The elements of the problem are: There are 30 class choices a student can pick from. There are 400 students that are asked to rank their top ten class preferences. Each class (specialty subject, but a class...
null
After having searched for a while, and after having read this https://stackoverflow.com/questions/1592649/examples-of-algorithms-which-has-o1-on-log-n-and-olog-n-complexities I was just wondering: is there some example of algorithm whose time complexity is ?$$O(n^{\log(n)})$$ Sorry for the arid question, I wou...
Al algorithm that is $O(n^{\log(n)})$
|complexity-theory|time-complexity|asymptotics|
null
null
null
I have heard DNA being referred to as "code", this is because it is an instruction set which dictates the bodies' properties. However, DNA (as far as I have learned), has no conditional jumps or normal jumps. After reading the article [*DNA computing*](https://en.wikipedia.org/wiki/DNA_computing) on Wikipedia briefl...
Is DNA computation Turing complete?
|turing-completeness|
**Question:** There are N soldiers standing in a straight line with ID 1 to N: [1,2,3,4,5] You are given array of IDs of length K in the order they are called : [3,1,2,1] When a ID is called the soldiers with that ID will attack the enemy and he will do the same damage as number of soldiers infront of him and ...
Optimization of algorithm
|algorithms|data-structures|
Yes, there are examples, though I don't know of any elementary ones. Before I give one, notice that $$ n^{\log n} = (2^{\log n})^{\log n} = 2^{(\log n)^2} = O(2^{\text{poly}(\log n)}) $$ where $\text{poly}$ is a polynomial function (in this case quadratic). For this reason, the time complexity you are interested...
Let's take a particular $a_i$ and $b_j$, what would be it's result if $a_i$ is a multiple of $b_j$, obviously $\frac{a_i}{b_j} \cdot c_j$. Now, think about what would be the result if $a_i$ isn't a multiple of $b_j$, it would be the same answer as for the least multiple of $b_j$ which is greater than $a_i$. For a...
An algorithm that is $O(n^{\log(n)})$
Is there any algorithm that can efficiently construct a generalized suffix tree or array (or something similar) for a prefix tree (trie)? In particular, I'm wondering: - How time-efficient an algorithm for this can be - How space-efficient the resulting data structure can be - What algorithm(s) might be abl...
Efficient generalized suffix array/tree construction for prefix trees
|suffix-trees|suffix-array|trie|
null