instruction
stringlengths
0
29.8k
⌀
I am learning about and building a very basic compiler. My question is about code generation. I have read on a lot of materials about code generation when building a compiler and I get the concept. Suppose I am targeting only a single architecture and OS, for a very basic language, and I have completed all the nece...
Creating an executable after code generation - compiler design
|programming-languages|compilers|code-generation|
Both constructions work. The advantages of using NFAs is that they allow easier constructions, especially for languages that can be naturally specified using existential quantifiers. So easy design wins. As you've wrote, putting two automata next to each other and guessing which automaton to run on the input word is a ...
Both constructions work. The advantages of using NFAs is that they allow easier constructions, especially for languages that can be naturally specified using existential quantifiers. So if we only care about proving whether some language is regular, then easy design wins. As you've wrote, putting two automata next to e...
Both constructions work. The advantages of using NFAs is that they allow easier constructions, especially for languages that can be naturally specified using existential quantifiers. So if we only care about proving whether some language is regular, then easy design wins. As you've wrote, putting two automata next to e...
Both constructions work. The advantages of using NFAs is that they allow easier constructions, especially for languages that can be naturally specified using existential quantifiers. So if we only care about proving whether some language is regular, then easy design wins. As you've wrote, putting two automata next to e...
Difference between product automaton vs. NFA with epsilon transitions
In the CSES problem [Sliding Window Cost][1], given an array and an integer `k`, we are asked to compute the **minimum cost** for each sliding window of fixed size `k`. The minimum cost is defined as the cost of making all elements equal. Therefore, it can be expressed as the sum of differences between each value and t...
I want to write a regular expression that generates precisely those words over $\Sigma = \{a,b\}$ that contain at **most** 1 non-overlapping occurrences of the subword bba. It has to accept the empty word and words suchs as $a$ or $bb$ or $aaaaaabbabbbb$. So far I've tried to place $bba$ in the beginning, middle or ...
null
Questions about regular expressions, a formalism to describe regular languages. If you are asking about how to find a regular expression for some language, please consult https://cs.stackexchange.com/q/45570/755 before asking, and show what progress you have made. Note that regular expressions in a computer scien...
{"OriginalQuestionIds":[45570],"Voters":[{"Id":755,"DisplayName":"D.W."}]}
Given a set $Z$ of $n$ points $(p_1,p_2,p_3, \ldots,p_n)$. The coordinates of these points are arbitrary numbers and are unsorted. If they give me $s$ and $t$ to be two points in $Z$. A northeast path from $s$ to $t$ in $Z$ is a sequence of points $(s=t_1,t_2,\ldots,t_k=t)$ such that every point for any two points $t_i...
Find the longest northeast path in $O(n\log n)$ time
null
I created a DFA recognizing the language and used the Brzozowski and McCluskey's algorithm (state elimination method) to obtain: $$(00\mid 11)^*(01\mid 10)\left(00\mid 11 \mid (01\mid 10)(00\mid 11)^*(01\mid 10)\right)^* $$
An effectively universal Turing machine $T$ is a Turing machine for which there exists a recursive reduction $f:A\rightarrow B$ such that $\forall A\forall B:T(B)=U(A)$, where $A,B$ are some sequences of symbols (that are given as inputs) and $U$ is a universal Turing machine. Is there any connection between effecti...
I was thinking about quicksort with multiple pivots and I came across this question. How can we efficiently implement a version of Quicksort where we choose $k−1$ pivots to partition an array of unique numbers into $k$ classes? My goal is to demonstrate that this multiary partitioning can be achieved in $O(n \log k)$ t...
Quick sort with $K-1$ pivots
null
Hint: Suppose $k$ is a power of two at first, for simplicity. Find the $n/2$th element in the array. Then.... (you fill in the next part)
An effectively universal Turing machine $T$ is a Turing machine for which there exists a recursive reduction $f:A\rightarrow B$ such that $\forall A\exists B:T(B)=U(A)$, where $A,B$ are some sequences of symbols (that are given as inputs) and $U$ is a universal Turing machine. Is there any connection between effecti...
An effectively universal Turing machine $T$ is a Turing machine for which there exists a recursive reduction $f:A\rightarrow B$ such that $\forall A\exists B:T(B)=U(A)$, where $A,B$ are finite sequences of symbols (that are given as inputs) and $U$ is a universal Turing machine. Is there any connection between effec...
An effectively universal Turing machine $T$ is a Turing machine for which there exists a recursive reduction $f$ such that $\forall A:U(A)=T(f(A))$, where $A, f(A)$ are finite sequences of symbols (that are given as inputs) and $U$ is a universal Turing machine. Is there any connection between effectively universal ...
null
null
null
I have the following recurrence: $F(n, L) = 2F(n / 2, L) + nL + n^2 log(n)$. Am I correct in saying that $F(n, L) \in O(n \log(n) L + n^2 log(n))$? I got to this result by bounding the $nL$ and $n^2 \log(n)$ parts separately. Thank you!
$F(n, L) = 2F(n / 2, L) + nL + n^2 log(n)$ and Master Theorem
|runtime-analysis|master-theorem|
You don’t really need the master theorem. If n = 2^k then the result is <= 2 n^2 k + n k L.
If you have a recurrence that doesn’t apply to the case n = 1, then it would be correct to assume T(1) = c, for some unknown c, and resolve the recurrence based on that; this would be useful if you are interested in actual and not just asymptotic values. Or you can say that T(1) is O(1) and go from there. If the re...
null
I'm a CS undergrad so forgive me if this question isn't formulated well. I got curious about the Busy Beaver function recently, and it got me wondering how all the n-state Turing machines are kept track of. Is there like a list of all of the machines, along with whether they halt or not? Or is there some other way?
How do people working on the Busy Beaver function keep track of all the turing machines?
|turing-machines|halting-problem|busy-beaver|
I'm inclined to disagree with McBride here, for the simple reason that while you can express program semantics totally via coinduction, it is not enough to solve the halting problem for the object language (because you would need to run the coinductive trace to exhaustion, which of course may be infinite). --- I ...
So I asked this question already once but didn't formulate it well. I ask it again but this time I want to be clear. The way how I understood it, the substitution method wants you to come up with a guess function $g(n)$ which has the property $g(n) \in O(f(n))$. The goal is, to show that your recurrence $T(n) \in O...
Can you short-cut the substitution method for recurrence solving? (Wrong Guess but End Result Works)
|recurrence-relation|
null
[From page 5, 1st paragraph][1], it is stated that: > Notice that an n-state Busy Beaver, if we had it, would serve as an O(n log n)-bit advice string, “unlocking” the answers to the halting problem for all n<sup>O(n)</sup> Turing machines with n states or fewer. Furthermore, this is essentially optimal: if we had a...
Hardwiring advice (bit string) into Turing machine
|complexity-theory|turing-machines|busy-beaver|
[In paper][1], page 5, 1st paragraph, it is stated that: > Notice that an n-state Busy Beaver, if we had it, would serve as an O(n log n)-bit advice string, “unlocking” the answers to the halting problem for all n<sup>O(n)</sup> Turing machines with n states or fewer. Furthermore, this is essentially optimal: if we ...
[In paper][1], page 5, 1st paragraph, it is stated that: > Notice that an n-state Busy Beaver, if we had it, would serve as an O(n log n)-bit advice string, “unlocking” the answers to the halting problem for all n<sup>O(n)</sup> Turing machines with n states or fewer. Furthermore, this is essentially optimal: if we ...
I had this problem in several projects and generalized a solution: https://github.com/cgdeboer/iteround
null
I am not a computer science nor a math person, but if given a pseudo-code or a English outline of steps. I can probably fumble my way through and write some code. I Apologize for the wall of text/numbers and my formatting. Seeking an algorithm that takes a number to start with. This number will be either in column A...
Seeking help in designing an algorithm
|algorithms|algorithm-design|
null
No, you can't. As an example, consider the recurrence $T(n) = 4T\left(\frac{n}2\right) + n^2$. If you assume $T(n) \leqslant cn^2 - dn$, using substitution method, you will get to: $$T(n) \leqslant 4\times c\frac{n^2}4 - 4\times d\frac{n}2 + n^2 = (c+1)n^2-2dn$$ Even if $(c+1)n^2-2dn\in \mathcal{O}(n^2)$, y...
If you have a unweighted directed graph with possible cycles, what algorithm would you use to find the longest path without visiting the same node twice? Also, there are multiple starting nodes... The real problem I am trying to solve is the following: All values are positive integers: A1 = [a1, a2, ..., an] ...
Longest path of directed graph with cycle and now weights
|shortest-path|
I couldn't understand the following part on admissible heuristic on [wiki][1]. How does it reach that they have to be equal? Admissible heuristic only says the eval needs to be equal/less than the true cost. > If our heuristic is admissible it follows that at this penultimate step Teval = Ttrue because any increase...
Admissible Heuristic wiki
|shortest-path|
The [longest path problem](https://en.wikipedia.org/wiki/Longest_path_problem) is $\mathsf{NP}$-complete, so there is no known polynomial algorithm. It can be solved in exponential time using [dynamic programming](https://cs.stackexchange.com/a/56778/79440).
null
The [Arm documentation][1] for Cortex-A76 (Raspberry Pi 5) says the L2 cache replacement policy is "*dynamic biased*". But what is it? More precisely: 1. How does it works? 2. Why not using pseudo-LRU, as for L1 cache? [1]: https://developer.arm.com/documentation/100798/0401/L2-memory-system/About-the-L2-...
What is dynamic biased cache replacement policy?
|cpu-cache|
Is the following adaptation of the graph bandwidth problem NP hard? If so, which problem could a reduction use? Given: Graph $G = (V , E ), L:E\to \mathbb N$. Question: Is there a $f : V → \mathbb Z$ where for each $e = \\{u, v \\} \in E: |f (u) - f (v )| = L(e)$?
NP hardness of adaption of the graph bandwidth problem
|graphs|np-hard|
null
null
null
There's a standard trick I've heard about in reductions where you just halt a machine and reject after some polynomial amount of time if it hasn't accepted yet. Can this be applied to nondeterministic Turning machines, and if not then why? For example, suppose we had a nondeterministic Turing machine $M$ for SAT. Gi...
Reductions trick where you halt and reject after polynomial time
|complexity-theory|reductions|
If I have a list of conditions: and(a,or(b,c)) not(b) or(a,c) and(a,d) or(or(or(a,b),c),d) and I'm given values for these conditions, let's say, `a=true, b=false, c=false, d=true`, what is a good algorithm to find the true ones in less than `O(log n)`? I'm trying to avoid testing all condi...
Search a list of conditions
|algorithms|search|
null
Consider $$L=\{<TM>:TM \text{ is a Turing machine and has minimal states}\}$$ $$L'=\{<PDA>:PDA\text{ is a PDA and has minimal states}\}$$ Which one is recursive? I think neither $L$ nor $L'$ are recursive but I can't reduce from a famous problem.
Undecidability of minimal PDAs and TM machines
|formal-languages|
I'm trying to prove that an inefficient double-lengthening PRG exists, i.e. construct a PRG $G: \{0,1\}^n \rightarrow \{0,1\}^{2n}$ My current approach is to bound the number of poly-time non-uniform algorithms as the number of boolean circuits, which is $2^{n^2}$, then we can say there $2^{n^2}$ functions, we will ...
Inefficient double lengthening PRG
|algorithms|time-complexity|polynomial-time|pseudo-random-generators|
- If the machine is a decider, meaning halts on its input $w$, then it does not repeat a configuration in its run on $w$. Hence, the number of configurations that the machine can be in bounds its running time from above. The number of configurations is at most $|Q| \cdot |\Sigma|^n \cdot n = 2^{log(|Q|\cdot |\Sigma|^n...
I found an answer that works well. The basic concept is to iterate a sorted list of all 'points of interest' (start & end location of intervals). Iterating that (scan line) allows us to maintain a stack of 'active intervals' (push when interval starts; pop when interval ends) where the top one is the dominating interva...
My teacher explained the function of a one-class SVM to us. However, the sketch used is not correct from my point of view. I understand the function of a one-class SVM as follows: - The SVM is trained with normal data. It finds a blue circle (in 2 dim) where most of the training data lies. However, some of the trai...
How does a One-Class SVM work?
|machine-learning|svm|
I found an answer that works well. The basic concept is to iterate a sorted list of all 'points of interest' (start & end location of intervals). Iterating that (scan line) allows us to maintain a stack of 'active intervals' (push when interval starts; pop when interval ends) where the top one is the dominating interva...
null
For all CFL, there is a one-state PDA that recognizes this language. So $L'$ is recursive: you just have to check if the PDA has exactly one state. For $L$, note that Turing machines with exactly one state can recognize only the empty language or the universal language. That should help to find a reduction.
For all CFL, there is a one-state PDA that recognizes this language. So $L'$ is recursive: you just have to check if the PDA has exactly one state. For $L$, note that Turing machines with exactly one state can recognize only the empty language or the universal language. That may help to find a reduction.
For all CFL, there is a one-state PDA that recognizes this language. So $L'$ is recursive: you just have to check if the PDA has exactly one state. For $L$, note that Turing machines with exactly one state can recognize only the empty language or the universal language. That may help to find a reduction (especially ...
This proof is very similar to a proof in [Sipser](https://www.goodreads.com/book/show/400716.Introduction_to_the_Theory_of_Computation?ac=1&from_search=true&qid=XwvlSNsyvA&rank=1). They consider the length of the description $\langle TM \rangle$ instead of the number of states, but the idea is the same. Assume that...
We can view this problem as depth first search on a directed unweighted bipartite graph. A graph is a set of vertices connected by a set of edges between the vertices. We can construct such graph by viewing each number as a vertex, then ask each pair of vertices whether they match one of the possible length of mo...
Definition: $\text{P}$ is the set of languages that can be decided by a deterministic Turing Machine in polynomial time. I wonder if $\text{P}$ equals to the set of languages that can be decided by a non-deterministic Turing Machine in polynomial time? I think this has to be true because a non-deterministic Turi...
|complexity-theory|turing-machines|polynomial-time|nondeterminism|
> I wonder if $\text{P}$ is the set of languages that can be decided by > a non-deterministic Turing machine in polynomial time? This is the same as asking whether $ \text{P} = \text{NP}$, where $\text{NP}$ is the set of languages that can be decided by nondeterminsitic Turing machines in polynomial time. The ques...
null