instruction
stringlengths
0
29.8k
⌀
I was playing a puzzle game and started wondering how they implemented their undo feature. The game only has five possible moves, and only when the player does a move does the game state change, but the game state can be quite complicated. The standard undo implementation would be to keep track of a stack of all pas...
Memory efficient undo data structure
|data-structures|reference-request|stacks|computer-games|
null
According to me the scalble and non-scalble data can be illustrated as follows: Non-Scalble data: The Non-Scalble data is nothing but the data for a software, algorithm, ect . Which is not in that format , need change in which that software is family .. that type of data we call it as a Non-Scalble data for that respe...
If Turing Recognizability means a T.M. will either halt on input $w$ if $w$ is in the language, or run forever if $w$ is not in the language. How can we know the language is Turing Recognizable if we run the T.M. on a $w$ not in the language and thus it never halts so we do not get to the next input.
|turing-machines|chomsky-hierarchy|
null
I think you've gotten yourself on the wrong path by trying to use PNG, splitting up into multiple chunks so the PNG files aren't too big, etc. Instead, store your data using any [sparse matrix datastructure](https://en.wikipedia.org/wiki/Sparse_matrix). There are many simple schemes. As you suggest, "a dictionary ...
Is there any programming language, by which I can write a code that during run time automatically generates so many other codes and furthermore those codes will be run in parallel?
Metaprogramming language
|programming-languages|
Yes. A relevant technical term is '[persistent data structure](https://en.wikipedia.org/wiki/Persistent_data_structure)'. (See also [tag:persistent-data-structure].) There are many techniques for building persistent versions of standard data structures (trees, lists, arrays, etc.), so you can represent your state as...
What you actually ask is: can language of every grammar be represented as an intersection of two context-free languages? The answer is **no**.\ To prove that, we can observe that, while the class of context-free languages is not closed under intersection, the class of context-sensitive languages is. This means tha...
null
null
null
No, such a construct can recognise at most the intersection of two context-free languages. To see where it's lacking, consider $L = \{\textsf{a}^n~|~n\in\mathbb{N}~\text{is co-prime}\}$. I conjecture that to express $L$ as the intersection of CFLs requires infinitely many CFLs. **Updated** after @HendrikJan's commen...
No, such a construct can recognise at most the intersection of two context-free languages. To see where it's lacking, consider $L = \{\textsf{a}^n~|~n\in\mathbb{N}~\text{is composite}\}$. I conjecture that to express $L$ as the intersection of CFLs requires infinitely many CFLs. **Updated** after @HendrikJan's comme...
null
No, such a construct can recognise at most the intersection of two context-free languages. To see where it's lacking, consider $L = \{\textsf{a}^n~|~n\in\mathbb{N}~\text{is composite}\}$. I conjecture that to express $L$ as the intersection of CFLs requires infinitely many CFLs. The paper *An infinite hierarchy of i...
null
null
Let HALT be a program that can decide the halting problem for any program and its input. HALT has two inputs, the program and the program's input. Let OPPOSITE be a program that accepts a program as input, calls HALT with its input as both of HALT's inputs, and then does the opposite of whatever HALT has concluded. ...
Halting Problem Question
|halting-problem|
I can easily convert NFA with multiple start states to NFA with single start state with epsilon transition. But I want to know how can I do so without epsilon transition Here's my idea 1. Suppose s1 and s2 are the start states. Let s0 be the new start state. 2. If s1 or s2 are final states, make s0 final stat...
How to convert NFA with multiple start states to NFA with single start state without epsilon transition?
|automata|finite-automata|nondeterminism|
null
Having a *one-step* functional $G := (\lambda r.\lambda x.\ \dots r\dots)$ where $r$ is used for a "recursive" call (or calls), the corresponding recursive function denoted by the $\lambda$-term $R$ must fulfill $$R = G\ R = G(GR) = \dots $$ precisely because $r$ is used for the recursive call(s). Lambda te...
Assume that the language $L = \{a^{(n^2)} | n > 0\}$ is context-free and let N be the pumping length given by the Pumping Lemma. Choose the string $u = a^{(N^2)}$, which is in the language L. According to the Pumping Lemma, u can be decomposed into vwxyz such that |wxy| ≤ N, |wy| > 0, and $vw^mxy^mz$ is in L for eve...
A good account of this result is in the [lecture notes of Dexter Kozen][1], although the original work of Meyer and Stockmeyer contains a refined space bounds. You may consult that version in Stockmeyer's thesis, for instance. [1]: http://www.cs.cornell.edu/courses/cs786/2004sp/Lectures/l10-complexity.pdf
null
**The following is small-scale example is meant to illustrate the general distribution problem** Consider 4 parks, each with exactly 1 pond. Parks are marked as vertices in the following undirected graph: [![desc][1]][1] Each park has a number of ducks in them, and each pond has a maximum capacity of ducks (th...
Is there an algorithm for the distrubution of ducks into ponds
|algorithms|graphs|combinatorics|
Is there an algorithm for the distrubution of ducks into ponds?
**The following is small-scale example is meant to illustrate the general distribution problem** Consider 4 parks, each with exactly 1 pond. Parks are marked as vertices in the following undirected graph: [![desc][1]][1] Each park has a number of ducks in them, and each pond has a maximum capacity of ducks (th...
This can be solved with max-flow: create a bipartite graph with parks on one side and ponds on another, have an edge with infinite capacity if a duck from park A can fly to pond B, and for each park have an edge from the source to it whose capacity is the number of ducks at that park, and for each pond an edge to the s...
null
A very similar construction/viewpoint has been recently studied by Colcombet and Petrişan in [[CP20]]. They see a deterministic finite automata as a functor $$\mathcal{A} \colon \mathcal{I} \to \mathsf{Set}$$ where $\mathcal{I}$ is the category induced by the three objects $\textsf{initial}$, $\textsf{states}$ and $\...
**The following is small-scale example is meant to illustrate the general distribution problem** Consider 4 parks, each with exactly 1 pond. Parks are marked as vertices in the following undirected graph: [![desc][1]][1] Each park has a number of ducks in them, and each pond has a maximum capacity of ducks (th...
I'm currently studying structural properties of network and control protocols and their relation to testing. I'm specifically interested in state machines. They would not need to cover the full behavior to be useful. For many protocols, prototypical state machines can be found online when specifically searching for the...
Looking for collection of protocol state machines
|automata|reference-request|communication-protocols|protocols|
A good account of this result is in the [lecture notes of Dexter Kozen][1], although the original work of Meyer and Stockmeyer contains a refined space bounds. You may consult that version in Stockmeyer's thesis, proposition 4.11 and theorem 4.13, for instance. [1]: http://www.cs.cornell.edu/courses/cs786/2004sp...
I've read [Downfall paper][1]. In the university, I've had an introductory course on computer organization and operating systems. We also studied Spectre and Meltdown attacks there. I understood the interplay of speculative execution and side channels in the case of those attacks. I understand the general similarity...
How exactly does stale data appear in temporal buffer in Downfall attack?
|computer-architecture|operating-systems|security|
A very similar construction/viewpoint has been recently studied by Colcombet and Petrişan in [[CP20]]. They see a deterministic finite automata as a functor $$\mathcal{A} \colon \mathcal{I} \to \mathsf{Set}$$ where $\mathcal{I}$ is the category induced by the three objects $\textsf{initial}$, $\textsf{states}$ and $\...
A very similar construction/viewpoint has been recently studied by Colcombet and Petrişan in [[CP20]]. They see a deterministic finite automaton as a functor $$\mathcal{A} \colon \mathcal{I} \to \mathsf{Set}$$ where $\mathcal{I}$ is the category induced by the three objects $\textsf{initial}$, $\textsf{states}$ and $...
null
null
I am working on building exact algorithms for NP-hard problems. Let's consider an NP-hard problem $P$. The brute force approach runs in $2^n$ time. In order to prove that there is no $2^{o(n)}$ time algorithm for $P$, we provide a reduction from the 3-SAT problem (Assuming ETH holds).<br> I want to prove that there ex...
lower bounds for exact algorithms
|algorithms|np-hard|
I am working on building exact algorithms for NP-hard problems. Let's consider an NP-hard problem $P$. The brute force approach runs in $2^n$ time. In order to prove that there is no $2^{o(n)}$ time algorithm for $P$, we provide a reduction from the 3-SAT problem (Assuming ETH holds).<br> I want to prove that no exact...
That is very unlikely to be true, because the problem size n will depend on exactly how problem instances are represented. If one representation is 20% larger, then the time to solve the problem is unaffected, but the time would be not $2^n$ but $2^{n/1.2}$ or $c^n$ for $c = 2^{1/1.2}$. And many problems have s...
We are looking for a code to list all maximal bicliques in bipartite graphs efficiently, as we want to run it on (large and sparse) graphs, with up to roughly a million nodes and edges in no more that a few hours. In the literature, we know [this fast implementation][1] which implements the algorithm presented in ["...
Code to list all maximal bicliques of a bipartite graph
|graphs|enumeration|bipartite-graph|
null
null
An intuitive classification between regular and non-regular languages is based on their recognizers. In case of regular languages, Finite State Automata are enough, while for non-regular languages you need more powerful automata. A language is regular if you can build a FSA for it. Thus, given that you can always bu...
null
No, Python is not a context-free language. It is a programming language that follows a syntax defined by a context-sensitive grammar. Context-free languages are a subset of formal languages that can be described by context-free grammars, where the structure of the language is determined solely by the arrangement of i...
null
null
I'm reading *Java Concurrency in Practice*, and I came across the following sentence (section **2.3.1 Intrinsic locks**, pg. 25): >Every Java object can implicitly act as a lock for purposes of synchronization; these built-in locks are called intrinsic locks or monitor locks. > >Intrinsic locks in Java act as *mut...
Can (intrinsic) locks act in different ways in addition to mutexes?
|concurrency|java|mutual-exclusion|
If I start with a directed graph that is strongly connected, is there a straightforward way / algorithm to find the smallest set of edges to remove, such that the result is a directed but acyclic graph? To be clear, the result is neither necessarily a tree (could have more than one way from A to B), nor is the grap...
Minimum edges removed to turn a strongly connected graph into an acyclic graph
|algorithms|graphs|dag|directed-graphs|connected|
null
This is a classic NP-complete problem called [Feedback Arc Set](https://en.m.wikipedia.org/wiki/Feedback_arc_set). The problem is solvable in fixed parameter tractable time $k^{O(k)}$, and there is an approximation algorithm, however it's open whether there is a constant factor approximation. The word _feedback_ ...
null
This is an empty set which is usually denoted by {}. In this case, the integer *n* is equal to itself while incremented by 1 which is mathematically impossible. Thus, this is an empty set. EX: n = 2, then n = n + 1, 2 = 2 + 1. This is impossible.
null
null
Let $G = (V, E)$ be an undirected graph such that every $v\in V$ has $\deg(v) \geq 3$. We must create an algorithm that outputs a cycle of length O(log(n)) if it exists. This algorithm must return in linear time. If such a cycle exists return True, if it doesn't return False. I had a couple ideas of where to start, ...
Finding a cycle of length log(n) given min degree
|algorithms|graphs|trees|
null
null
null
Suppose we have a bipartite graph with N vertices on either side. Number of possible matchings (i.e. assignments) = N! Number of edges in the bipartite graph = N * N Suppose few edges among the N * N edge set is missing (or have infinite weight) So, how can we find the number of matchings in the "incomplete" b...
Number of matchings in a bipartite graph having missing edges
|graphs|combinatorics|matching|assignment-problem|
The problem is #P-hard, which means it is believed that there is no efficient algorithm for this problem. See https://cs.stackexchange.com/q/19924/755 and https://cs.stackexchange.com/q/19275/755.
The problem is #P-hard, which means it is believed that there is no efficient algorithm for this problem. See https://cs.stackexchange.com/q/19924/755 and https://cs.stackexchange.com/q/19275/755. When the number of missing edges is small, e.g., a fixed constant, there are algorithms whose running time is poly...
Pick an arbitrary vertex $s$ and construct the first $\log n$ levels of the BFS tree $T$ from $s$. You will encounter some non-tree edge $(u,v)$ in the process. Indeed, if no such edge existed, then the number of vertices in the $\log n$-th level of the tree would be at least $3 \cdot 2^{\log n -1} > n$, which is a...
Pick an arbitrary vertex $s$ and construct the first $\lceil \log n \rceil$ levels of the BFS tree $T$ from $s$. You will encounter some non-tree edge $(u,v)$ in the process. Indeed, if no such edge existed, then the number of vertices in the first $\lceil \log n \rceil$ levels of the tree would be at least $1 + 3 ...
null
Assume that $n \ge 5$ (the only other possible non-empty graph that satisfies the constraints on the degree is $K_4$, which is trivial to detect). Pick an arbitrary vertex $s$ and construct the first $\lceil \log n \rceil$ levels of the BFS tree $T$ from $s$. You will encounter some non-tree edge $(u,v)$ in the proc...
Pick an arbitrary vertex $s$ and construct the first $\lceil \log n \rceil$ levels of the BFS tree $T$ from $s$. You will encounter some non-tree edge $(u,v)$ in the process. This is trivially true when $n=4$, as the only possible graph that satisfies the degree constraints is $K_4$ (the case $n \le 3$ is impossibl...
Is there an oracle $A$ with $P^A = NP^A$, but $EXP^A \not= NEXP^A$ ? I found a proof with padding arguments (wikipedia), that $$ P = NP \Rightarrow EXP = NEXP $$ If an oracle $A$ exists with $P=NP$ and $EXP\not=NEXP$ relative to $A$ then the padding technique would be a proof methode, that circumvents the Relat...
Is there an oracle $A$ with $P^A = NP^A$, but $EXP^A \not= NEXP^A$?
|complexity-theory|p-vs-np|oracles|